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

Core/REST/Server/Output/ValueObjectVisitor/RelationList.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 use eZ\Publish\Core\REST\Server\Values\RestRelation as ValuesRestRelation;
13
17 class RelationList extends ValueObjectVisitor
18 {
26 public function visit(Visitor $visitor, Generator $generator, $data)
27 {
28 $generator->startObjectElement('Relations', 'RelationList');
29 $visitor->setHeader('Content-Type', $generator->getMediaType('RelationList'));
30
31 $path = $data->path;
32 if ($path === null) {
33 $path = $this->router->generate(
34 'ezpublish_rest_loadVersionRelations',
35 [
36 'contentId' => $data->contentId,
37 'versionNumber' => $data->versionNo,
38 ]
39 );
40 }
41
42 $generator->startAttribute('href', $path);
43 $generator->endAttribute('href');
44
45 $generator->startList('Relation');
46 foreach ($data->relations as $relation) {
47 $visitor->visitValueObject(new ValuesRestRelation($relation, $data->contentId, $data->versionNo));
48 }
49 $generator->endList('Relation');
50
51 $generator->endObjectElement('Relations');
52 }
53 }
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\RelationList
RelationList value object visitor.
Definition: Core/REST/Server/Output/ValueObjectVisitor/RelationList.php:18
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\RelationList\visit
visit(Visitor $visitor, Generator $generator, $data)
Visit struct returned by controllers.
Definition: Core/REST/Server/Output/ValueObjectVisitor/RelationList.php:26
eZ\Publish\Core\REST\Server\Values\RestRelation
RestRelation view model.
Definition: Values/RestRelation.php:16
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+.