本文整理汇总了PHP中eZ\Publish\Core\REST\Common\Output\Generator::startList方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::startList方法的具体用法?PHP Generator::startList怎么用?PHP Generator::startList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\REST\Common\Output\Generator
的用法示例。
在下文中一共展示了Generator::startList方法的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\API\Repository\Values\User\Policy $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('Policy');
$visitor->setHeader('Content-Type', $generator->getMediaType('Policy'));
$visitor->setHeader('Accept-Patch', $generator->getMediaType('PolicyUpdate'));
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadPolicy', array('roleId' => $data->roleId, 'policyId' => $data->id)));
$generator->endAttribute('href');
$generator->startValueElement('id', $data->id);
$generator->endValueElement('id');
$generator->startValueElement('module', $data->module);
$generator->endValueElement('module');
$generator->startValueElement('function', $data->function);
$generator->endValueElement('function');
$limitations = $data->getLimitations();
if (!empty($limitations)) {
$generator->startHashElement('limitations');
$generator->startList('limitation');
foreach ($limitations as $limitation) {
$this->visitLimitation($generator, $limitation);
}
$generator->endList('limitation');
$generator->endHashElement('limitations');
}
$generator->endObjectElement('Policy');
}
示例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 \eZ\Publish\Core\REST\Server\Values\Version $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$content = $data->content;
$versionInfo = $content->getVersionInfo();
$contentType = $data->contentType;
$generator->startObjectElement('Version');
$visitor->setHeader('Content-Type', $generator->getMediaType('Version'));
$visitor->setHeader('Accept-Patch', $generator->getMediaType('VersionUpdate'));
$path = $data->path;
if ($path == null) {
$path = $this->router->generate('ezpublish_rest_loadContentInVersion', array('contentId' => $content->id, 'versionNumber' => $versionInfo->versionNo));
}
$generator->startAttribute('href', $path);
$generator->endAttribute('href');
$visitor->visitValueObject($versionInfo);
$generator->startHashElement('Fields');
$generator->startList('field');
foreach ($content->getFields() as $field) {
$this->visitField($generator, $contentType, $field);
}
$generator->endList('field');
$generator->endHashElement('Fields');
$visitor->visitValueObject(new RelationListValue($data->relations, $content->id, $versionInfo->versionNo));
$generator->endObjectElement('Version');
}
示例6: 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');
}
示例7: 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');
}
示例8: 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;
}
示例9: 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');
}
示例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\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');
}
示例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\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');
}
示例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 \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');
}
示例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\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');
}
示例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 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');
}
示例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\RestExecutedView $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('View');
$visitor->setHeader('Content-Type', $generator->getMediaType('View'));
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_views_load', array('viewId' => $data->identifier)));
$generator->endAttribute('href');
$generator->startValueElement('identifier', $data->identifier);
$generator->endValueElement('identifier');
// BEGIN Query
$generator->startObjectElement('Query');
$generator->endObjectElement('Query');
// END Query
// BEGIN Result
$generator->startObjectElement('Result', 'ViewResult');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_views_load_results', array('viewId' => $data->identifier)));
$generator->endAttribute('href');
// BEGIN searchHits
$generator->startHashElement('searchHits');
$generator->startList('searchHit');
foreach ($data->searchResults->searchHits as $searchHit) {
$generator->startObjectElement('searchHit');
$generator->startAttribute('score', 0);
$generator->endAttribute('score');
$generator->startAttribute('index', 0);
$generator->endAttribute('index');
$generator->startObjectElement('value');
// @todo Refactor
if ($searchHit->valueObject instanceof ApiValues\Content) {
/** @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */
$contentInfo = $searchHit->valueObject->contentInfo;
$valueObject = new RestContentValue($contentInfo, $this->locationService->loadLocation($contentInfo->mainLocationId), $searchHit->valueObject, $this->contentTypeService->loadContentType($contentInfo->contentTypeId), $this->contentService->loadRelations($searchHit->valueObject->getVersionInfo()));
} elseif ($searchHit->valueObject instanceof ApiValues\Location) {
$valueObject = $searchHit->valueObject;
} elseif ($searchHit->valueObject instanceof ApiValues\ContentInfo) {
$valueObject = new RestContentValue($searchHit->valueObject);
} else {
throw new Exceptions\InvalidArgumentException('Unhandled object type');
}
$visitor->visitValueObject($valueObject);
$generator->endObjectElement('value');
$generator->endObjectElement('searchHit');
}
$generator->endList('searchHit');
$generator->endHashElement('searchHits');
// END searchHits
$generator->endObjectElement('Result');
// END Result
$generator->endObjectElement('View');
}