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

CriterionVisitor/LanguageCodeIn.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
17 class LanguageCodeIn extends CriterionVisitor
18 {
26 public function canVisit(Criterion $criterion)
27 {
28 return
29 $criterion instanceof Criterion\LanguageCode &&
30 (
31 ($criterion->operator ?: Operator::IN) === Operator::IN ||
32 $criterion->operator === Operator::EQ
33 );
34 }
35
43 protected function getCondition(Criterion $criterion)
44 {
45 if (count($criterion->value) > 1) {
46 return [
47 'terms' => [
48 'language_code_ms' => $criterion->value,
49 ],
50 ];
51 } else {
52 return [
53 'term' => [
54 'language_code_ms' => $criterion->value[0],
55 ],
56 ];
57 }
58 }
59
69 public function visitFilter(Criterion $criterion, Dispatcher $dispatcher, array $languageFilter)
70 {
71 $filter = $this->getCondition($criterion);
72
74 if ($criterion->matchAlwaysAvailable) {
75 $filter = [
76 'or' => [
77 $filter,
78 [
79 'term' => [
80 'always_available_b' => true,
81 ],
82 ],
83 ],
84 ];
85 }
86
87 return $filter;
88 }
89
99 public function visitQuery(Criterion $criterion, Dispatcher $dispatcher, array $languageFilter)
100 {
101 $filter = $this->getCondition($criterion);
102
104 if ($criterion->matchAlwaysAvailable) {
105 $filter = [
106 'bool' => [
107 'should' => [
108 $filter,
109 [
110 'term' => [
111 'always_available_b' => true,
112 ],
113 ],
114 ],
115 'minimum_should_match' => 1,
116 ],
117 ];
118 }
119
120 return $filter;
121 }
122 }
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\LanguageCodeIn
Visits the LanguageCode criterion.
Definition: CriterionVisitor/LanguageCodeIn.php:18
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\LanguageCodeIn\canVisit
canVisit(Criterion $criterion)
Check if visitor is applicable to current criterion.
Definition: CriterionVisitor/LanguageCodeIn.php:26
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\LanguageCodeIn\getCondition
getCondition(Criterion $criterion)
Returns nested condition common for filter and query contexts.
Definition: CriterionVisitor/LanguageCodeIn.php:43
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\Core\Search\Elasticsearch\Content\CriterionVisitor\visitFilter
visitFilter(Criterion $criterion, CriterionVisitorDispatcher $dispatcher, array $languageFilter)
Map field value to a proper Elasticsearch filter representation.
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\visitQuery
visitQuery(Criterion $criterion, CriterionVisitorDispatcher $dispatcher, array $languageFilter)
Map field value to a proper Elasticsearch query representation.
Definition: CriterionVisitor.php:55
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+.