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

Core/REST/Client/Input/Parser/Relation.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\Client\Values;
12 use eZ\Publish\API\Repository\ContentService;
13
17 class Relation extends BaseParser
18 {
24 protected $contentService;
25
29 public function __construct(ContentService $contentService)
30 {
31 $this->contentService = $contentService;
32 }
33
46 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
47 {
48 return new Values\Content\Relation(
49 array(
50 'id' => $data['_href'],
51 'sourceContentInfo' => $this->contentService->loadContentInfo(
52 $data['SourceContent']['_href']
53 ),
54 'destinationContentInfo' => $this->contentService->loadContentInfo(
55 $data['DestinationContent']['_href']
56 ),
57 'type' => $this->convertRelationType($data['RelationType']),
58 // @todo: Handle SourceFieldDefinitionIdentifier
59 )
60 );
61 }
62
70 protected function convertRelationType($stringType)
71 {
72 $stringTypeList = explode(',', strtoupper($stringType));
73 $relationType = 0;
74
75 foreach ($stringTypeList as $stringTypeValue) {
76 switch ($stringTypeValue) {
77 case 'COMMON':
78 $relationType |= Values\Content\Relation::COMMON;
79 break;
80 case 'EMBED':
81 $relationType |= Values\Content\Relation::EMBED;
82 break;
83 case 'LINK':
84 $relationType |= Values\Content\Relation::LINK;
85 break;
86 case 'FIELD':
87 $relationType |= Values\Content\Relation::FIELD;
88 break;
89 case 'ASSET':
90 $relationType |= Values\Content\Relation::ASSET;
91 break;
92 default:
93 throw new \RuntimeException(
94 sprintf('Unknown Relation type: "%s"', $stringTypeValue)
95 );
96 }
97 }
98
99 return $relationType;
100 }
101 }
eZ\Publish\API\Repository\Values\Content\Relation
Definition: API/Repository/Values/Content/Relation.php:21
eZ\Publish\API\Repository\Values\Content\Relation\EMBED
const EMBED
Definition: API/Repository/Values/Content/Relation.php:34
eZ\Publish\API\Repository\Values\Content\Relation\LINK
const LINK
Definition: API/Repository/Values/Content/Relation.php:41
eZ\Publish\API\Repository\Values\Content\Relation\FIELD
const FIELD
Definition: API/Repository/Values/Content/Relation.php:48
eZ\Publish\API\Repository\Values\Content\Relation\ASSET
const ASSET
Definition: API/Repository/Values/Content/Relation.php:55
eZ\Publish\API\Repository\Values\Content\Relation\COMMON
const COMMON
Definition: API/Repository/Values/Content/Relation.php:27
eZ\Publish\Core\REST\Client\Input\Parser\Relation\convertRelationType
convertRelationType($stringType)
Converts the string representation of the relation type to its constant.
Definition: Core/REST/Client/Input/Parser/Relation.php:70
eZ\Publish\Core\REST\Client\Input\Parser\Relation\$contentService
$contentService
Definition: Core/REST/Client/Input/Parser/Relation.php:24
eZ\Publish\Core\REST\Client\Input\Parser\Relation\__construct
__construct(ContentService $contentService)
Definition: Core/REST/Client/Input/Parser/Relation.php:29
eZ\Publish\Core\REST\Client\Input\Parser\Relation\parse
parse(array $data, ParsingDispatcher $parsingDispatcher)
Parse input structure.
Definition: Core/REST/Client/Input/Parser/Relation.php:46
eZ\Publish\Core\REST\Client\Values\Content\Relation
Implementation of the \eZ\Publish\API\Repository\Values\Content\Relation class.
Definition: Core/REST/Client/Values/Content/Relation.php:18
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\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+.