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

Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/Field.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler;
8
9 use eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter;
10 use eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\FieldValue\Converter as FieldValueConverter;
11 use eZ\Publish\Core\Persistence\Database\DatabaseHandler;
12 use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
13 use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry as Registry;
14 use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException;
15 use eZ\Publish\Core\Persistence\TransformationProcessor;
16 use eZ\Publish\Core\Persistence\Database\SelectQuery;
17 use eZ\Publish\SPI\Persistence\Content\Type\Handler as ContentTypeHandler;
18 use eZ\Publish\SPI\Persistence\Content\Language\Handler as LanguageHandler;
19
23 class Field extends FieldBase
24 {
30 protected $fieldConverterRegistry;
31
37 protected $fieldValueConverter;
38
44 protected $transformationProcessor;
45
46 public function __construct(
47 DatabaseHandler $dbHandler,
48 ContentTypeHandler $contentTypeHandler,
49 LanguageHandler $languageHandler,
50 Registry $fieldConverterRegistry,
51 FieldValueConverter $fieldValueConverter,
52 TransformationProcessor $transformationProcessor
53 ) {
54 parent::__construct($dbHandler, $contentTypeHandler, $languageHandler);
55
56 $this->fieldConverterRegistry = $fieldConverterRegistry;
57 $this->fieldValueConverter = $fieldValueConverter;
58 $this->transformationProcessor = $transformationProcessor;
59 }
60
68 public function accept(Criterion $criterion)
69 {
70 return $criterion instanceof Criterion\Field;
71 }
72
88 protected function getFieldsInformation($fieldIdentifier)
89 {
90 $fieldMapArray = [];
91 $fieldMap = $this->contentTypeHandler->getSearchableFieldMap();
92
93 foreach ($fieldMap as $contentTypeIdentifier => $fieldIdentifierMap) {
94 // First check if field exists in the current ContentType, there is nothing to do if it doesn't
95 if (!isset($fieldIdentifierMap[$fieldIdentifier])) {
96 continue;
97 }
98
99 $fieldTypeIdentifier = $fieldIdentifierMap[$fieldIdentifier]['field_type_identifier'];
100 $fieldMapArray[$fieldTypeIdentifier]['ids'][] = $fieldIdentifierMap[$fieldIdentifier]['field_definition_id'];
101 if (!isset($fieldMapArray[$fieldTypeIdentifier]['column'])) {
102 $fieldMapArray[$fieldTypeIdentifier]['column'] = $this->fieldConverterRegistry->getConverter($fieldTypeIdentifier)->getIndexColumn();
103 }
104 }
105
106 if (empty($fieldMapArray)) {
107 throw new InvalidArgumentException(
108 '$criterion->target',
109 "No searchable fields found for the given criterion target '{$fieldIdentifier}'."
110 );
111 }
112
113 return $fieldMapArray;
114 }
115
133 public function handle(
134 CriteriaConverter $converter,
135 SelectQuery $query,
136 Criterion $criterion,
137 array $languageSettings
138 ) {
139 $fieldsInformation = $this->getFieldsInformation($criterion->target);
140
141 $subSelect = $query->subSelect();
142 $subSelect->select(
143 $this->dbHandler->quoteColumn('contentobject_id')
144 )->from(
145 $this->dbHandler->quoteTable('ezcontentobject_attribute')
146 );
147
148 $whereExpressions = [];
149
150 foreach ($fieldsInformation as $fieldTypeIdentifier => $fieldsInfo) {
151 if ($fieldsInfo['column'] === false) {
152 continue;
153 }
154
155 $filter = $this->fieldValueConverter->convertCriteria(
156 $fieldTypeIdentifier,
157 $subSelect,
158 $criterion,
159 $fieldsInfo['column']
160 );
161
162 $whereExpressions[] = $subSelect->expr->lAnd(
163 $subSelect->expr->in(
164 $this->dbHandler->quoteColumn('contentclassattribute_id'),
165 $fieldsInfo['ids']
166 ),
167 $filter
168 );
169 }
170
171 return $this->getInExpressionWithFieldConditions(
172 $query,
173 $subSelect,
174 $languageSettings,
175 $whereExpressions,
176 $fieldsInformation
177 );
178 }
179 }
eZ\Publish\API\Repository\Values\Content\Query\Criterion\Field
The Field Criterion class.
Definition: API/Repository/Values/Content/Query/Criterion/Field.php:19
eZ\Publish\API\Repository\Values\Content\Query\Criterion
Definition: API/Repository/Values/Content/Query/Criterion.php:15
eZ\Publish\Core\Base\Exceptions\InvalidArgumentException
Invalid Argument Type Exception implementation.
Definition: Core/Base/Exceptions/InvalidArgumentException.php:20
eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry
Definition: ConverterRegistry.php:12
eZ\Publish\Core\Persistence\TransformationProcessor
Interface for processing a set of transformations on a string.
Definition: TransformationProcessor.php:15
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter
Content locator gateway implementation using the DoctrineDatabase.
Definition: Search/Legacy/Content/Common/Gateway/CriteriaConverter.php:17
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\FieldBase
Base criterion handler for field criteria.
Definition: Legacy/Content/Common/Gateway/CriterionHandler/FieldBase.php:21
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\FieldBase\getInExpressionWithFieldConditions
getInExpressionWithFieldConditions(SelectQuery $query, SelectQuery $subSelect, array $languageSettings, array $fieldWhereExpressions, array $fieldsInformation)
Definition: Legacy/Content/Common/Gateway/CriterionHandler/FieldBase.php:151
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\FieldBase\$languageHandler
$languageHandler
Definition: Legacy/Content/Common/Gateway/CriterionHandler/FieldBase.php:34
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\FieldBase\$contentTypeHandler
$contentTypeHandler
Definition: Legacy/Content/Common/Gateway/CriterionHandler/FieldBase.php:27
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\FieldValue\Converter
Content locator gateway implementation using the DoctrineDatabase.
Definition: Search/Legacy/Content/Common/Gateway/CriterionHandler/FieldValue/Converter.php:17
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\Field\getFieldsInformation
getFieldsInformation($fieldIdentifier)
Returns relevant field information for the specified field.
Definition: Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/Field.php:88
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\Field\$transformationProcessor
$transformationProcessor
Definition: Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/Field.php:44
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\Field\$fieldValueConverter
$fieldValueConverter
Definition: Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/Field.php:37
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\Field\handle
handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
Generate query expression for a Criterion this handler accepts.
Definition: Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/Field.php:133
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\Field\$fieldConverterRegistry
$fieldConverterRegistry
Definition: Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/Field.php:30
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\Field\__construct
__construct(DatabaseHandler $dbHandler, ContentTypeHandler $contentTypeHandler, LanguageHandler $languageHandler, Registry $fieldConverterRegistry, FieldValueConverter $fieldValueConverter, TransformationProcessor $transformationProcessor)
Definition: Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/Field.php:46
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\Field\accept
accept(Criterion $criterion)
Check if this criterion handler accepts to handle the given criterion.
Definition: Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/Field.php:68
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\$dbHandler
$dbHandler
Definition: Search/Legacy/Content/Common/Gateway/CriterionHandler.php:38
eZ\Publish\Core\Persistence\Database\DatabaseHandler
Interface for relational database abstractions supported by eZ.
Definition: DatabaseHandler.php:18
eZ\Publish\Core\Persistence\Database\Query\subSelect
subSelect()
Create a subselect used with the current query.
eZ\Publish\Core\Persistence\Database\SelectQuery
Definition: SelectQuery.php:16
eZ\Publish\SPI\Persistence\Content\Language\Handler
Language Handler interface.
Definition: SPI/Persistence/Content/Language/Handler.php:15
eZ\Publish\SPI\Persistence\Content\Type\Handler
Definition: SPI/Persistence/Content/Type/Handler.php:14
eZ\Publish\API\Repository\Values\Content\Query\Criterion
Definition: API/Repository/Values/Content/Query/Criterion/Ancestor.php:7
eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler
Definition: Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/ContentId.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.