Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
Authority | |
0.00% |
0 / 21 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
fetchList | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
12 | |||
fromLocationResults | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | /** |
4 | * @package ClientDldb |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsdldb\Elastic; |
9 | |
10 | use BO\Zmsdldb\Entity\Authority as Entity; |
11 | use BO\Zmsdldb\Collection\Authorities as Collection; |
12 | use BO\Zmsdldb\File\Authority as Base; |
13 | |
14 | /** |
15 | */ |
16 | class Authority extends Base |
17 | { |
18 | /** |
19 | * fetch locations for a list of service and group by authority |
20 | * |
21 | * @return Collection\Authorities |
22 | */ |
23 | public function fetchList($servicelist = false) |
24 | { |
25 | $boolquery = Helper::boolFilteredQuery(); |
26 | $boolquery->getFilter()->addMust(Helper::localeFilter($this->locale)); |
27 | $query = \Elastica\Query::create($boolquery); |
28 | $limit = 1000; |
29 | $filter = null; |
30 | |
31 | if ($servicelist && count($servicelist)) { |
32 | $filter = new \Elastica\Filter\Terms('services.service', (array)$servicelist); |
33 | $filter->setExecution('and'); |
34 | $query->setPostFilter($filter); |
35 | } |
36 | $query->addSort(['sort' => 'asc']); |
37 | $resultList = $this |
38 | ->access() |
39 | ->getIndex() |
40 | ->getType('location') |
41 | ->search($query, $limit); |
42 | return $this->fromLocationResults($resultList); |
43 | } |
44 | |
45 | |
46 | /** |
47 | * Take an elasticsearch result and return a authority list |
48 | * |
49 | * @return Collection\Authorities |
50 | */ |
51 | public function fromLocationResults($resultList) |
52 | { |
53 | $authorityList = new Collection(); |
54 | foreach ($resultList as $result) { |
55 | $location = new \BO\Zmsdldb\Entity\Location($result->getData()); |
56 | $authorityList->addLocation($location); |
57 | } |
58 | return $authorityList; |
59 | } |
60 | } |