1 | <?php |
||
14 | class IndexConfig |
||
15 | { |
||
16 | /** |
||
17 | * The name of the index for ElasticSearch. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | private $elasticSearchName; |
||
22 | |||
23 | /** |
||
24 | * The internal name of the index. May not be the same as the name used in ElasticSearch, |
||
25 | * especially if aliases are enabled. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | private $name; |
||
30 | |||
31 | /** |
||
32 | * An array of settings sent to ElasticSearch when creating the index. |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | private $settings; |
||
37 | |||
38 | /** |
||
39 | * All types that belong to this index. |
||
40 | * |
||
41 | * @var TypeConfig[] |
||
42 | */ |
||
43 | private $types; |
||
44 | |||
45 | /** |
||
46 | * Indicates if the index should use an alias, allowing an index repopulation to occur |
||
47 | * without overwriting the current index. |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | private $useAlias = false; |
||
52 | |||
53 | /** |
||
54 | * Constructor expects an array as generated by the Container Configuration builder. |
||
55 | * |
||
56 | * @param string $name |
||
57 | * @param TypeConfig[] $types |
||
58 | * @param array $config |
||
59 | */ |
||
60 | 18 | public function __construct($name, array $types, array $config) |
|
68 | |||
69 | /** |
||
70 | * @return string |
||
71 | */ |
||
72 | 9 | public function getElasticSearchName() |
|
76 | |||
77 | /** |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getName() |
||
81 | { |
||
82 | return $this->name; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @return array |
||
87 | */ |
||
88 | 1 | public function getSettings() |
|
92 | |||
93 | /** |
||
94 | * @param string $typeName |
||
95 | * |
||
96 | * @return TypeConfig |
||
97 | * |
||
98 | * @throws \InvalidArgumentException |
||
99 | */ |
||
100 | public function getType($typeName) |
||
101 | { |
||
102 | if (!array_key_exists($typeName, $this->types)) { |
||
103 | throw new \InvalidArgumentException(sprintf('Type "%s" does not exist on index "%s"', $typeName, $this->name)); |
||
104 | } |
||
105 | |||
106 | return $this->types[$typeName]; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @return \FOS\ElasticaBundle\Configuration\TypeConfig[] |
||
111 | */ |
||
112 | 1 | public function getTypes() |
|
116 | |||
117 | /** |
||
118 | * @return boolean |
||
119 | */ |
||
120 | 9 | public function isUseAlias() |
|
124 | } |
||
125 |