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

CriterionVisitor/ContentTypeIdentifierIn.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor;
8
9 use eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitorDispatcher as Dispatcher;
10 use eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor;
11 use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
12 use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator;
13 use eZ\Publish\SPI\Persistence\Content\Type\Handler as ContentTypeHandler;
14
18 class ContentTypeIdentifierIn extends CriterionVisitor
19 {
25 protected $contentTypeHandler;
26
32 public function __construct(ContentTypeHandler $contentTypeHandler)
33 {
34 $this->contentTypeHandler = $contentTypeHandler;
35 }
36
44 public function canVisit(Criterion $criterion)
45 {
46 return
47 $criterion instanceof Criterion\ContentTypeIdentifier &&
48 (
49 ($criterion->operator ?: Operator::IN) === Operator::IN ||
50 $criterion->operator === Operator::EQ
51 );
52 }
53
63 public function visitFilter(Criterion $criterion, Dispatcher $dispatcher, array $languageFilter)
64 {
65 if (count($criterion->value) > 1) {
66 $idList = [];
67 foreach ($criterion->value as $identifier) {
68 $idList[] = $this->contentTypeHandler->loadByIdentifier($identifier)->id;
69 }
70
71 $filter = [
72 'terms' => [
73 'type_id' => $idList,
74 ],
75 ];
76 } else {
77 $filter = [
78 'term' => [
79 'type_id' => $this->contentTypeHandler->loadByIdentifier($criterion->value[0])->id,
80 ],
81 ];
82 }
83
84 return $filter;
85 }
86 }
eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator\EQ
const EQ
Definition: API/Repository/Values/Content/Query/Criterion/Operator.php:16
eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator\IN
const IN
Definition: API/Repository/Values/Content/Query/Criterion/Operator.php:21
eZ\Publish\API\Repository\Values\Content\Query\Criterion
Definition: API/Repository/Values/Content/Query/Criterion.php:15
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitorDispatcher
Dispatches Criterion objects to a visitor depending on the query context.
Definition: CriterionVisitorDispatcher.php:19
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\ContentTypeIdentifierIn
Visits the ContentTypeIdentifier criterion.
Definition: CriterionVisitor/ContentTypeIdentifierIn.php:19
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\ContentTypeIdentifierIn\canVisit
canVisit(Criterion $criterion)
Check if visitor is applicable to current criterion.
Definition: CriterionVisitor/ContentTypeIdentifierIn.php:44
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\ContentTypeIdentifierIn\__construct
__construct(ContentTypeHandler $contentTypeHandler)
Create from content type handler.
Definition: CriterionVisitor/ContentTypeIdentifierIn.php:32
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\ContentTypeIdentifierIn\$contentTypeHandler
$contentTypeHandler
Definition: CriterionVisitor/ContentTypeIdentifierIn.php:25
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\ContentTypeIdentifierIn\visitFilter
visitFilter(Criterion $criterion, Dispatcher $dispatcher, array $languageFilter)
Map field value to a proper Elasticsearch filter representation.
Definition: CriterionVisitor/ContentTypeIdentifierIn.php:63
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor
Visits the criterion tree into a hash representation of Elasticsearch query/filter AST.
Definition: CriterionVisitor.php:19
eZ\Publish\SPI\Persistence\Content\Type\Handler
Definition: SPI/Persistence/Content/Type/Handler.php:14
eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator
Definition: Specifications.php:7
eZ\Publish\API\Repository\Values\Content\Query\Criterion
Definition: API/Repository/Values/Content/Query/Criterion/Ancestor.php:7
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor
Definition: CriterionVisitor/ContentIdIn.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.