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

Core/REST/Server/Input/Parser/Criterion.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Server\Input\Parser;
8
9 use eZ\Publish\Core\REST\Common\Input\BaseParser;
10 use eZ\Publish\Core\REST\Common\Input\ParsingDispatcher;
11 use eZ\Publish\Core\REST\Common\Exceptions;
12
16 abstract class Criterion extends BaseParser
17 {
19 protected static $criterionIdMap = [
20 'AND' => 'LogicalAnd',
21 'OR' => 'LogicalOr',
22 'NOT' => 'LogicalNot',
23 ];
24
36 public function dispatchCriterion($criterionName, $criterionData, ParsingDispatcher $parsingDispatcher)
37 {
38 $mediaType = $this->getCriterionMediaType($criterionName);
39 try {
40 return $parsingDispatcher->parse([$criterionName => $criterionData], $mediaType);
41 } catch (Exceptions\Parser $e) {
42 throw new Exceptions\Parser("Invalid Criterion id <$criterionName> in <AND>", 0, $e);
43 }
44 }
45
57 public function dispatchFacetBuilder($facetBuilderName, $facetBuilderData, ParsingDispatcher $parsingDispatcher)
58 {
59 $mediaType = $this->getFacetBuilderMediaType($facetBuilderName);
60
61 try {
62 return $parsingDispatcher->parse([$facetBuilderName => $facetBuilderData], $mediaType);
63 } catch (Exceptions\Parser $e) {
64 throw new Exceptions\Parser("Invalid FacetBuilder id <${facetBuilderName}>", 0, $e);
65 }
66 }
67
79 public function dispatchSortClause($sortClauseName, $direction, ParsingDispatcher $parsingDispatcher)
80 {
81 $mediaType = $this->getSortClauseMediaType($sortClauseName);
82
83 return $parsingDispatcher->parse([$sortClauseName => $direction], $mediaType);
84 }
85
86 protected function getCriterionMediaType($criterionName)
87 {
88 $criterionName = str_replace('Criterion', '', $criterionName);
89 if (isset(self::$criterionIdMap[$criterionName])) {
90 $criterionName = self::$criterionIdMap[$criterionName];
91 }
92
93 return 'application/vnd.ez.api.internal.criterion.' . $criterionName;
94 }
95
96 protected function getSortClauseMediaType($sortClauseName)
97 {
98 return 'application/vnd.ez.api.internal.sortclause.' . $sortClauseName;
99 }
100
101 protected function getFacetBuilderMediaType($facetBuilderName)
102 {
103 return 'application/vnd.ez.api.internal.facetbuilder.' . $facetBuilderName;
104 }
105 }
eZ\Publish\API\Repository\Values\Content\Query\Criterion
Definition: API/Repository/Values/Content/Query/Criterion.php:15
eZ\Publish\Core\REST\Common\Exceptions\Parser
Exception thrown if a parser discovers an error.
Definition: REST/Common/Exceptions/Parser.php:15
eZ\Publish\Core\REST\Common\Input\BaseParser
Definition: BaseParser.php:12
eZ\Publish\Core\REST\Common\Input\ParsingDispatcher
Parsing dispatcher.
Definition: ParsingDispatcher.php:15
eZ\Publish\Core\REST\Common\Input\ParsingDispatcher\parse
parse(array $data, $mediaType)
Parses the given $data according to $mediaType.
Definition: ParsingDispatcher.php:66
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\getFacetBuilderMediaType
getFacetBuilderMediaType($facetBuilderName)
Definition: Core/REST/Server/Input/Parser/Criterion.php:101
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\getSortClauseMediaType
getSortClauseMediaType($sortClauseName)
Definition: Core/REST/Server/Input/Parser/Criterion.php:96
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\dispatchCriterion
dispatchCriterion($criterionName, $criterionData, ParsingDispatcher $parsingDispatcher)
Dispatches parsing of a criterion name + data to its own parser.
Definition: Core/REST/Server/Input/Parser/Criterion.php:36
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\$criterionIdMap
static $criterionIdMap
Definition: Core/REST/Server/Input/Parser/Criterion.php:19
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\getCriterionMediaType
getCriterionMediaType($criterionName)
Definition: Core/REST/Server/Input/Parser/Criterion.php:86
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\dispatchFacetBuilder
dispatchFacetBuilder($facetBuilderName, $facetBuilderData, ParsingDispatcher $parsingDispatcher)
Dispatches parsing of a facet builder name + data to its own parser.
Definition: Core/REST/Server/Input/Parser/Criterion.php:57
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\dispatchSortClause
dispatchSortClause($sortClauseName, $direction, ParsingDispatcher $parsingDispatcher)
Dispatches parsing of a sort clause name + direction to its own parser.
Definition: Core/REST/Server/Input/Parser/Criterion.php:79
eZ\Publish\Core\REST\Common\Exceptions
Definition: Core/REST/Common/Exceptions/ForbiddenException.php:7
eZ\Publish\Core\REST\Server\Input\Parser
Definition: ContentCreate.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.