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

Core/REST/Client/Output/ValueObjectVisitor/FieldDefinitionCreateStruct.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\Core\REST\Common\Output\FieldTypeSerializer;
10 use eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor;
11 use eZ\Publish\Core\REST\Common\Output\Generator;
12 use eZ\Publish\Core\REST\Common\Output\Visitor;
13
17 class FieldDefinitionCreateStruct extends ValueObjectVisitor
18 {
20 protected $fieldTypeSerializer;
21
26 public function __construct(FieldTypeSerializer $fieldTypeSerializer)
27 {
28 $this->fieldTypeSerializer = $fieldTypeSerializer;
29 }
30
38 public function visit(Visitor $visitor, Generator $generator, $fieldDefinitionCreateStruct)
39 {
40 $generator->startObjectElement('FieldDefinition');
41 $visitor->setHeader('Content-Type', $generator->getMediaType('FieldDefinitionCreateStruct'));
42
43 $generator->startValueElement('identifier', $fieldDefinitionCreateStruct->identifier);
44 $generator->endValueElement('identifier');
45
46 $generator->startValueElement('fieldType', $fieldDefinitionCreateStruct->fieldTypeIdentifier);
47 $generator->endValueElement('fieldType');
48
49 $generator->startValueElement('fieldGroup', $fieldDefinitionCreateStruct->fieldGroup);
50 $generator->endValueElement('fieldGroup');
51
52 $generator->startValueElement('position', $fieldDefinitionCreateStruct->position);
53 $generator->endValueElement('position');
54
55 $generator->startValueElement('isTranslatable', $fieldDefinitionCreateStruct->isTranslatable ? 'true' : 'false');
56 $generator->endValueElement('isTranslatable');
57
58 $generator->startValueElement('isRequired', $fieldDefinitionCreateStruct->isRequired ? 'true' : 'false');
59 $generator->endValueElement('isRequired');
60
61 $generator->startValueElement('isInfoCollector', $fieldDefinitionCreateStruct->isInfoCollector ? 'true' : 'false');
62 $generator->endValueElement('isInfoCollector');
63
64 $generator->startValueElement('isSearchable', $fieldDefinitionCreateStruct->isSearchable ? 'true' : 'false');
65 $generator->endValueElement('isSearchable');
66
67 $this->fieldTypeSerializer->serializeFieldDefaultValue(
68 $generator,
69 $fieldDefinitionCreateStruct->fieldTypeIdentifier,
70 $fieldDefinitionCreateStruct->defaultValue
71 );
72
73 $this->fieldTypeSerializer->serializeFieldSettings(
74 $generator,
75 $fieldDefinitionCreateStruct->fieldTypeIdentifier,
76 $fieldDefinitionCreateStruct->fieldSettings
77 );
78
79 $this->fieldTypeSerializer->serializeValidatorConfiguration(
80 $generator,
81 $fieldDefinitionCreateStruct->fieldTypeIdentifier,
82 $fieldDefinitionCreateStruct->validatorConfiguration
83 );
84
85 if (!empty($fieldDefinitionCreateStruct->names)) {
86 $generator->startHashElement('names');
87 $generator->startList('value');
88 foreach ($fieldDefinitionCreateStruct->names as $languageCode => $name) {
89 $generator->startValueElement('value', $name, array('languageCode' => $languageCode));
90 $generator->endValueElement('value');
91 }
92 $generator->endList('value');
93 $generator->endHashElement('names');
94 }
95
96 if (!empty($fieldDefinitionCreateStruct->descriptions)) {
97 $generator->startHashElement('descriptions');
98 $generator->startList('value');
99 foreach ($fieldDefinitionCreateStruct->descriptions as $languageCode => $description) {
100 $generator->startValueElement('value', $description, array('languageCode' => $languageCode));
101 $generator->endValueElement('value');
102 }
103 $generator->endList('value');
104 $generator->endHashElement('descriptions');
105 }
106
107 $generator->endObjectElement('FieldDefinition');
108 }
109 }
eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor\FieldDefinitionCreateStruct
FieldDefinitionCreateStruct value object visitor.
Definition: Core/REST/Client/Output/ValueObjectVisitor/FieldDefinitionCreateStruct.php:18
eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor\FieldDefinitionCreateStruct\visit
visit(Visitor $visitor, Generator $generator, $fieldDefinitionCreateStruct)
Visit struct returned by controllers.
Definition: Core/REST/Client/Output/ValueObjectVisitor/FieldDefinitionCreateStruct.php:38
eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor\FieldDefinitionCreateStruct\__construct
__construct(FieldTypeSerializer $fieldTypeSerializer)
Definition: Core/REST/Client/Output/ValueObjectVisitor/FieldDefinitionCreateStruct.php:26
eZ\Publish\Core\REST\Client\Output\ValueObjectVisitor\FieldDefinitionCreateStruct\$fieldTypeSerializer
$fieldTypeSerializer
Definition: Core/REST/Client/Output/ValueObjectVisitor/FieldDefinitionCreateStruct.php:20
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
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.