1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the Role ValueObjectVisitor class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
* |
9
|
|
|
* @version //autogentag// |
10
|
|
|
*/ |
11
|
|
|
namespace eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor; |
12
|
|
|
|
13
|
|
|
use eZ\Publish\API\Repository\Values\User\RoleDraft; |
14
|
|
|
use eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor; |
15
|
|
|
use eZ\Publish\Core\REST\Common\Output\Generator; |
16
|
|
|
use eZ\Publish\Core\REST\Common\Output\Visitor; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Role value object visitor. |
20
|
|
|
*/ |
21
|
|
|
class Role extends ValueObjectVisitor |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Visit struct returned by controllers. |
25
|
|
|
* |
26
|
|
|
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor |
27
|
|
|
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator |
28
|
|
|
* @param Role|RoleDraft $data |
29
|
|
|
*/ |
30
|
|
|
public function visit(Visitor $visitor, Generator $generator, $data) |
31
|
|
|
{ |
32
|
|
|
$generator->startObjectElement('Role'); |
33
|
|
|
$visitor->setHeader('Content-Type', $generator->getMediaType($data instanceof RoleDraft ? 'RoleDraft' : 'Role')); |
34
|
|
|
$visitor->setHeader('Accept-Patch', $generator->getMediaType('RoleInput')); |
35
|
|
|
|
36
|
|
|
$generator->startAttribute( |
37
|
|
|
'href', |
38
|
|
|
$this->router->generate('ezpublish_rest_loadRole', array('roleId' => $data->id)) |
39
|
|
|
); |
40
|
|
|
$generator->endAttribute('href'); |
41
|
|
|
|
42
|
|
|
$generator->startValueElement('identifier', $data->identifier); |
43
|
|
|
$generator->endValueElement('identifier'); |
44
|
|
|
|
45
|
|
|
$generator->startObjectElement('Policies', 'PolicyList'); |
46
|
|
|
$generator->startAttribute( |
47
|
|
|
'href', |
48
|
|
|
$this->router->generate('ezpublish_rest_loadPolicies', array('roleId' => $data->id)) |
49
|
|
|
); |
50
|
|
|
$generator->endAttribute('href'); |
51
|
|
|
$generator->endObjectElement('Policies'); |
52
|
|
|
|
53
|
|
|
$generator->endObjectElement('Role'); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|