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

Core/REST/Client/Input/Parser/VersionInfo.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\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\Client\Values;
13 use eZ\Publish\API\Repository\ContentService;
14
18 class VersionInfo extends BaseParser
19 {
21 protected $parserTools;
22
28 protected $contentService;
29
34 public function __construct(ParserTools $parserTools, ContentService $contentService)
35 {
36 $this->parserTools = $parserTools;
37 $this->contentService = $contentService;
38 }
39
50 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
51 {
52 $contentInfoId = $this->requestParser->parseHref($data['Content']['_href'], 'contentId');
53
54 return new Values\Content\VersionInfo(
55 $this->contentService,
56 array(
57 'id' => $data['id'],
58 'versionNo' => $data['versionNo'],
59 'status' => $this->convertVersionStatus($data['status']),
60 'modificationDate' => new \DateTime($data['modificationDate']),
61 'creatorId' => $data['Creator']['_href'],
62 'creationDate' => new \DateTime($data['creationDate']),
63 'initialLanguageCode' => $data['initialLanguageCode'],
64 'languageCodes' => explode(',', $data['languageCodes']),
65 'names' => $this->parserTools->parseTranslatableList($data['names']),
66 'contentInfoId' => $contentInfoId,
67 )
68 );
69 }
70
78 protected function convertVersionStatus($statusString)
79 {
80 switch (strtoupper($statusString)) {
81 case 'PUBLISHED':
82 return Values\Content\VersionInfo::STATUS_PUBLISHED;
83 case 'DRAFT':
84 return Values\Content\VersionInfo::STATUS_DRAFT;
85 case 'ARCHIVED':
86 return Values\Content\VersionInfo::STATUS_ARCHIVED;
87 }
88 throw new \RuntimeException(
89 sprintf('Unknown version status: "%s"', $statusString)
90 );
91 }
92 }
eZ\Publish\API\Repository\Values\Content\VersionInfo
Definition: API/Repository/Values/Content/VersionInfo.php:27
eZ\Publish\API\Repository\Values\Content\VersionInfo\STATUS_DRAFT
const STATUS_DRAFT
Definition: API/Repository/Values/Content/VersionInfo.php:28
eZ\Publish\API\Repository\Values\Content\VersionInfo\STATUS_PUBLISHED
const STATUS_PUBLISHED
Definition: API/Repository/Values/Content/VersionInfo.php:29
eZ\Publish\API\Repository\Values\Content\VersionInfo\STATUS_ARCHIVED
const STATUS_ARCHIVED
Definition: API/Repository/Values/Content/VersionInfo.php:30
eZ\Publish\Core\REST\Client\Input\Parser\VersionInfo\__construct
__construct(ParserTools $parserTools, ContentService $contentService)
Definition: Core/REST/Client/Input/Parser/VersionInfo.php:34
eZ\Publish\Core\REST\Client\Input\Parser\VersionInfo\parse
parse(array $data, ParsingDispatcher $parsingDispatcher)
Parse input structure.
Definition: Core/REST/Client/Input/Parser/VersionInfo.php:50
eZ\Publish\Core\REST\Client\Input\Parser\VersionInfo\$parserTools
$parserTools
Definition: Core/REST/Client/Input/Parser/VersionInfo.php:21
eZ\Publish\Core\REST\Client\Input\Parser\VersionInfo\convertVersionStatus
convertVersionStatus($statusString)
Converts the given $statusString to its constant representation.
Definition: Core/REST/Client/Input/Parser/VersionInfo.php:78
eZ\Publish\Core\REST\Client\Input\Parser\VersionInfo\$contentService
$contentService
Definition: Core/REST/Client/Input/Parser/VersionInfo.php:28
eZ\Publish\Core\REST\Client\Values\Content\VersionInfo
Definition: Core/REST/Client/Values/Content/VersionInfo.php:29
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\$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+.