|
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 abstract class |
|
15
|
|
|
* |
|
16
|
|
|
* @author Dmitry Balabka <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
class IndexConfigAbstract |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* The name of the index for ElasticSearch. |
|
22
|
|
|
* |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $elasticSearchName; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* The internal name of the index. May not be the same as the name used in ElasticSearch, |
|
29
|
|
|
* especially if aliases are enabled. |
|
30
|
|
|
* |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $name; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* An array of settings sent to ElasticSearch when creating the index. |
|
37
|
|
|
* |
|
38
|
|
|
* @var array |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $settings; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* All types that belong to this index. |
|
44
|
|
|
* |
|
45
|
|
|
* @var TypeConfig[] |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $types; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
10 |
|
public function getElasticSearchName() |
|
53
|
|
|
{ |
|
54
|
10 |
|
return $this->elasticSearchName; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
2 |
|
public function getName() |
|
61
|
|
|
{ |
|
62
|
2 |
|
return $this->name; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return array |
|
67
|
|
|
*/ |
|
68
|
6 |
|
public function getSettings() |
|
69
|
|
|
{ |
|
70
|
6 |
|
return $this->settings; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param string $typeName |
|
75
|
|
|
* |
|
76
|
|
|
* @return TypeConfig |
|
77
|
|
|
* |
|
78
|
|
|
* @throws \InvalidArgumentException |
|
79
|
|
|
*/ |
|
80
|
3 |
|
public function getType($typeName) |
|
81
|
|
|
{ |
|
82
|
3 |
|
if (!array_key_exists($typeName, $this->types)) { |
|
83
|
|
|
throw new \InvalidArgumentException(sprintf('Type "%s" does not exist on index "%s"', $typeName, $this->name)); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
3 |
|
return $this->types[$typeName]; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return \FOS\ElasticaBundle\Configuration\TypeConfig[] |
|
91
|
|
|
*/ |
|
92
|
6 |
|
public function getTypes() |
|
93
|
|
|
{ |
|
94
|
6 |
|
return $this->types; |
|
95
|
|
|
} |
|
96
|
|
|
} |