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

Output/ValueObjectVisitor/VersionList.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\Core\REST\Common\Output\ValueObjectVisitor;
10 use eZ\Publish\Core\REST\Common\Output\Generator;
11 use eZ\Publish\Core\REST\Common\Output\Visitor;
12
16 class VersionList extends ValueObjectVisitor
17 {
25 public function visit(Visitor $visitor, Generator $generator, $data)
26 {
27 $generator->startObjectElement('VersionList');
28 $visitor->setHeader('Content-Type', $generator->getMediaType('VersionList'));
29 //@todo Needs refactoring, disabling certain headers should not be done this way
30 $visitor->setHeader('Accept-Patch', false);
31
32 $generator->startAttribute('href', $data->path);
33 $generator->endAttribute('href');
34
35 $generator->startList('VersionItem');
36 foreach ($data->versions as $version) {
37 $generator->startHashElement('VersionItem');
38
39 $generator->startObjectElement('Version');
40 $generator->startAttribute(
41 'href',
42 $this->router->generate(
43 'ezpublish_rest_loadContentInVersion',
44 [
45 'contentId' => $version->getContentInfo()->id,
46 'versionNumber' => $version->versionNo,
47 ]
48 )
49 );
50 $generator->endAttribute('href');
51 $generator->endObjectElement('Version');
52
53 $visitor->visitValueObject($version);
54
55 $generator->endHashElement('VersionItem');
56 }
57 $generator->endList('VersionItem');
58
59 $generator->endObjectElement('VersionList');
60 }
61 }
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\VersionList
VersionList value object visitor.
Definition: Output/ValueObjectVisitor/VersionList.php:17
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\VersionList\visit
visit(Visitor $visitor, Generator $generator, $data)
Visit struct returned by controllers.
Definition: Output/ValueObjectVisitor/VersionList.php:25
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+.