本文整理汇总了PHP中eZ\Publish\Core\REST\Common\Output\Generator::endList方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::endList方法的具体用法?PHP Generator::endList怎么用?PHP Generator::endList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\REST\Common\Output\Generator
的用法示例。
在下文中一共展示了Generator::endList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: visit
/**
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param mixed $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentList'));
if (empty($data->contents)) {
$visitor->setStatus(204);
return;
}
$generator->startObjectElement('contentList');
$generator->startList('content');
foreach ($data->contents as $content) {
$generator->startObjectElement('content');
$generator->startValueElement('contentId', $content['contentId']);
$generator->endValueElement('contentId');
$generator->startValueElement('contentTypeId', $content['contentTypeId']);
$generator->endValueElement('contentTypeId');
$generator->startValueElement('identifier', $content['identifier']);
$generator->endValueElement('identifier');
$generator->startValueElement('language', $content['language']);
$generator->endValueElement('language');
$generator->startValueElement('publishedDate', $content['publishedDate']);
$generator->endValueElement('publishedDate');
$generator->startValueElement('author', $content['author']);
$generator->endValueElement('author');
$generator->startValueElement('uri', $content['uri']);
$generator->endValueElement('uri');
$generator->startValueElement('categoryPath', $content['categoryPath']);
$generator->endValueElement('categoryPath');
$generator->startObjectElement('mainLocation');
$generator->startAttribute('href', $content['mainLocation']['href']);
$generator->endAttribute('href');
$generator->endObjectElement('mainLocation');
$generator->startObjectElement('locations');
$generator->startAttribute('href', $content['locations']['href']);
$generator->endAttribute('href');
$generator->endObjectElement('locations');
$generator->startList('fields');
foreach ($content['fields'] as $field) {
$generator->startHashElement('fields');
$generator->startValueElement('key', $field['key']);
$generator->endValueElement('key');
$generator->startValueElement('value', $field['value']);
$generator->endValueElement('value');
$generator->endHashElement('fields');
}
$generator->endList('fields');
$generator->endObjectElement('content');
}
$generator->endList('content');
$generator->endObjectElement('contentList');
}
示例2: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Exceptions\ContentFieldValidationException $data
*/
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');
$generator->startValueElement('errorDescription', $data->getMessage());
$generator->endValueElement('errorDescription');
$generator->startHashElement('errorDetails');
$generator->startList('fields');
foreach ($data->getFieldErrors() as $fieldTypeId => $translations) {
foreach ($translations as $languageCode => $validationErrors) {
if (!is_array($validationErrors)) {
$validationErrors = [$validationErrors];
}
foreach ($validationErrors as $validationError) {
$generator->startHashElement('field');
$generator->startAttribute('fieldTypeId', $fieldTypeId);
$generator->endAttribute('fieldTypeId');
$generator->startList('errors');
$generator->startHashElement('error');
$generator->startValueElement('type', $validationError->getTarget());
$generator->endValueElement('type');
$translation = $validationError->getTranslatableMessage();
$generator->startValueElement('message', $this->translator->trans($this->translationToString($translation), $translation->values, 'repository_exceptions'));
$generator->endValueElement('message');
$generator->endHashElement('error');
$generator->endList('errors');
$generator->endHashElement('field');
}
}
}
$generator->endList('fields');
$generator->endHashElement('errorDetails');
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');
}
$generator->endObjectElement('ErrorMessage');
}
示例3: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\UserGroupRefList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('UserGroupRefList');
$visitor->setHeader('Content-Type', $generator->getMediaType('UserGroupRefList'));
//@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');
$groupCount = count($data->userGroups);
$generator->startList('UserGroup');
foreach ($data->userGroups as $userGroup) {
$generator->startObjectElement('UserGroup');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadUserGroup', array('groupPath' => trim($userGroup->mainLocation->pathString, '/'))));
$generator->endAttribute('href');
if ($data->userId !== null && $groupCount > 1) {
$generator->startHashElement('unassign');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_unassignUserFromUserGroup', array('userId' => $data->userId, 'groupPath' => $userGroup->mainLocation->path[count($userGroup->mainLocation->path) - 1])));
$generator->endAttribute('href');
$generator->startAttribute('method', 'DELETE');
$generator->endAttribute('method');
$generator->endHashElement('unassign');
}
$generator->endObjectElement('UserGroup');
}
$generator->endList('UserGroup');
$generator->endObjectElement('UserGroupRefList');
}
示例4: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\ContentTypeGroupRefList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ContentTypeGroupRefList');
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentTypeGroupRefList'));
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_listContentTypesForGroup', array('contentTypeGroupId' => $data->contentType->id)));
$generator->endAttribute('href');
$groupCount = count($data->contentTypeGroups);
$generator->startList('ContentTypeGroupRef');
foreach ($data->contentTypeGroups as $contentTypeGroup) {
$generator->startObjectElement('ContentTypeGroupRef', 'ContentTypeGroup');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadContentTypeGroup', array('contentTypeGroupId' => $contentTypeGroup->id)));
$generator->endAttribute('href');
// Unlinking last group is not allowed
if ($groupCount > 1) {
$generator->startHashElement('unlink');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_unlinkContentTypeFromGroup', array('contentTypeId' => $data->contentType->id, 'contentTypeGroupId' => $contentTypeGroup->id)));
$generator->endAttribute('href');
$generator->startAttribute('method', 'DELETE');
$generator->endAttribute('method');
$generator->endHashElement('unlink');
}
$generator->endObjectElement('ContentTypeGroupRef');
}
$generator->endList('ContentTypeGroupRef');
$generator->endObjectElement('ContentTypeGroupRefList');
}
示例5: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param mixed $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ObjectStateCreate');
$visitor->setHeader('Content-Type', $generator->getMediaType('ObjectStateCreate'));
$generator->startValueElement('identifier', $data->identifier);
$generator->endValueElement('identifier');
$generator->startValueElement('priority', $data->priority);
$generator->endValueElement('priority');
$generator->startValueElement('defaultLanguageCode', $data->defaultLanguageCode);
$generator->endValueElement('defaultLanguageCode');
$generator->startHashElement('names');
$generator->startList('value');
foreach ($data->names as $languageCode => $name) {
$generator->startValueElement('value', $name, array('languageCode' => $languageCode));
$generator->endValueElement('value');
}
$generator->endList('value');
$generator->endHashElement('names');
$generator->startHashElement('descriptions');
foreach ($data->descriptions as $languageCode => $description) {
$generator->startValueElement('value', $description, array('languageCode' => $languageCode));
$generator->endValueElement('value');
}
$generator->endHashElement('descriptions');
$generator->endObjectElement('ObjectStateCreate');
}
示例6: generateElement
/**
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param array $contentList
*
* @return Generator
*/
public function generateElement(Generator $generator, array $contentList = [])
{
$generator->startObjectElement('contentList');
$generator->startList('content');
foreach ($contentList as $content) {
$generator->startObjectElement('content');
$generator->startValueElement('contentId', $content['contentId']);
$generator->endValueElement('contentId');
$generator->startValueElement('contentTypeId', $content['contentTypeId']);
$generator->endValueElement('contentTypeId');
$generator->startValueElement('identifier', $content['identifier']);
$generator->endValueElement('identifier');
$generator->startValueElement('language', $content['language']);
$generator->endValueElement('language');
$generator->startValueElement('publishedDate', $content['publishedDate']);
$generator->endValueElement('publishedDate');
$generator->startValueElement('author', $content['author']);
$generator->endValueElement('author');
$generator->startValueElement('uri', $content['uri']);
$generator->endValueElement('uri');
$generator->startValueElement('categoryPath', $content['categoryPath']);
$generator->endValueElement('categoryPath');
$generator->startObjectElement('mainLocation');
$generator->startAttribute('href', $content['mainLocation']['href']);
$generator->endAttribute('href');
$generator->endObjectElement('mainLocation');
$generator->startObjectElement('locations');
$generator->startAttribute('href', $content['locations']['href']);
$generator->endAttribute('href');
$generator->endObjectElement('locations');
$generator->startList('fields');
foreach ($content['fields'] as $field) {
$generator->startHashElement('fields');
$generator->startValueElement('key', $field['key']);
$generator->endValueElement('key');
$generator->startValueElement('value', $field['value']);
$generator->endValueElement('value');
$generator->endHashElement('fields');
}
$generator->endList('fields');
$generator->endObjectElement('content');
}
$generator->endList('content');
$generator->endObjectElement('contentList');
return $generator;
}
示例7: visit
/**
* @param Visitor $visitor
* @param Generator $generator
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$contentTypeIdentifiers = is_array($data->value) ? $data->value : [$data->value];
$generator->startList('ContentTypeIdentifierCriterion');
foreach ($contentTypeIdentifiers as $contentTypeIdentifier) {
$generator->startValueElement('ContentTypeIdentifierCriterion', $contentTypeIdentifier);
$generator->endValueElement('ContentTypeIdentifierCriterion');
}
$generator->endList('ContentTypeIdentifierCriterion');
}
示例8: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\Trash $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('Trash');
$visitor->setHeader('Content-Type', $generator->getMediaType('Trash'));
$generator->startAttribute('href', $data->path);
$generator->endAttribute('href');
$generator->startList('TrashItem');
foreach ($data->trashItems as $trashItem) {
$visitor->visitValueObject($trashItem);
}
$generator->endList('TrashItem');
$generator->endObjectElement('Trash');
}
示例9: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\URLAliasList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('UrlAliasList');
$visitor->setHeader('Content-Type', $generator->getMediaType('UrlAliasList'));
$generator->startAttribute('href', $data->path);
$generator->endAttribute('href');
$generator->startList('UrlAlias');
foreach ($data->urlAliases as $urlAlias) {
$visitor->visitValueObject($urlAlias);
}
$generator->endList('UrlAlias');
$generator->endObjectElement('UrlAliasList');
}
示例10: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\URLWildcardList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('UrlWildcardList');
$visitor->setHeader('Content-Type', $generator->getMediaType('UrlWildcardList'));
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_listURLWildcards'));
$generator->endAttribute('href');
$generator->startList('UrlWildcard');
foreach ($data->urlWildcards as $urlWildcard) {
$visitor->visitValueObject($urlWildcard);
}
$generator->endList('UrlWildcard');
$generator->endObjectElement('UrlWildcardList');
}
示例11: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\RoleAssignmentList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('RoleAssignmentList');
$visitor->setHeader('Content-Type', $generator->getMediaType('RoleAssignmentList'));
$generator->startAttribute('href', $data->isGroupAssignment ? $this->router->generate('ezpublish_rest_loadRoleAssignmentsForUserGroup', array('groupPath' => $data->id)) : $this->router->generate('ezpublish_rest_loadRoleAssignmentsForUser', array('userId' => $data->id)));
$generator->endAttribute('href');
$generator->startList('RoleAssignment');
foreach ($data->roleAssignments as $roleAssignment) {
$visitor->visitValueObject($data->isGroupAssignment ? new Values\RestUserGroupRoleAssignment($roleAssignment, $data->id) : new Values\RestUserRoleAssignment($roleAssignment, $data->id));
}
$generator->endList('RoleAssignment');
$generator->endObjectElement('RoleAssignmentList');
}
示例12: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param mixed $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ContentObjectStates');
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentObjectStates'));
$generator->startList('ObjectState');
foreach ($data->states as $state) {
$generator->startObjectElement('ObjectState');
$generator->startAttribute('href', $this->requestParser->generate('objectstate', array('objectstategroup' => $state->groupId, 'objectstate' => $state->objectState->id)));
$generator->endAttribute('href');
$generator->endObjectElement('ObjectState');
}
$generator->endList('ObjectState');
$generator->endObjectElement('ContentObjectStates');
}
示例13: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\ObjectStateList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ObjectStateList');
$visitor->setHeader('Content-Type', $generator->getMediaType('ObjectStateList'));
//@todo Needs refactoring, disabling certain headers should not be done this way
$visitor->setHeader('Accept-Patch', false);
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadObjectStates', array('objectStateGroupId' => $data->groupId)));
$generator->endAttribute('href');
$generator->startList('ObjectState');
foreach ($data->states as $state) {
$visitor->visitValueObject(new RestObjectStateValue($state, $data->groupId));
}
$generator->endList('ObjectState');
$generator->endObjectElement('ObjectStateList');
}
示例14: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\ContentList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ContentList');
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentList'));
//@todo Needs refactoring, disabling certain headers should not be done this way
$visitor->setHeader('Accept-Patch', false);
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_redirectContent'));
$generator->endAttribute('href');
$generator->startList('ContentInfo');
foreach ($data->contents as $content) {
$visitor->visitValueObject($content);
}
$generator->endList('ContentInfo');
$generator->endObjectElement('ContentList');
}
示例15: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\ContentTypeInfoList $data
*/
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');
}