| @@ 273-296 (lines=24) @@ | ||
| 270 | * |
|
| 271 | * @return array Buckets. |
|
| 272 | */ |
|
| 273 | protected function fetchAggregation(DocumentIterator $result, $filterName, $values) |
|
| 274 | { |
|
| 275 | $data = []; |
|
| 276 | $aggregation = $result->getAggregation(sprintf('%s-filter', $filterName)); |
|
| 277 | ||
| 278 | if ($aggregation->getAggregation($filterName)) { |
|
| 279 | $aggregation = $aggregation->find($filterName.'.query'); |
|
| 280 | $data['all-selected'] = $aggregation; |
|
| 281 | ||
| 282 | return $data; |
|
| 283 | } |
|
| 284 | ||
| 285 | if (!empty($values)) { |
|
| 286 | foreach ($values as $name => $value) { |
|
| 287 | $data[$name] = $aggregation->find(sprintf('%s.%s.query', $name, $filterName)); |
|
| 288 | } |
|
| 289 | ||
| 290 | $data['all-selected'] = $aggregation->find(sprintf('all-selected.%s.query', $filterName)); |
|
| 291 | ||
| 292 | return $data; |
|
| 293 | } |
|
| 294 | ||
| 295 | return []; |
|
| 296 | } |
|
| 297 | ||
| 298 | /** |
|
| 299 | * A method used to add an additional filter to the aggregations |
|
| @@ 80-103 (lines=24) @@ | ||
| 77 | * |
|
| 78 | * @return array Buckets. |
|
| 79 | */ |
|
| 80 | protected function fetchAggregation(DocumentIterator $result, $filterName, $values) |
|
| 81 | { |
|
| 82 | $data = []; |
|
| 83 | $aggregation = $result->getAggregation(sprintf('%s-filter', $filterName)); |
|
| 84 | ||
| 85 | if ($aggregation->getAggregation($filterName)) { |
|
| 86 | $aggregation = $aggregation->find($filterName.'.query'); |
|
| 87 | $data['all-selected'] = $aggregation; |
|
| 88 | ||
| 89 | return $data; |
|
| 90 | } |
|
| 91 | ||
| 92 | if (!empty($values)) { |
|
| 93 | foreach ($values as $name => $value) { |
|
| 94 | $data[$name] = $aggregation->find(sprintf('%s.%s.query', $name, $filterName)); |
|
| 95 | } |
|
| 96 | ||
| 97 | $data['all-selected'] = $aggregation->find(sprintf('all-selected.%s.query', $filterName)); |
|
| 98 | ||
| 99 | return $data; |
|
| 100 | } |
|
| 101 | ||
| 102 | return []; |
|
| 103 | } |
|
| 104 | ||
| 105 | /** |
|
| 106 | * A method used to add an additional filter to the aggregations |
|