Skip to content

Commit b9b0c1b

Browse files
committed
Move TypeConfig creation to its own method
1 parent 64fa26e commit b9b0c1b

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

Configuration/Source/ContainerSource.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,7 @@ public function getConfiguration()
4040
{
4141
$indexes = array();
4242
foreach ($this->configArray as $config) {
43-
$types = array();
44-
45-
if (isset($config['types'])) {
46-
foreach ($config['types'] as $typeConfig) {
47-
$types[$typeConfig['name']] = new TypeConfig(
48-
$typeConfig['name'],
49-
$typeConfig['mapping'],
50-
$typeConfig['config']
51-
);
52-
// TODO: handle prototypes..
53-
}
54-
}
55-
43+
$types = $this->getTypes($config);
5644
$index = new IndexConfig($config['name'], $types, array(
5745
'elasticSearchName' => $config['elasticsearch_name'],
5846
'settings' => $config['settings'],
@@ -64,4 +52,28 @@ public function getConfiguration()
6452

6553
return $indexes;
6654
}
55+
56+
/**
57+
* Builds TypeConfig objects for each type.
58+
*
59+
* @param array $config
60+
* @return array
61+
*/
62+
protected function getTypes($config)
63+
{
64+
$types = array();
65+
66+
if (isset($config['types'])) {
67+
foreach ($config['types'] as $typeConfig) {
68+
$types[$typeConfig['name']] = new TypeConfig(
69+
$typeConfig['name'],
70+
$typeConfig['mapping'],
71+
$typeConfig['config']
72+
);
73+
// TODO: handle prototypes..
74+
}
75+
}
76+
77+
return $types;
78+
}
6779
}

Tests/Functional/app/Basic/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ fos_elastica:
9292
identifier: "id"
9393
null_mappings:
9494
mappings: ~
95+
empty_index: ~

0 commit comments

Comments
 (0)