Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
ElasticAccess | |
0.00% |
0 / 31 |
|
0.00% |
0 / 9 |
110 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
connectElasticSearch | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
getIndex | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConnection | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
loadLocations | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
loadServices | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
loadTopics | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
loadSettings | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
loadAuthorities | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * @package 115Mandant |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsdldb; |
9 | |
10 | /** |
11 | * @SuppressWarnings(TooManyMethods) |
12 | * |
13 | * Using elastica query classes increases object dependencies dramatically |
14 | * @SuppressWarnings(CouplingBetweenObjects) |
15 | */ |
16 | class ElasticAccess extends FileAccess |
17 | { |
18 | /** |
19 | * The client used to talk to elastic search. |
20 | * |
21 | * @var \Elastica\Client |
22 | */ |
23 | protected $connection; |
24 | |
25 | /** |
26 | * Index from elastic search |
27 | * |
28 | * @var \Elastica\Index $index |
29 | */ |
30 | protected $index; |
31 | |
32 | /** |
33 | * |
34 | * @return self |
35 | */ |
36 | public function __construct($index = null, $host = 'localhost', $port = '9200', $transport = 'Http') |
37 | { |
38 | if ($index) { |
39 | $this->connectElasticSearch($index, $host, $port, $transport); |
40 | } |
41 | } |
42 | |
43 | public function connectElasticSearch($index, $host = 'localhost', $port = '9200', $transport = 'Http') |
44 | { |
45 | $this->connection = new \Elastica\Client(array( |
46 | 'host' => $host, |
47 | 'port' => $port, |
48 | 'transport' => $transport |
49 | )); |
50 | $this->index = $this->getConnection()->getIndex($index); |
51 | } |
52 | |
53 | /** |
54 | * |
55 | * @return \Elastica\Index |
56 | */ |
57 | public function getIndex() |
58 | { |
59 | return $this->index; |
60 | } |
61 | |
62 | /** |
63 | * |
64 | * @return \Elastica\Client |
65 | */ |
66 | protected function getConnection() |
67 | { |
68 | return $this->connection; |
69 | } |
70 | |
71 | /** |
72 | * |
73 | * @return self |
74 | */ |
75 | public function loadLocations($locationJson, $locale = 'de') |
76 | { |
77 | $this->accessInstance[$locale]['Location'] = new Elastic\Location($locationJson, $locale); |
78 | $this->accessInstance[$locale]['Location']->setAccessInstance($this); |
79 | return $this; |
80 | } |
81 | |
82 | /** |
83 | * |
84 | * @return self |
85 | */ |
86 | public function loadServices($serviceJson, $locale = 'de') |
87 | { |
88 | $this->accessInstance[$locale]['Service'] = new Elastic\Service($serviceJson, $locale); |
89 | $this->accessInstance[$locale]['Service']->setAccessInstance($this); |
90 | return $this; |
91 | } |
92 | |
93 | /** |
94 | * |
95 | * @return self |
96 | */ |
97 | public function loadTopics($topicJson, $locale = 'de') |
98 | { |
99 | $this->accessInstance[$locale]['Topic'] = new Elastic\Topic($topicJson, $locale); |
100 | $this->accessInstance[$locale]['Topic']->setAccessInstance($this); |
101 | $this->accessInstance[$locale]['Link'] = new Elastic\Link($topicJson, $locale); |
102 | $this->accessInstance[$locale]['Link']->setAccessInstance($this); |
103 | return $this; |
104 | } |
105 | |
106 | /** |
107 | * |
108 | * @return self |
109 | */ |
110 | public function loadSettings($settingsJson) |
111 | { |
112 | $this->accessInstance['de']['Setting'] = new Elastic\Setting($settingsJson); |
113 | $this->accessInstance['de']['Setting']->setAccessInstance($this); |
114 | $this->accessInstance['de']['Office'] = new Elastic\Office($settingsJson); |
115 | $this->accessInstance['de']['Office']->setAccessInstance($this); |
116 | $this->accessInstance['de']['Borough'] = new Elastic\Borough($settingsJson); |
117 | $this->accessInstance['de']['Borough']->setAccessInstance($this); |
118 | return $this; |
119 | } |
120 | |
121 | |
122 | /** |
123 | * |
124 | * @return self |
125 | */ |
126 | public function loadAuthorities($authorityJson, $locale = 'de') |
127 | { |
128 | $this->accessInstance[$locale]['Authority'] = new Elastic\Authority($authorityJson, $locale); |
129 | $this->accessInstance[$locale]['Authority']->setAccessInstance($this); |
130 | return $this; |
131 | } |
132 | } |