Visit struct returned by controllers.

@param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
@param \eZ\Publish\Core\REST\Common\Output\Generator $generator
@param \Exception $data
183181
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('ErrorMessage');

        $statusCode = $this->getStatus();
        $visitor->setStatus($statusCode);
        $visitor->setHeader('Content-Type', $generator->getMediaType('ErrorMessage'));

        $generator->startValueElement('errorCode', $statusCode);
        $generator->endValueElement('errorCode');

        $generator->startValueElement('errorMessage', $this->httpStatusCodes[$statusCode]);
        $generator->endValueElement('errorMessage');

        if ($data instanceof Translatable && $this->translator) {
            /** @Ignore */
            $errorDescription = $this->translator->trans($data->getMessageTemplate(), $data->getParameters(), 'repository_exceptions');
        } else {
            $errorDescription = $data->getMessage();
        }
        $generator->startValueElement('errorDescription', $errorDescription);
        $generator->endValueElement('errorDescription');

        if ($this->debug) {
            $generator->startValueElement('trace', $data->getTraceAsString());
            $generator->endValueElement('trace');

            $generator->startValueElement('file', $data->getFile());
            $generator->endValueElement('file');

            $generator->startValueElement('line', $data->getLine());
            $generator->endValueElement('line');
        }

        if ($previous = $data->getPrevious()) {
            $generator->startObjectElement('Previous', 'ErrorMessage');
            $visitor->visitValueObject($previous);
            $generator->endObjectElement('Previous');
        }

        $generator->endObjectElement('ErrorMessage');
    }
1025534
public function deserializeDateTimeFromJson(JsonDeserializationVisitor $visitor, $data, array $type)
    {
        if (null === $data) {
            return null;
        }

        return parent::deserializeDateTimeFromJson(
            $visitor,
            $this->dateConverter->getDateTimeStringInFormat($data),
            $type
        );
    }
962441
public function record(Visitor $visitor, $idReferrerActionUrl, $idReferrerActionName)
    {
        $this->loadIdsFromLogActionTable();

        $visitAction = array(
            'idvisit'           => $visitor->getVisitorColumn('idvisit'),
            'idsite'            => $this->request->getIdSite(),
            'idvisitor'         => $visitor->getVisitorColumn('idvisitor'),
            'idaction_url'      => $this->getIdActionUrl(),
            'idaction_url_ref'  => $idReferrerActionUrl,
            'idaction_name_ref' => $idReferrerActionName
        );

        /** @var ActionDimension[] $dimensions */
        $dimensions = ActionDimension::getAllDimensions();

        foreach ($dimensions as $dimension) {
            $value = $dimension->onNewAction($this->request, $visitor, $this);

            if ($value !== false) {
                if (is_float($value)) {
                    $value = Common::forceDotAsSeparatorForDecimalPoint($value);
                }

                $visitAction[$dimension->getColumnName()] = $value;
            }
        }

        // idaction_name is NULLable. we only set it when applicable
        if ($this->isActionHasActionName()) {
            $visitAction['idaction_name'] = (int)$this->getIdActionName();
        }

        foreach ($this->actionIdsCached as $field => $idAction) {
            $visitAction[$field] = ($idAction === false) ? 0 : $idAction;
        }

        $customValue = $this->getCustomFloatValue();
        if ($customValue !== false && $customValue !== null && $customValue !== '') {
            $visitAction[self::DB_COLUMN_CUSTOM_FLOAT] = Common::forceDotAsSeparatorForDecimalPoint($customValue);
        }

        $visitAction = array_merge($visitAction, $this->customFields);

        $this->idLinkVisitAction = $this->getModel()->createAction($visitAction);

        $visitAction['idlink_va'] = $this->idLinkVisitAction;

        Common::printDebug("Inserted new action:");
        $visitActionDebug = $visitAction;
        $visitActionDebug['idvisitor'] = bin2hex($visitActionDebug['idvisitor']);
        Common::printDebug($visitActionDebug);
    }
1343662
public function accept(Visitor $visitor)
    {
        foreach ($this as $attribute => $value) {
            foreach ($this->isTraversable($value) ? $value : [$value] as $element) {
                if ($element instanceof Visitee) {
                    $element->accept($visitor);
                }
            }
        }

        /** @noinspection PhpParamsInspection */
        $visitor->visit($this);
    }
