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

Client/Output/ValueObjectVisitor/VersionUpdate.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor;
8
9 use eZ\Publish\API\Repository\Values\Content\Field;
10 use eZ\Publish\API\Repository\Values\ContentType\ContentType;
11 use eZ\Publish\Core\REST\Common\Output\FieldTypeSerializer;
12 use eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor;
13 use eZ\Publish\Core\REST\Common\Output\Generator;
14 use eZ\Publish\Core\REST\Common\Output\Visitor;
15
19 class VersionUpdate extends ValueObjectVisitor
20 {
24 public function __construct(FieldTypeSerializer $fieldTypeSerializer)
25 {
26 $this->fieldTypeSerializer = $fieldTypeSerializer;
27 }
28
34 public function visit(Visitor $visitor, Generator $generator, $versionUpdate)
35 {
36 $updateStruct = $versionUpdate->contentUpdateStruct;
37
38 $generator->startObjectElement('VersionUpdate');
39 $visitor->setHeader('Content-Type', $generator->getMediaType('VersionUpdate'));
40 $generator->startValueElement('initialLanguageCode', $updateStruct->initialLanguageCode);
41 $generator->endValueElement('initialLanguageCode');
42
43 if (is_array($updateStruct->fields) && count($updateStruct->fields) > 0) {
44 $generator->startHashElement('fields');
45 $generator->startList('field');
46 foreach ($updateStruct->fields as $field) {
47 $this->visitField($generator, $versionUpdate->contentType, $field);
48 }
49 $generator->endList('field');
50 $generator->endHashElement('fields');
51 }
52
53 $generator->endObjectElement('VersionUpdate');
54 }
55
56 private function visitField(Generator $generator, ContentType $contentType, Field $field)
57 {
58 $generator->startHashElement('field');
59
60 $generator->startValueElement('id', $field->id);
61 $generator->endValueElement('id');
62
63 $generator->startValueElement('fieldDefinitionIdentifier', $field->fieldDefIdentifier);
64 $generator->endValueElement('fieldDefinitionIdentifier');
65
66 $generator->startValueElement('languageCode', $field->languageCode);
67 $generator->endValueElement('languageCode');
68
69 $this->fieldTypeSerializer->serializeFieldValue(
70 $generator,
71 $contentType,
72 $field
73 );
74
75 $generator->endHashElement('field');
76 }
77 }
eZ\Publish\API\Repository\Values\ContentType\ContentType
Definition: API/Repository/Values/ContentType/ContentType.php:36
eZ\Publish\API\Repository\Values\Content\Field
Definition: API/Repository/Values/Content/Field.php:21
eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor\VersionUpdate
Visits a ContentUpdateStruct into a VersionUpdate request.
Definition: Client/Output/ValueObjectVisitor/VersionUpdate.php:20
eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor\VersionUpdate\visitField
visitField(Generator $generator, ContentType $contentType, Field $field)
Definition: Client/Output/ValueObjectVisitor/VersionUpdate.php:56
eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor\VersionUpdate\visit
visit(Visitor $visitor, Generator $generator, $versionUpdate)
Definition: Client/Output/ValueObjectVisitor/VersionUpdate.php:34
eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor\VersionUpdate\__construct
__construct(FieldTypeSerializer $fieldTypeSerializer)
Definition: Client/Output/ValueObjectVisitor/VersionUpdate.php:24
eZ\Publish\Core\REST\Common\Output\FieldTypeSerializer
Serializes FieldType related data for REST output.
Definition: FieldTypeSerializer.php:19
eZ\Publish\Core\REST\Common\Output\Generator
Output generator.
Definition: REST/Common/Output/Generator.php:13
eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor
Basic ValueObjectVisitor.
Definition: ValueObjectVisitor.php:18
eZ\Publish\Core\REST\Common\Output\Visitor
Visits a value object into an HTTP Response.
Definition: Visitor.php:15
eZ\Publish\Core\REST\Common\Output\Visitor\setHeader
setHeader($name, $value)
Set HTTP response header.
Definition: Visitor.php:64
eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor
Definition: Client/Output/ValueObjectVisitor/ContentObjectStates.php:7
eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor
Definition: Common/Output/ValueObjectVisitor/ContentObjectStates.php:7
eZ\Publish\SPI\Persistence\Content\Type
Definition: SPI/Persistence/Content/Type/CreateStruct.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.