1 | <?php |
||
26 | class ConfigManager implements ManagerInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var IndexConfig[] |
||
30 | */ |
||
31 | private $indexes = []; |
||
32 | |||
33 | /** |
||
34 | * @param Source\SourceInterface[] $sources |
||
35 | */ |
||
36 | public function __construct(array $sources) |
||
37 | { |
||
38 | foreach ($sources as $source) { |
||
39 | $this->indexes = array_merge($source->getConfiguration(), $this->indexes); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @param string $indexName |
||
45 | * |
||
46 | * @return IndexConfig |
||
47 | */ |
||
48 | public function getIndexConfiguration($indexName) |
||
49 | { |
||
50 | if (!$this->hasIndexConfiguration($indexName)) { |
||
51 | throw new \InvalidArgumentException(sprintf('Index with name "%s" is not configured.', $indexName)); |
||
52 | } |
||
53 | |||
54 | return $this->indexes[$indexName]; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function getIndexNames() |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | public function getTypeConfiguration($indexName, $typeName) |
||
79 | |||
80 | /** |
||
81 | * @param string $indexName |
||
82 | * |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function hasIndexConfiguration($indexName) |
||
89 | } |
||
90 |