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

Publish/Core/REST/Client/Input/Parser/Content.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Client\Input\Parser;
8
9 use eZ\Publish\Core\REST\Common\Input\ParserTools;
10 use eZ\Publish\API\Repository\ContentService;
11 use eZ\Publish\Core\REST\Common\Input\BaseParser;
12 use eZ\Publish\Core\REST\Common\Input\FieldTypeParser;
13 use eZ\Publish\Core\REST\Common\Input\ParsingDispatcher;
14 use eZ\Publish\Core\REST\Client\Values;
15 use eZ\Publish\API\Repository\Values\Content\Field;
16
23 class Content extends BaseParser
24 {
30 protected $versionInfoParser;
31
33 protected $parserTools;
34
36 protected $contentService;
37
39 protected $fieldTypeParser;
40
47 public function __construct(ParserTools $parserTools, ContentService $contentService, VersionInfo $versionInfoParser, FieldTypeParser $fieldTypeParser)
48 {
49 $this->parserTools = $parserTools;
50 $this->contentService = $contentService;
51 $this->versionInfoParser = $versionInfoParser;
52 $this->fieldTypeParser = $fieldTypeParser;
53 }
54
65 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
66 {
67 $versionInfo = $this->versionInfoParser->parse(
68 $data['CurrentVersion']['Version']['VersionInfo'],
69 $parsingDispatcher
70 );
71 $fields = $this->parseFields(
72 $data['CurrentVersion']['Version']['Fields'],
73 str_replace('/api/ezp/v2/content/objects/', '', $versionInfo->contentInfoId)
74 );
75
76 return new Values\Content\Content(
77 $this->contentService,
78 array(
79 'versionInfo' => $versionInfo,
80 'internalFields' => $fields,
81 )
82 );
83 }
84
93 protected function parseFields(array $rawFieldsData, $contentId)
94 {
95 $fields = array();
96
97 if (isset($rawFieldsData['field'])) {
98 foreach ($rawFieldsData['field'] as $rawFieldData) {
99 $fields[] = new Field(
100 array(
101 'id' => $rawFieldData['id'],
102 'fieldDefIdentifier' => $rawFieldData['fieldDefinitionIdentifier'],
103 'languageCode' => $rawFieldData['languageCode'],
104 'value' => $this->fieldTypeParser->parseFieldValue(
105 $contentId,
106 $rawFieldData['fieldDefinitionIdentifier'],
107 $rawFieldData['fieldValue']
108 ),
109 )
110 );
111 }
112 }
113
114 return $fields;
115 }
116 }
eZ\Publish\API\Repository\Values\Content\Content
Definition: Publish/API/Repository/Values/Content/Content.php:21
eZ\Publish\API\Repository\Values\Content\Field
Definition: API/Repository/Values/Content/Field.php:21
eZ\Publish\API\Repository\Values\Content\VersionInfo
Definition: API/Repository/Values/Content/VersionInfo.php:27
eZ\Publish\Core\REST\Client\Input\Parser\Content\parseFields
parseFields(array $rawFieldsData, $contentId)
Parses the fields from the given $rawFieldsData.
Definition: Publish/Core/REST/Client/Input/Parser/Content.php:93
eZ\Publish\Core\REST\Client\Input\Parser\Content\$contentService
$contentService
Definition: Publish/Core/REST/Client/Input/Parser/Content.php:36
eZ\Publish\Core\REST\Client\Input\Parser\Content\__construct
__construct(ParserTools $parserTools, ContentService $contentService, VersionInfo $versionInfoParser, FieldTypeParser $fieldTypeParser)
Definition: Publish/Core/REST/Client/Input/Parser/Content.php:47
eZ\Publish\Core\REST\Client\Input\Parser\Content\$versionInfoParser
$versionInfoParser
Definition: Publish/Core/REST/Client/Input/Parser/Content.php:30
eZ\Publish\Core\REST\Client\Input\Parser\Content\$fieldTypeParser
$fieldTypeParser
Definition: Publish/Core/REST/Client/Input/Parser/Content.php:39
eZ\Publish\Core\REST\Client\Input\Parser\Content\$parserTools
$parserTools
Definition: Publish/Core/REST/Client/Input/Parser/Content.php:33
eZ\Publish\Core\REST\Client\Input\Parser\Content\parse
parse(array $data, ParsingDispatcher $parsingDispatcher)
Parse input structure.
Definition: Publish/Core/REST/Client/Input/Parser/Content.php:65
eZ\Publish\Core\REST\Client\Values\Content\Content
Definition: Publish/Core/REST/Client/Values/Content/Content.php:26
eZ\Publish\Core\REST\Common\Input\BaseParser
Definition: BaseParser.php:12
eZ\Publish\Core\REST\Common\Input\FieldTypeParser
Definition: FieldTypeParser.php:15
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\$fieldTypeParser
$fieldTypeParser
Definition: common.php:123
eZ\Publish\Core\REST\$parserTools
$parserTools
Definition: common.php:120
eZ\Publish\API\Repository\ContentService
Definition: API/Repository/ContentService.php:27
eZ\Publish\Core\REST\Client\Input\Parser
Definition: Publish/Core/REST/Client/Input/Parser/Content.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.