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

Output/ValueObjectVisitor/RestUser.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor;
8
9 use eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor;
10 use eZ\Publish\Core\REST\Common\Output\Generator;
11 use eZ\Publish\Core\REST\Common\Output\Visitor;
12 use eZ\Publish\Core\REST\Server\Values\Version as VersionValue;
13
17 class RestUser extends ValueObjectVisitor
18 {
26 public function visit(Visitor $visitor, Generator $generator, $data)
27 {
28 $contentInfo = $data->contentInfo;
29
30 $generator->startObjectElement('User');
31
32 $generator->startAttribute(
33 'href',
34 $this->router->generate('ezpublish_rest_loadUser', ['userId' => $contentInfo->id])
35 );
36 $generator->endAttribute('href');
37
38 $generator->startAttribute('id', $contentInfo->id);
39 $generator->endAttribute('id');
40
41 $generator->startAttribute('remoteId', $contentInfo->remoteId);
42 $generator->endAttribute('remoteId');
43
44 $visitor->setHeader('Content-Type', $generator->getMediaType('User'));
45 $visitor->setHeader('Accept-Patch', $generator->getMediaType('UserUpdate'));
46
47 $generator->startObjectElement('ContentType');
48
49 $generator->startAttribute(
50 'href',
51 $this->router->generate('ezpublish_rest_loadContentType', ['contentTypeId' => $contentInfo->contentTypeId])
52 );
53 $generator->endAttribute('href');
54
55 $generator->endObjectElement('ContentType');
56
57 $generator->startValueElement('name', $contentInfo->name);
58 $generator->endValueElement('name');
59
60 $generator->startObjectElement('Versions', 'VersionList');
61 $generator->startAttribute(
62 'href',
63 $this->router->generate('ezpublish_rest_loadContentVersions', ['contentId' => $contentInfo->id])
64 );
65 $generator->endAttribute('href');
66 $generator->endObjectElement('Versions');
67
68 $generator->startObjectElement('Section');
69 $generator->startAttribute(
70 'href',
71 $this->router->generate('ezpublish_rest_loadSection', ['sectionId' => $contentInfo->sectionId])
72 );
73 $generator->endAttribute('href');
74 $generator->endObjectElement('Section');
75
76 $generator->startObjectElement('MainLocation', 'Location');
77 $generator->startAttribute(
78 'href',
79 $this->router->generate(
80 'ezpublish_rest_loadLocation',
81 ['locationPath' => trim($data->mainLocation->pathString, '/')]
82 )
83 );
84 $generator->endAttribute('href');
85 $generator->endObjectElement('MainLocation');
86
87 $generator->startObjectElement('Locations', 'LocationList');
88 $generator->startAttribute(
89 'href',
90 $this->router->generate('ezpublish_rest_loadLocationsForContent', ['contentId' => $contentInfo->id])
91 );
92 $generator->endAttribute('href');
93 $generator->endObjectElement('Locations');
94
95 $generator->startObjectElement('Groups', 'UserGroupRefList');
96 $generator->startAttribute(
97 'href',
98 $this->router->generate('ezpublish_rest_loadUserGroupsOfUser', ['userId' => $contentInfo->id])
99 );
100 $generator->endAttribute('href');
101 $generator->endObjectElement('Groups');
102
103 $generator->startObjectElement('Owner', 'User');
104 $generator->startAttribute(
105 'href',
106 $this->router->generate('ezpublish_rest_loadUser', ['userId' => $contentInfo->ownerId])
107 );
108 $generator->endAttribute('href');
109 $generator->endObjectElement('Owner');
110
111 $generator->startValueElement('publishDate', $contentInfo->publishedDate->format('c'));
112 $generator->endValueElement('publishDate');
113
114 $generator->startValueElement('lastModificationDate', $contentInfo->modificationDate->format('c'));
115 $generator->endValueElement('lastModificationDate');
116
117 $generator->startValueElement('mainLanguageCode', $contentInfo->mainLanguageCode);
118 $generator->endValueElement('mainLanguageCode');
119
120 $generator->startValueElement(
121 'alwaysAvailable',
122 $this->serializeBool($generator, $contentInfo->alwaysAvailable)
123 );
124 $generator->endValueElement('alwaysAvailable');
125
126 $visitor->visitValueObject(
127 new VersionValue(
128 $data->content,
129 $data->contentType,
130 $data->relations
131 )
132 );
133
134 $generator->startValueElement('login', $data->content->login);
135 $generator->endValueElement('login');
136
137 $generator->startValueElement('email', $data->content->email);
138 $generator->endValueElement('email');
139
140 $generator->startValueElement(
141 'enabled',
142 $this->serializeBool($generator, $data->content->enabled)
143 );
144 $generator->endValueElement('enabled');
145
146 $generator->startObjectElement('UserGroups', 'UserGroupList');
147 $generator->startAttribute(
148 'href',
149 $this->router->generate(
150 'ezpublish_rest_loadUserGroupsOfUser',
151 ['userId' => $contentInfo->id]
152 )
153 );
154 $generator->endAttribute('href');
155 $generator->endObjectElement('UserGroups');
156
157 $generator->startObjectElement('Roles', 'RoleAssignmentList');
158 $generator->startAttribute(
159 'href',
160 $this->router->generate(
161 'ezpublish_rest_loadRoleAssignmentsForUser',
162 [
163 'userId' => $contentInfo->id,
164 ]
165 )
166 );
167 $generator->endAttribute('href');
168 $generator->endObjectElement('Roles');
169
170 $generator->endObjectElement('User');
171 }
172 }
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\ValueObjectVisitor\serializeBool
serializeBool(Generator $generator, $boolValue)
Returns a string representation for the given $boolValue.
Definition: ValueObjectVisitor.php:67
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\visitValueObject
visitValueObject($data)
Visit struct returned by controllers.
Definition: Visitor.php:131
eZ\Publish\Core\REST\Common\Output\Visitor\setHeader
setHeader($name, $value)
Set HTTP response header.
Definition: Visitor.php:64
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\RestUser
RestUser value object visitor.
Definition: Output/ValueObjectVisitor/RestUser.php:18
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\RestUser\visit
visit(Visitor $visitor, Generator $generator, $data)
Visit struct returned by controllers.
Definition: Output/ValueObjectVisitor/RestUser.php:26
eZ\Publish\Core\REST\Server\Values\Version
Version view model.
Definition: Core/REST/Server/Values/Version.php:17
eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor
Definition: Common/Output/ValueObjectVisitor/ContentObjectStates.php:7
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor
Definition: Output/ValueObjectVisitor/BadRequestException.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.