686237
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('CountryList');
        $visitor->setHeader('Content-Type', $generator->getMediaType('CountryList'));
        $visitor->setHeader('Accept-Patch', false);

        $generator->startList('Country');

        foreach ($data->countries as $country) {
            $generator->startObjectElement('Country', 'Country');

            $generator->startAttribute('id', $country['Alpha2']);
            $generator->endAttribute('id');

            $generator->startValueElement('name', $country['Name']);
            $generator->endValueElement('name');

            $generator->startValueElement('Alpha2', $country['Alpha2']);
            $generator->endValueElement('Alpha2');

            $generator->startValueElement('Alpha3', $country['Alpha3']);
            $generator->endValueElement('Alpha3');

            $generator->startValueElement('IDC', $country['IDC']);
            $generator->endValueElement('IDC');

            $generator->endObjectElement('Country');
        }
        $generator->endList('Country');
        $generator->endObjectElement('CountryList');
    }
1352029
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('Tag');
        $visitor->setHeader('Content-Type', $generator->getMediaType('Tag'));
        $visitor->setHeader('Accept-Patch', $generator->getMediaType('TagUpdate'));

        $tag = $data->tag;

        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_eztags_loadTag',
                ['tagPath' => trim($tag->pathString, '/')]
            )
        );
        $generator->endAttribute('href');

        $generator->startValueElement('id', $tag->id);
        $generator->endValueElement('id');

        $tagPath = explode('/', trim($tag->pathString, '/'));
        $parentPathString = implode('/', array_slice($tagPath, 0, count($tagPath) - 1));

        if (!empty($tag->parentTagId)) {
            $generator->startObjectElement('ParentTag', 'Tag');
            $generator->startAttribute(
                'href',
                $this->router->generate(
                    'ezpublish_rest_eztags_loadTag',
                    [
                        'tagPath' => $parentPathString,
                    ]
                )
            );
            $generator->endAttribute('href');
            $generator->endObjectElement('ParentTag');
        }

        if (!empty($tag->mainTagId)) {
            $generator->startObjectElement('MainTag', 'Tag');
            $generator->startAttribute(
                'href',
                $this->router->generate(
                    'ezpublish_rest_eztags_loadTag',
                    [
                        // Main tags always have a same parent tag ID
                        'tagPath' => $parentPathString . '/' . $tag->mainTagId,
                    ]
                )
            );
            $generator->endAttribute('href');
            $generator->endObjectElement('MainTag');
        }

        $this->visitTranslatedList($generator, $tag->keywords, 'keywords');

        $generator->startValueElement('depth', $tag->depth);
        $generator->endValueElement('depth');

        $generator->startValueElement('pathString', $tag->pathString);
        $generator->endValueElement('pathString');

        $generator->startValueElement(
            'modificationDate',
            $tag->modificationDate->format('c')
        );
        $generator->endValueElement('modificationDate');

        $generator->startValueElement('remoteId', $tag->remoteId);
        $generator->endValueElement('remoteId');

        $generator->startValueElement(
            'alwaysAvailable',
            $this->serializeBool($generator, $tag->alwaysAvailable)
        );
        $generator->endValueElement('alwaysAvailable');

        $generator->startValueElement('mainLanguageCode', $tag->mainLanguageCode);
        $generator->endValueElement('mainLanguageCode');

        $generator->startValueElement(
            'languageCodes',
            implode(',', $tag->languageCodes)
        );
        $generator->endValueElement('languageCodes');

        if (empty($tag->mainTagId)) {
            $generator->startValueElement('childrenCount', $data->childrenCount);
            $generator->endValueElement('childrenCount');

            $generator->startObjectElement('Children', 'TagList');
            $generator->startAttribute(
                'href',
                $this->router->generate(
                    'ezpublish_rest_eztags_loadTagChildren',
                    [
                        'tagPath' => trim($tag->pathString, '/'),
                    ]
                )
            );
            $generator->endAttribute('href');
            $generator->endObjectElement('Children');

            $generator->startValueElement('synonymsCount', $data->synonymsCount);
            $generator->endValueElement('synonymsCount');

            $generator->startObjectElement('Synonyms', 'TagList');
            $generator->startAttribute(
                'href',
                $this->router->generate(
                    'ezpublish_rest_eztags_loadTagSynonyms',
                    ['tagPath' => trim($tag->pathString, '/')]
                )
            );
            $generator->endAttribute('href');
            $generator->endObjectElement('Synonyms');
        }

        $generator->startObjectElement('RelatedContent', 'ContentList');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_eztags_getRelatedContent',
                [
                    'tagPath' => trim($tag->pathString, '/'),
                ]
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('RelatedContent');

        $generator->endObjectElement('Tag');
    }
746250
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('ContentTypeInfoList');
        $visitor->setHeader('Content-Type', $generator->getMediaType('ContentTypeInfoList'));
        //@todo Needs refactoring, disabling certain headers should not be done this way
        $visitor->setHeader('Accept-Patch', false);

        $generator->startAttribute('href', $data->path);
        $generator->endAttribute('href');

        $generator->startList('ContentType');
        foreach ($data->contentTypes as $contentType) {
            $visitor->visitValueObject(
                new Values\RestContentType($contentType)
            );
        }
        $generator->endList('ContentType');

        $generator->endObjectElement('ContentTypeInfoList');
    }
