1 | <?php |
||
17 | class ConfigManager implements ManagerInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var IndexConfig[] |
||
21 | */ |
||
22 | private $indexes = []; |
||
23 | |||
24 | /** |
||
25 | * @param Source\SourceInterface[] $sources |
||
26 | */ |
||
27 | public function __construct(array $sources) |
||
28 | { |
||
29 | foreach ($sources as $source) { |
||
30 | $this->indexes = array_merge($source->getConfiguration(), $this->indexes); |
||
31 | } |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param string $indexName |
||
36 | * |
||
37 | * @return IndexConfig |
||
38 | */ |
||
39 | public function getIndexConfiguration($indexName) |
||
40 | { |
||
41 | if (!$this->hasIndexConfiguration($indexName)) { |
||
42 | throw new \InvalidArgumentException(sprintf('Index with name "%s" is not configured.', $indexName)); |
||
43 | } |
||
44 | |||
45 | return $this->indexes[$indexName]; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | public function getIndexNames() |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | public function getTypeConfiguration($indexName, $typeName) |
||
70 | |||
71 | /** |
||
72 | * @param string $indexName |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function hasIndexConfiguration($indexName) |
||
80 | } |
||
81 |