Move TypeConfig creation to its own method

This commit is contained in:
Tim Nagel 2015-01-22 09:33:46 +11:00
parent 64fa26e3d9
commit b9b0c1b961
2 changed files with 26 additions and 13 deletions

View file

@ -40,19 +40,7 @@ class ContainerSource implements SourceInterface
{
$indexes = array();
foreach ($this->configArray as $config) {
$types = array();
if (isset($config['types'])) {
foreach ($config['types'] as $typeConfig) {
$types[$typeConfig['name']] = new TypeConfig(
$typeConfig['name'],
$typeConfig['mapping'],
$typeConfig['config']
);
// TODO: handle prototypes..
}
}
$types = $this->getTypes($config);
$index = new IndexConfig($config['name'], $types, array(
'elasticSearchName' => $config['elasticsearch_name'],
'settings' => $config['settings'],
@ -64,4 +52,28 @@ class ContainerSource implements SourceInterface
return $indexes;
}
/**
* Builds TypeConfig objects for each type.
*
* @param array $config
* @return array
*/
protected function getTypes($config)
{
$types = array();
if (isset($config['types'])) {
foreach ($config['types'] as $typeConfig) {
$types[$typeConfig['name']] = new TypeConfig(
$typeConfig['name'],
$typeConfig['mapping'],
$typeConfig['config']
);
// TODO: handle prototypes..
}
}
return $types;
}
}

View file

@ -92,3 +92,4 @@ fos_elastica:
identifier: "id"
null_mappings:
mappings: ~
empty_index: ~