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

Core/REST/Server/Output/ValueObjectVisitor/BookmarkList.php
Go to the documentation of this file.
1 <?php
2
7 declare(strict_types=1);
8
9 namespace eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor;
10
11 use eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor;
12 use eZ\Publish\Core\REST\Common\Output\Generator;
13 use eZ\Publish\Core\REST\Common\Output\Visitor;
14 use eZ\Publish\Core\REST\Server\Values\BookmarkList as BookmarkListValue;
15
16 class BookmarkList extends ValueObjectVisitor
17 {
21 public function visit(Visitor $visitor, Generator $generator, $data)
22 {
23 $generator->startObjectElement('BookmarkList');
24 $visitor->setHeader('Content-Type', $generator->getMediaType('BookmarkList'));
25
26 $this->visitAttributes($visitor, $generator, $data);
27 $generator->endObjectElement('BookmarkList');
28 }
29
30 protected function visitAttributes(Visitor $visitor, Generator $generator, BookmarkListValue $data): void
31 {
32 $generator->startValueElement('count', $data->totalCount);
33 $generator->endValueElement('count');
34
35 $generator->startList('items');
36 foreach ($data->items as $restLocation) {
37 $generator->startObjectElement('Bookmark');
38
39 $generator->startAttribute('_href', $this->router->generate('ezpublish_rest_isBookmarked', [
40 'locationId' => $restLocation->location->id,
41 ]));
42 $generator->endAttribute('_href');
43
44 $visitor->visitValueObject($restLocation);
45 $generator->endObjectElement('Bookmark');
46 }
47
48 $generator->endList('items');
49 }
50 }
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\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\BookmarkList
Definition: Core/REST/Server/Output/ValueObjectVisitor/BookmarkList.php:17
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\BookmarkList\visitAttributes
visitAttributes(Visitor $visitor, Generator $generator, BookmarkListValue $data)
Definition: Core/REST/Server/Output/ValueObjectVisitor/BookmarkList.php:30
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\BookmarkList\visit
visit(Visitor $visitor, Generator $generator, $data)
{Visit struct returned by controllers.}
Definition: Core/REST/Server/Output/ValueObjectVisitor/BookmarkList.php:21
eZ\Publish\Core\REST\Server\Values\BookmarkList
Definition: Core/REST/Server/Values/BookmarkList.php:14
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+.