123946
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $restFieldDefinition = $data->fieldDefinition;

        parent::visit($visitor, $generator, $restFieldDefinition);

        $draftUriPart = $this->getUrlTypeSuffix($restFieldDefinition->contentType->status);
        $visitor->setHeader(
            'Location',
            $this->router->generate(
                "ezpublish_rest_loadContentType{$draftUriPart}FieldDefinition",
                array(
                    'contentTypeId' => $restFieldDefinition->contentType->id,
                    'fieldDefinitionId' => $restFieldDefinition->fieldDefinition->id,
                )
            )
        );
        $visitor->setStatus(201);
    }
1226021
public function create(array $visitorRawData = array())
    {
        $visitor = null;

        /**
         * Triggered while visit is filtering in live plugin. Subscribers to this
         * event can force the use of a custom visitor object that extends from
         * {@link Piwik\Plugins\Live\VisitorInterface}.
         *
         * @param \Piwik\Plugins\Live\VisitorInterface &$visitor Initialized to null, but can be set to
         *                                              a new visitor object. If it isn't modified
         *                                              Piwik uses the default class.
         * @param array $visitorRawData Raw data using in Visitor object constructor.
         */
        Piwik::postEvent('Live.makeNewVisitorObject', array(&$visitor, $visitorRawData));

        if (is_null($visitor)) {
            $visitor = new Visitor($visitorRawData);
        } elseif (!($visitor instanceof VisitorInterface)) {
            throw new Exception("The Visitor object set in the plugin must implement VisitorInterface");
        }

        return $visitor;
    }
701057
public function init(GeneratorDataObject $generator, MetaDataInterface $metadata)
    {
        $generator = clone $generator;
        $phpParser = clone $this->phpStringParser;

        return $this->analyze($generator->getName(), $phpParser, $generator, $metadata, true);
    }
1167940
protected function visitTranslatedList(Generator $generator, array $translatedElements, $listName)
    {
        $generator->startHashElement($listName);
        $generator->startList('value');
        foreach ($translatedElements as $languageCode => $element) {
            $generator->startValueElement('value', $element, array('languageCode' => $languageCode));
            $generator->endValueElement('value');
        }
        $generator->endList('value');
        $generator->endHashElement($listName);
    }
1091556
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('RoleAssignInput');
        $visitor->setHeader('Content-Type', $generator->getMediaType('RoleAssignInput'));

        $generator->startObjectElement('Role');

        $generator->startAttribute(
            'href',
            $this->requestParser->generate('role', array('role' => $data->getRole()->id))
        );
        $generator->endAttribute('href');

        $generator->endObjectElement('Role');

        $roleLimitation = $data->getRoleLimitation();
        if ($roleLimitation !== null) {
            $visitor->visitValueObject($roleLimitation);
        }

        $generator->endObjectElement('RoleAssignInput');
    }
812898
private void initGenerator(ResourceGenerator generator) {

		initializeGeneratorProperties(generator);
		updateRegistries(generator);
		ResourceReader proxy = ResourceGeneratorReaderProxyFactory.getResourceReaderProxy(generator, rsHandler, config);
		rsHandler.addResourceReader(proxy);
	}
838002
private function visitCollections(Block $block, VisitorInterface $subVisitor): Generator
    {
        foreach ($block->getCollections() as $identifier => $collection) {
            yield $identifier => $subVisitor->visit($collection);
        }
    }
1246844
public static function getGeneratorElements(Generator $generator)
    {
        $elements = [];

        for (; $generator->valid(); $generator->next()) {
            $elements[] = $generator->current();
        }

        return $elements;
    }
759423
private function visit(GraphNavigatorInterface $navigator, VisitorInterface $visitor, Context $context, $data, string $format, ?string $type = null, bool $prepare = true)
    {
        $context->initialize(
            $format,
            $visitor,
            $navigator,
            $this->factory
        );

        $visitor->setNavigator($navigator);
        $navigator->initialize($visitor, $context);

        if ($prepare) {
            $data = $visitor->prepare($data);
        }

        if (null !== $type) {
            $type = $this->typeParser->parse($type);
        }
        return $navigator->accept($data, $type);
    }
835141
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        parent::visit($visitor, $generator, $data->restLocation);
        $visitor->setHeader(
            'Location',
            $this->router->generate(
                'ezpublish_rest_loadLocation',
                array('locationPath' => trim($data->restLocation->location->pathString, '/'))
            )
        );
        $visitor->setStatus(201);
    }