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

Core/REST/Server/Output/ValueObjectVisitor/Role.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\API\Repository\Values\User\RoleDraft;
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 Role extends ValueObjectVisitor
18 {
26 public function visit(Visitor $visitor, Generator $generator, $data)
27 {
28 $generator->startObjectElement('Role');
29 $visitor->setHeader('Content-Type', $generator->getMediaType($data instanceof RoleDraft ? 'RoleDraft' : 'Role'));
30 $visitor->setHeader('Accept-Patch', $generator->getMediaType('RoleInput'));
31 $this->visitRoleAttributes($visitor, $generator, $data);
32 $generator->endObjectElement('Role');
33 }
34
35 protected function visitRoleAttributes(Visitor $visitor, Generator $generator, $data)
36 {
37 $generator->startAttribute(
38 'href',
39 $this->router->generate('ezpublish_rest_loadRole', ['roleId' => $data->id])
40 );
41 $generator->endAttribute('href');
42
43 $generator->startValueElement('identifier', $data->identifier);
44 $generator->endValueElement('identifier');
45
46 $generator->startObjectElement('Policies', 'PolicyList');
47 $generator->startAttribute(
48 'href',
49 $this->router->generate('ezpublish_rest_loadPolicies', ['roleId' => $data->id])
50 );
51 $generator->endAttribute('href');
52 $generator->endObjectElement('Policies');
53 }
54 }
eZ\Publish\API\Repository\Values\User\RoleDraft
This class represents a draft of a role.
Definition: API/Repository/Values/User/RoleDraft.php:13
eZ\Publish\API\Repository\Values\User\Role
Definition: API/Repository/Values/User/Role.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\Server\Output\ValueObjectVisitor\Role\visitRoleAttributes
visitRoleAttributes(Visitor $visitor, Generator $generator, $data)
Definition: Core/REST/Server/Output/ValueObjectVisitor/Role.php:35
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\Role\visit
visit(Visitor $visitor, Generator $generator, $data)
Visit struct returned by controllers.
Definition: Core/REST/Server/Output/ValueObjectVisitor/Role.php:26
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+.