|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the RestTrashItem 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\Core\REST\Common\Output\ValueObjectVisitor; |
|
14
|
|
|
use eZ\Publish\Core\REST\Common\Output\Generator; |
|
15
|
|
|
use eZ\Publish\Core\REST\Common\Output\Visitor; |
|
16
|
|
|
use eZ\Publish\Core\REST\Server\Values\RestContent as RestContentValue; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* RestTrashItem value object visitor. |
|
20
|
|
|
*/ |
|
21
|
|
|
class RestTrashItem 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 \eZ\Publish\Core\REST\Server\Values\RestTrashItem $data |
|
29
|
|
|
*/ |
|
30
|
|
|
public function visit(Visitor $visitor, Generator $generator, $data) |
|
31
|
|
|
{ |
|
32
|
|
|
$generator->startObjectElement('TrashItem'); |
|
33
|
|
|
$visitor->setHeader('Content-Type', $generator->getMediaType('TrashItem')); |
|
34
|
|
|
|
|
35
|
|
|
$trashItem = $data->trashItem; |
|
36
|
|
|
$contentInfo = $trashItem->getContentInfo(); |
|
37
|
|
|
|
|
38
|
|
|
$generator->startAttribute( |
|
39
|
|
|
'href', |
|
40
|
|
|
$this->router->generate('ezpublish_rest_loadTrashItem', array('trashItemId' => $trashItem->id)) |
|
|
|
|
|
|
41
|
|
|
); |
|
42
|
|
|
$generator->endAttribute('href'); |
|
43
|
|
|
|
|
44
|
|
|
$generator->startValueElement('id', $trashItem->id); |
|
|
|
|
|
|
45
|
|
|
$generator->endValueElement('id'); |
|
46
|
|
|
|
|
47
|
|
|
$generator->startValueElement('priority', $trashItem->priority); |
|
|
|
|
|
|
48
|
|
|
$generator->endValueElement('priority'); |
|
49
|
|
|
|
|
50
|
|
|
$generator->startValueElement( |
|
51
|
|
|
'hidden', |
|
52
|
|
|
$this->serializeBool($generator, $trashItem->hidden) |
|
|
|
|
|
|
53
|
|
|
); |
|
54
|
|
|
$generator->endValueElement('hidden'); |
|
55
|
|
|
|
|
56
|
|
|
$generator->startValueElement( |
|
57
|
|
|
'invisible', |
|
58
|
|
|
$this->serializeBool($generator, $trashItem->invisible) |
|
|
|
|
|
|
59
|
|
|
); |
|
60
|
|
|
$generator->endValueElement('invisible'); |
|
61
|
|
|
|
|
62
|
|
|
$pathStringParts = explode('/', trim($trashItem->pathString, '/')); |
|
|
|
|
|
|
63
|
|
|
$pathStringParts = array_slice($pathStringParts, 0, count($pathStringParts) - 1); |
|
64
|
|
|
|
|
65
|
|
|
$generator->startObjectElement('ParentLocation', 'Location'); |
|
66
|
|
|
$generator->startAttribute( |
|
67
|
|
|
'href', |
|
68
|
|
|
$this->router->generate( |
|
69
|
|
|
'ezpublish_rest_loadLocation', |
|
70
|
|
|
array( |
|
71
|
|
|
'locationPath' => implode('/', $pathStringParts), |
|
72
|
|
|
) |
|
73
|
|
|
) |
|
74
|
|
|
); |
|
75
|
|
|
$generator->endAttribute('href'); |
|
76
|
|
|
$generator->endObjectElement('ParentLocation'); |
|
77
|
|
|
|
|
78
|
|
|
$generator->startValueElement('pathString', $trashItem->pathString); |
|
|
|
|
|
|
79
|
|
|
$generator->endValueElement('pathString'); |
|
80
|
|
|
|
|
81
|
|
|
$generator->startValueElement('depth', $trashItem->depth); |
|
|
|
|
|
|
82
|
|
|
$generator->endValueElement('depth'); |
|
83
|
|
|
|
|
84
|
|
|
$generator->startValueElement('childCount', $data->childCount); |
|
85
|
|
|
$generator->endValueElement('childCount'); |
|
86
|
|
|
|
|
87
|
|
|
$generator->startValueElement('remoteId', $trashItem->remoteId); |
|
|
|
|
|
|
88
|
|
|
$generator->endValueElement('remoteId'); |
|
89
|
|
|
|
|
90
|
|
|
$generator->startObjectElement('Content'); |
|
91
|
|
|
$generator->startAttribute( |
|
92
|
|
|
'href', |
|
93
|
|
|
$this->router->generate('ezpublish_rest_loadContent', array('contentId' => $contentInfo->id)) |
|
94
|
|
|
); |
|
95
|
|
|
$generator->endAttribute('href'); |
|
96
|
|
|
$generator->endObjectElement('Content'); |
|
97
|
|
|
|
|
98
|
|
|
$generator->startValueElement('sortField', $this->serializeSortField($trashItem->sortField)); |
|
|
|
|
|
|
99
|
|
|
$generator->endValueElement('sortField'); |
|
100
|
|
|
|
|
101
|
|
|
$generator->startValueElement('sortOrder', $this->serializeSortOrder($trashItem->sortOrder)); |
|
|
|
|
|
|
102
|
|
|
$generator->endValueElement('sortOrder'); |
|
103
|
|
|
|
|
104
|
|
|
$generator->startObjectElement('ContentInfo', 'ContentInfo'); |
|
105
|
|
|
$generator->startAttribute( |
|
106
|
|
|
'href', |
|
107
|
|
|
$this->router->generate( |
|
108
|
|
|
'ezpublish_rest_loadContent', |
|
109
|
|
|
array('contentId' => $contentInfo->id) |
|
110
|
|
|
) |
|
111
|
|
|
); |
|
112
|
|
|
$generator->endAttribute('href'); |
|
113
|
|
|
$visitor->visitValueObject(new RestContentValue($contentInfo)); |
|
114
|
|
|
$generator->endObjectElement('ContentInfo'); |
|
115
|
|
|
|
|
116
|
|
|
$generator->endObjectElement('TrashItem'); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.