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

FieldParser.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Server\Input\Parser\FacetBuilder;
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 use eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder\FieldFacetBuilder;
13
17 class FieldParser extends BaseParser
18 {
29 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
30 {
31 if (!array_key_exists('Field', $data)) {
32 throw new Exceptions\Parser('Invalid <Field> format');
33 }
34
35 $sortType = [
36 'COUNT_ASC' => FieldFacetBuilder::COUNT_ASC,
37 'COUNT_DESC' => FieldFacetBuilder::COUNT_DESC,
38 'TERM_ASC' => FieldFacetBuilder::TERM_ASC,
39 'TERM_DESC' => FieldFacetBuilder::TERM_DESC,
40 ];
41
42 if (isset($data['Field']['sort'])) {
43 $type = $data['Field']['sort'];
44
45 if (!in_array($type, $sortType)) {
46 throw new Exceptions\Parser('<Field> unknown sort type (supported: ' . implode(', ', array_keys($sortType)) . ')');
47 }
48
49 $data['Field']['sort'] = $sortType[$type];
50 } else {
51 throw new Exceptions\Parser('<Field> sort type missing (supported: ' . implode(', ', array_keys($sortType)) . ')');
52 }
53
54 return new FieldFacetBuilder($data['Field']);
55 }
56 }
eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder\FieldFacetBuilder
Build a field term facet.
Definition: FieldFacetBuilder.php:19
eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder\FieldFacetBuilder\TERM_DESC
const TERM_DESC
Definition: FieldFacetBuilder.php:23
eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder\FieldFacetBuilder\COUNT_DESC
const COUNT_DESC
Definition: FieldFacetBuilder.php:21
eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder\FieldFacetBuilder\COUNT_ASC
const COUNT_ASC
Definition: FieldFacetBuilder.php:20
eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder\FieldFacetBuilder\TERM_ASC
const TERM_ASC
Definition: FieldFacetBuilder.php:22
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\Server\Input\Parser\FacetBuilder\FieldParser
Parser for Field facet builder.
Definition: FieldParser.php:18
eZ\Publish\Core\REST\Server\Input\Parser\FacetBuilder\FieldParser\parse
parse(array $data, ParsingDispatcher $parsingDispatcher)
Parses input structure to a FacetBuilder object.
Definition: FieldParser.php:29
eZ\Publish\Core\REST\Common\Exceptions
Definition: Core/REST/Common/Exceptions/ForbiddenException.php:7
eZ\Publish\Core\REST\Server\Input\Parser\FacetBuilder
Definition: ContentTypeParser.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.