1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the OpCart software. |
4
|
|
|
* |
5
|
|
|
* (c) 2015, OpticsPlanet, Inc |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace FOS\ElasticaBundle\Configuration; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Index configuration trait class |
15
|
|
|
* |
16
|
|
|
* @author Dmitry Balabka <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
trait IndexConfigTrait |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* The name of the index for ElasticSearch. |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
private $elasticSearchName; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The model of the index |
29
|
|
|
* |
30
|
|
|
* @var string|null |
31
|
|
|
*/ |
32
|
|
|
private $model; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The internal name of the index. May not be the same as the name used in ElasticSearch, |
36
|
|
|
* especially if aliases are enabled. |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $name; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* An array of settings sent to ElasticSearch when creating the index. |
44
|
|
|
* |
45
|
|
|
* @var array |
46
|
|
|
*/ |
47
|
|
|
private $settings; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* All types that belong to this index. |
51
|
|
|
* |
52
|
|
|
* @var TypeConfig[] |
53
|
|
|
*/ |
54
|
|
|
private $types; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
11 |
|
public function getElasticSearchName(): string |
60
|
|
|
{ |
61
|
11 |
|
return $this->elasticSearchName; |
62
|
|
|
} |
63
|
|
|
|
64
|
8 |
|
public function getModel(): ?string |
65
|
|
|
{ |
66
|
8 |
|
return $this->model; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
3 |
|
public function getName(): string |
73
|
|
|
{ |
74
|
3 |
|
return $this->name; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return array |
79
|
|
|
*/ |
80
|
10 |
|
public function getSettings(): array |
81
|
|
|
{ |
82
|
10 |
|
return $this->settings; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/**s |
86
|
|
|
* @throws \InvalidArgumentException |
87
|
|
|
*/ |
88
|
2 |
|
public function getType(string $typeName): TypeConfig |
89
|
|
|
{ |
90
|
2 |
|
if (!array_key_exists($typeName, $this->types)) { |
91
|
|
|
throw new \InvalidArgumentException(sprintf('Type "%s" does not exist on index "%s"', $typeName, $this->name)); |
92
|
|
|
} |
93
|
|
|
|
94
|
2 |
|
return $this->types[$typeName]; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return \FOS\ElasticaBundle\Configuration\TypeConfig[] |
99
|
|
|
*/ |
100
|
9 |
|
public function getTypes() |
101
|
|
|
{ |
102
|
9 |
|
return $this->types; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|