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

Server/Output/ValueObjectVisitor/ContentTypeGroupRefList.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 ContentTypeGroupRefList extends ValueObjectVisitor
17 {
25 public function visit(Visitor $visitor, Generator $generator, $data)
26 {
27 $generator->startObjectElement('ContentTypeGroupRefList');
28 $visitor->setHeader('Content-Type', $generator->getMediaType('ContentTypeGroupRefList'));
29
30 $generator->startAttribute(
31 'href',
32 $this->router->generate(
33 'ezpublish_rest_listContentTypesForGroup',
34 [
35 'contentTypeGroupId' => $data->contentType->id,
36 ]
37 )
38 );
39 $generator->endAttribute('href');
40
41 $groupCount = count($data->contentTypeGroups);
42
43 $generator->startList('ContentTypeGroupRef');
44 foreach ($data->contentTypeGroups as $contentTypeGroup) {
45 $generator->startObjectElement('ContentTypeGroupRef', 'ContentTypeGroup');
46
47 $generator->startAttribute(
48 'href',
49 $this->router->generate(
50 'ezpublish_rest_loadContentTypeGroup',
51 [
52 'contentTypeGroupId' => $contentTypeGroup->id,
53 ]
54 )
55 );
56 $generator->endAttribute('href');
57
58 // Unlinking last group is not allowed
59 if ($groupCount > 1) {
60 $generator->startHashElement('unlink');
61
62 $generator->startAttribute(
63 'href',
64 $this->router->generate(
65 'ezpublish_rest_unlinkContentTypeFromGroup',
66 [
67 'contentTypeId' => $data->contentType->id,
68 'contentTypeGroupId' => $contentTypeGroup->id,
69 ]
70 )
71 );
72 $generator->endAttribute('href');
73
74 $generator->startAttribute('method', 'DELETE');
75 $generator->endAttribute('method');
76
77 $generator->endHashElement('unlink');
78 }
79
80 $generator->endObjectElement('ContentTypeGroupRef');
81 }
82 $generator->endList('ContentTypeGroupRef');
83
84 $generator->endObjectElement('ContentTypeGroupRefList');
85 }
86 }
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\setHeader
setHeader($name, $value)
Set HTTP response header.
Definition: Visitor.php:64
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\ContentTypeGroupRefList
ContentTypeGroupRefList value object visitor.
Definition: Server/Output/ValueObjectVisitor/ContentTypeGroupRefList.php:17
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\ContentTypeGroupRefList\visit
visit(Visitor $visitor, Generator $generator, $data)
Visit struct returned by controllers.
Definition: Server/Output/ValueObjectVisitor/ContentTypeGroupRefList.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+.