Total Complexity | 7 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 55.56% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | trait QueryComponentFacetTrait |
||
13 | { |
||
14 | /** |
||
15 | * @var BaseIndex |
||
16 | */ |
||
17 | protected $index; |
||
18 | /** |
||
19 | * @var BaseQuery |
||
20 | */ |
||
21 | protected $query; |
||
22 | /** |
||
23 | * @var Query |
||
24 | */ |
||
25 | protected $clientQuery; |
||
26 | |||
27 | /** |
||
28 | * Add facets from the index |
||
29 | */ |
||
30 | 4 | protected function buildFacets(): void |
|
31 | { |
||
32 | 4 | $facets = $this->clientQuery->getFacetSet(); |
|
33 | // Facets should be set from the index configuration |
||
34 | 4 | foreach ($this->index->getFacetFields() as $class => $config) { |
|
35 | $facets->createFacetField('facet-' . $config['Title'])->setField($config['Field']); |
||
36 | } |
||
37 | // Count however, comes from the query |
||
38 | 4 | $facets->setMinCount($this->query->getFacetsMinCount()); |
|
39 | 4 | } |
|
40 | |||
41 | /** |
||
42 | * Add facet filters based on the current request |
||
43 | */ |
||
44 | 4 | protected function buildFacetQuery() |
|
58 | } |
||
59 | } |
||
63 |