Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor;
8
9 use eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor;
10 use eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder;
11 use eZ\Publish\API\Repository\Exceptions\NotImplementedException;
12 use OutOfRangeException;
13
19 class Aggregate extends FacetBuilderVisitor
20 {
26 protected $visitors = [];
27
33 public function __construct(array $visitors = [])
34 {
35 foreach ($visitors as $visitor) {
36 $this->addVisitor($visitor);
37 }
38 }
39
45 public function addVisitor(FacetBuilderVisitor $visitor)
46 {
47 $this->visitors[] = $visitor;
48 }
49
57 public function canMap($name)
58 {
59 return true;
60 }
61
70 public function map($name, $data)
71 {
72 foreach ($this->visitors as $visitor) {
73 if ($visitor->canMap($name)) {
74 return $visitor->map($name, $data);
75 }
76 }
77
78 throw new OutOfRangeException(
79 'No visitor available for: ' . $name
80 );
81 }
82
90 public function canVisit(FacetBuilder $facetBuilder)
91 {
92 return true;
93 }
94
104 public function visit(FacetBuilder $facetBuilder)
105 {
106 foreach ($this->visitors as $visitor) {
107 if ($visitor->canVisit($facetBuilder)) {
108 return $visitor->visit($facetBuilder);
109 }
110 }
111
112 throw new NotImplementedException(
113 'No visitor available for: ' . get_class($facetBuilder)
114 );
115 }
116 }
eZ\Publish\API\Repository\Exceptions\NotImplementedException
This Exception is thrown if a feature has not been implemented intentionally.
Definition: API/Repository/Exceptions/NotImplementedException.php:15
eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder
This class is the base class for facet builders.
Definition: FacetBuilder.php:15
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor\Aggregate
Visits the facet builder tree into a Elasticsearch query.
Definition: Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php:20
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor\Aggregate\visit
visit(FacetBuilder $facetBuilder)
Map facet builder to a proper Elasticsearch representation.
Definition: Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php:104
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor\Aggregate\canVisit
canVisit(FacetBuilder $facetBuilder)
Check if visitor is applicable to current facet builder.
Definition: Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php:90
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor\Aggregate\__construct
__construct(array $visitors=[])
Construct from optional visitor array.
Definition: Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php:33
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor\Aggregate\canMap
canMap($name)
Check if visitor is applicable to current facet result.
Definition: Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php:57
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor\Aggregate\map
map($name, $data)
Map Elasticsearch facet result back to facet objects.
Definition: Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php:70
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor\Aggregate\addVisitor
addVisitor(FacetBuilderVisitor $visitor)
Adds visitor.
Definition: Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php:45
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor\Aggregate\$visitors
$visitors
Definition: Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php:26
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor
Visits the facet builder tree into a hash representation of Elasticsearch aggregations.
Definition: FacetBuilderVisitor.php:17
eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder
Definition: ContentTypeFacetBuilder.php:7
eZ\Publish\Core\Search\Elasticsearch\Content\FacetBuilderVisitor
Definition: Search/Elasticsearch/Content/FacetBuilderVisitor/Aggregate.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.