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

ViewInputOneDotOne.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\Server\Input\Parser\Criterion as CriterionParser;
10 use eZ\Publish\Core\REST\Common\Input\ParsingDispatcher;
11 use eZ\Publish\Core\REST\Common\Exceptions;
12 use eZ\Publish\Core\REST\Server\Values\RestViewInput;
13
17 class ViewInputOneDotOne extends CriterionParser
18 {
29 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
30 {
31 $restViewInput = new RestViewInput();
32
33 // identifier
34 if (!array_key_exists('identifier', $data)) {
35 throw new Exceptions\Parser('Missing <identifier> attribute for <ViewInput>.');
36 }
37 $restViewInput->identifier = $data['identifier'];
38 $restViewInput->languageCode = $data['languageCode'] ?? null;
39 $restViewInput->useAlwaysAvailable = $data['useAlwaysAvailable'] ?? null;
40
41 // query
42 if (array_key_exists('ContentQuery', $data) && is_array($data['ContentQuery'])) {
43 $queryData = $data['ContentQuery'];
44 $queryMediaType = 'application/vnd.ez.api.internal.ContentQuery';
45 }
46
47 if (array_key_exists('LocationQuery', $data) && is_array($data['LocationQuery'])) {
48 $queryData = $data['LocationQuery'];
49 $queryMediaType = 'application/vnd.ez.api.internal.LocationQuery';
50 }
51
52 if (!isset($queryMediaType) || !isset($queryData)) {
53 throw new Exceptions\Parser('Missing <ContentQuery> or <LocationQuery> attribute for <ViewInput>.');
54 }
55
56 $restViewInput->query = $parsingDispatcher->parse($queryData, $queryMediaType);
57
58 return $restViewInput;
59 }
60 }
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\ViewInputOneDotOne
Parser for ViewInput 1.1.
Definition: ViewInputOneDotOne.php:18
eZ\Publish\Core\REST\Server\Input\Parser\ViewInputOneDotOne\parse
parse(array $data, ParsingDispatcher $parsingDispatcher)
Parses input structure to a RestViewInput struct.
Definition: ViewInputOneDotOne.php:29
eZ\Publish\Core\REST\Server\Values\RestViewInput
RestContentCreateStruct view model.
Definition: RestViewInput.php:15
eZ\Publish\Core\REST\Common\Exceptions
Definition: Core/REST/Common/Exceptions/ForbiddenException.php:7
eZ\Publish\Core\REST\Server\Input\Parser\Criterion
Definition: Core/REST/Server/Input/Parser/Criterion/Ancestor.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+.