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

Core/REST/Server/Output/ValueObjectVisitor/Policy.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\PolicyDraft;
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 use eZ\Publish\API\Repository\Values\User\Policy as PolicyValue;
14
18 class Policy extends ValueObjectVisitor
19 {
27 public function visit(Visitor $visitor, Generator $generator, $data)
28 {
29 $generator->startObjectElement('Policy');
30 $visitor->setHeader('Content-Type', $generator->getMediaType($data instanceof PolicyDraft ? 'PolicyDraft' : 'Policy'));
31 $visitor->setHeader('Accept-Patch', $generator->getMediaType('PolicyUpdate'));
32 $this->visitPolicyAttributes($visitor, $generator, $data);
33 $generator->endObjectElement('Policy');
34 }
35
36 protected function visitPolicyAttributes(Visitor $visitor, Generator $generator, PolicyValue $data)
37 {
38 $generator->startAttribute(
39 'href',
40 $this->router->generate('ezpublish_rest_loadPolicy', ['roleId' => $data->roleId, 'policyId' => $data->id])
41 );
42 $generator->endAttribute('href');
43
44 $generator->startValueElement('id', $data->id);
45 $generator->endValueElement('id');
46
47 if ($data instanceof PolicyDraft) {
48 $generator->startValueElement('originalId', $data->originalId);
49 $generator->endValueElement('originalId');
50 }
51
52 $generator->startValueElement('module', $data->module);
53 $generator->endValueElement('module');
54
55 $generator->startValueElement('function', $data->function);
56 $generator->endValueElement('function');
57
58 $limitations = $data->getLimitations();
59 if (!empty($limitations)) {
60 $generator->startHashElement('limitations');
61 $generator->startList('limitation');
62
63 foreach ($limitations as $limitation) {
64 $this->visitLimitation($generator, $limitation);
65 }
66
67 $generator->endList('limitation');
68 $generator->endHashElement('limitations');
69 }
70 }
71 }
eZ\Publish\API\Repository\Values\User\PolicyDraft
Definition: API/Repository/Values/User/PolicyDraft.php:13
eZ\Publish\API\Repository\Values\User\Policy
Definition: API/Repository/Values/User/Policy.php:21
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\visitLimitation
visitLimitation(Generator $generator, Limitation $limitation)
Visits a limitation.
Definition: ValueObjectVisitor.php:119
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\Policy
Policy value object visitor.
Definition: Core/REST/Server/Output/ValueObjectVisitor/Policy.php:19
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\Policy\visit
visit(Visitor $visitor, Generator $generator, $data)
Visit struct returned by controllers.
Definition: Core/REST/Server/Output/ValueObjectVisitor/Policy.php:27
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\Policy\visitPolicyAttributes
visitPolicyAttributes(Visitor $visitor, Generator $generator, PolicyValue $data)
Definition: Core/REST/Server/Output/ValueObjectVisitor/Policy.php:36
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+.