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

ContentTypeGroupInput.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\Input\ParserTools;
12 use eZ\Publish\Core\REST\Common\Exceptions;
13 use eZ\Publish\API\Repository\ContentTypeService;
14 use DateTime;
15
19 class ContentTypeGroupInput extends BaseParser
20 {
26 protected $contentTypeService;
27
29 protected $parserTools;
30
37 public function __construct(ContentTypeService $contentTypeService, ParserTools $parserTools)
38 {
39 $this->contentTypeService = $contentTypeService;
40 $this->parserTools = $parserTools;
41 }
42
51 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
52 {
53 // Since ContentTypeGroupInput is used both for creating and updating ContentTypeGroup and identifier is not
54 // required when updating ContentTypeGroup, we need to rely on PAPI to throw the exception on missing
55 // identifier when creating a ContentTypeGroup
56 // @todo Bring in line with XSD which says that identifier is required always
57
58 $contentTypeGroupIdentifier = null;
59 if (array_key_exists('identifier', $data)) {
60 $contentTypeGroupIdentifier = $data['identifier'];
61 }
62
63 $contentTypeGroupCreateStruct = $this->contentTypeService->newContentTypeGroupCreateStruct($contentTypeGroupIdentifier);
64
65 if (array_key_exists('modificationDate', $data)) {
66 $contentTypeGroupCreateStruct->creationDate = new DateTime($data['modificationDate']);
67 }
68
69 // @todo mainLanguageCode, names, descriptions?
70
71 if (array_key_exists('User', $data) && is_array($data['User'])) {
72 if (!array_key_exists('_href', $data['User'])) {
73 throw new Exceptions\Parser("Missing '_href' attribute for User element in ContentTypeGroupInput.");
74 }
75
76 $contentTypeGroupCreateStruct->creatorId = $this->requestParser->parseHref($data['User']['_href'], 'userId');
77 }
78
79 return $contentTypeGroupCreateStruct;
80 }
81 }
eZ\Publish\Core\REST\Common\Input\BaseParser
Definition: BaseParser.php:12
eZ\Publish\Core\REST\Common\Input\ParserTools
Tools object to be used in Input Parsers.
Definition: ParserTools.php:17
eZ\Publish\Core\REST\Common\Input\ParsingDispatcher
Parsing dispatcher.
Definition: ParsingDispatcher.php:15
eZ\Publish\Core\REST\Server\Input\Parser\ContentTypeGroupInput
Parser for ContentTypeGroupInput.
Definition: ContentTypeGroupInput.php:20
eZ\Publish\Core\REST\Server\Input\Parser\ContentTypeGroupInput\$parserTools
$parserTools
Definition: ContentTypeGroupInput.php:29
eZ\Publish\Core\REST\Server\Input\Parser\ContentTypeGroupInput\parse
parse(array $data, ParsingDispatcher $parsingDispatcher)
Parse input structure.
Definition: ContentTypeGroupInput.php:51
eZ\Publish\Core\REST\Server\Input\Parser\ContentTypeGroupInput\__construct
__construct(ContentTypeService $contentTypeService, ParserTools $parserTools)
Construct.
Definition: ContentTypeGroupInput.php:37
eZ\Publish\Core\REST\Server\Input\Parser\ContentTypeGroupInput\$contentTypeService
$contentTypeService
Definition: ContentTypeGroupInput.php:26
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
Definition: ContentCreate.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.