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

Output/ValueObjectVisitor/CountryList.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 CountryList extends ValueObjectVisitor
17 {
25 public function visit(Visitor $visitor, Generator $generator, $data)
26 {
27 $generator->startObjectElement('CountryList');
28 $visitor->setHeader('Content-Type', $generator->getMediaType('CountryList'));
29 $visitor->setHeader('Accept-Patch', false);
30
31 $generator->startList('Country');
32
33 foreach ($data->countries as $country) {
34 $generator->startObjectElement('Country', 'Country');
35
36 $generator->startAttribute('id', $country['Alpha2']);
37 $generator->endAttribute('id');
38
39 $generator->startValueElement('name', $country['Name']);
40 $generator->endValueElement('name');
41
42 $generator->startValueElement('Alpha2', $country['Alpha2']);
43 $generator->endValueElement('Alpha2');
44
45 $generator->startValueElement('Alpha3', $country['Alpha3']);
46 $generator->endValueElement('Alpha3');
47
48 $generator->startValueElement('IDC', $country['IDC']);
49 $generator->endValueElement('IDC');
50
51 $generator->endObjectElement('Country');
52 }
53 $generator->endList('Country');
54 $generator->endObjectElement('CountryList');
55 }
56 }
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\CountryList
CountryList value object visitor.
Definition: Output/ValueObjectVisitor/CountryList.php:17
eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor\CountryList\visit
visit(Visitor $visitor, Generator $generator, $data)
Visit struct returned by controllers.
Definition: Output/ValueObjectVisitor/CountryList.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+.