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

Core/REST/Server/Input/Parser/Criterion/ContentTypeIdentifier.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Server\Input\Parser\Criterion;
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\ContentTypeService;
13 use eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeId as ContentTypeIdCriterion;
14
18 class ContentTypeIdentifier extends BaseParser
19 {
25 protected $contentTypeService;
26
27 public function __construct(ContentTypeService $contentTypeService)
28 {
29 $this->contentTypeService = $contentTypeService;
30 }
31
42 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
43 {
44 if (!array_key_exists('ContentTypeIdentifierCriterion', $data)) {
45 throw new Exceptions\Parser('Invalid <ContentTypeIdCriterion> format');
46 }
47 if (!is_array($data['ContentTypeIdentifierCriterion'])) {
48 $data['ContentTypeIdentifierCriterion'] = [$data['ContentTypeIdentifierCriterion']];
49 }
50
51 return new ContentTypeIdCriterion(
52 array_map(
53 function ($contentTypeIdentifier) {
54 return $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier)->id;
55 },
56 $data['ContentTypeIdentifierCriterion']
57 )
58 );
59 }
60 }
eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeId
A criterion that matches content based on its ContentType id.
Definition: API/Repository/Values/Content/Query/Criterion/ContentTypeId.php:20
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\Criterion\ContentTypeIdentifier
Parser for ViewInput.
Definition: Core/REST/Server/Input/Parser/Criterion/ContentTypeIdentifier.php:19
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\ContentTypeIdentifier\parse
parse(array $data, ParsingDispatcher $parsingDispatcher)
Parses input structure to a Criterion object.
Definition: Core/REST/Server/Input/Parser/Criterion/ContentTypeIdentifier.php:42
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\ContentTypeIdentifier\__construct
__construct(ContentTypeService $contentTypeService)
Definition: Core/REST/Server/Input/Parser/Criterion/ContentTypeIdentifier.php:27
eZ\Publish\Core\REST\Server\Input\Parser\Criterion\ContentTypeIdentifier\$contentTypeService
$contentTypeService
Definition: Core/REST/Server/Input/Parser/Criterion/ContentTypeIdentifier.php:25
eZ\Publish\API\Repository\ContentTypeService
Definition: API/Repository/ContentTypeService.php:25
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
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.