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

CriterionVisitor/UserMetadataIn.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\Exceptions\NotImplementedException;
12 use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
13 use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator;
14
18 class UserMetadataIn extends CriterionVisitor
19 {
27 public function canVisit(Criterion $criterion)
28 {
29 return
30 $criterion instanceof Criterion\UserMetadata &&
31 (
32 ($criterion->operator ?: Operator::IN) === Operator::IN ||
33 $criterion->operator === Operator::EQ
34 );
35 }
36
48 public function visitFilter(Criterion $criterion, Dispatcher $dispatcher, array $languageFilter)
49 {
50 switch ($criterion->target) {
51 case Criterion\UserMetadata::MODIFIER:
52 $fieldName = 'creator_id';
53 break;
54
55 case Criterion\UserMetadata::OWNER:
56 $fieldName = 'owner_id';
57 break;
58
59 case Criterion\UserMetadata::GROUP:
60 $fieldName = 'owner_user_group_mid';
61 break;
62
63 default:
64 throw new NotImplementedException(
65 'No visitor available for: ' . get_class($criterion) . " with target '{$criterion->target}'"
66 );
67 }
68
69 if (count($criterion->value) > 1) {
70 $filter = [
71 'terms' => [
72 $fieldName => $criterion->value,
73 ],
74 ];
75 } else {
76 $filter = [
77 'term' => [
78 $fieldName => $criterion->value[0],
79 ],
80 ];
81 }
82
83 return $filter;
84 }
85 }
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\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\UserMetadataIn
Visits the UserMetadata criterion.
Definition: CriterionVisitor/UserMetadataIn.php:19
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\UserMetadataIn\canVisit
canVisit(Criterion $criterion)
Check if visitor is applicable to current criterion.
Definition: CriterionVisitor/UserMetadataIn.php:27
eZ\Publish\Core\Search\Elasticsearch\Content\CriterionVisitor\UserMetadataIn\visitFilter
visitFilter(Criterion $criterion, Dispatcher $dispatcher, array $languageFilter)
Map field value to a proper Elasticsearch filter representation.
Definition: CriterionVisitor/UserMetadataIn.php:48
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\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+.