本文整理汇总了PHP中eZ\Publish\Core\REST\Common\Output\Generator::endObjectElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::endObjectElement方法的具体用法?PHP Generator::endObjectElement怎么用?PHP Generator::endObjectElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\REST\Common\Output\Generator
的用法示例。
在下文中一共展示了Generator::endObjectElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例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\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');
}
示例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\API\Repository\Values\ContentType\ContentTypeGroup $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ContentTypeGroup');
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentTypeGroup'));
$visitor->setHeader('Accept-Patch', $generator->getMediaType('ContentTypeGroupInput'));
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadContentTypeGroup', array('contentTypeGroupId' => $data->id)));
$generator->endAttribute('href');
$generator->startValueElement('id', $data->id);
$generator->endValueElement('id');
$generator->startValueElement('identifier', $data->identifier);
$generator->endValueElement('identifier');
$generator->startValueElement('created', $data->creationDate->format('c'));
$generator->endValueElement('created');
$generator->startValueElement('modified', $data->modificationDate->format('c'));
$generator->endValueElement('modified');
$generator->startObjectElement('Creator', 'User');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadUser', array('userId' => $data->creatorId)));
$generator->endAttribute('href');
$generator->endObjectElement('Creator');
$generator->startObjectElement('Modifier', 'User');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadUser', array('userId' => $data->modifierId)));
$generator->endAttribute('href');
$generator->endObjectElement('Modifier');
$generator->startObjectElement('ContentTypes', 'ContentTypeInfoList');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_listContentTypesForGroup', array('contentTypeGroupId' => $data->id)));
$generator->endAttribute('href');
$generator->endObjectElement('ContentTypes');
$generator->endObjectElement('ContentTypeGroup');
}
示例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 \Netgen\TagsBundle\Core\REST\Server\Values\RestTag $data
*/
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', array('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', array('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', array('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', array('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', array('tagPath' => trim($tag->pathString, '/'))));
$generator->endAttribute('href');
$generator->endObjectElement('Synonyms');
}
$generator->startObjectElement('RelatedContent', 'ContentList');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_eztags_getRelatedContent', array('tagPath' => trim($tag->pathString, '/'))));
$generator->endAttribute('href');
$generator->endObjectElement('RelatedContent');
$generator->endObjectElement('Tag');
}
示例5: 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');
}
示例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 mixed $data
*/
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');
}
示例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('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');
}
示例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\Common\Values\ContentObjectStates $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ContentObjectStates');
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentObjectStates'));
$visitor->setHeader('Accept-Patch', $generator->getMediaType('ContentObjectStates'));
$generator->startList('ObjectState');
foreach ($data->states as $state) {
$generator->startObjectElement('ObjectState');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadObjectState', array('objectStateGroupId' => $state->groupId, 'objectStateId' => $state->objectState->id)));
$generator->endAttribute('href');
$generator->endObjectElement('ObjectState');
}
$generator->endList('ObjectState');
$generator->endObjectElement('ContentObjectStates');
}
示例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\API\Repository\Values\User\Role $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('Role');
$visitor->setHeader('Content-Type', $generator->getMediaType('Role'));
$visitor->setHeader('Accept-Patch', $generator->getMediaType('RoleInput'));
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadRole', array('roleId' => $data->id)));
$generator->endAttribute('href');
$generator->startValueElement('identifier', $data->identifier);
$generator->endValueElement('identifier');
$generator->startObjectElement('Policies', 'PolicyList');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadPolicies', array('roleId' => $data->id)));
$generator->endAttribute('href');
$generator->endObjectElement('Policies');
$generator->endObjectElement('Role');
}
示例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 mixed $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('PolicyUpdate');
$visitor->setHeader('Content-Type', $generator->getMediaType('PolicyUpdate'));
$limitations = $data->getLimitations();
if (!empty($limitations)) {
$generator->startObjectElement('limitations');
$generator->startList('limitations');
foreach ($limitations as $limitation) {
$visitor->visitValueObject($limitation);
}
$generator->endList('limitations');
$generator->endObjectElement('limitations');
}
$generator->endObjectElement('PolicyUpdate');
}
示例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 \Netgen\TagsBundle\Core\REST\Server\Values\TagList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('TagList');
$visitor->setHeader('Content-Type', $generator->getMediaType('TagList'));
$generator->startAttribute('href', $data->path);
$generator->endAttribute('href');
$generator->startList('Tag');
foreach ($data->tags as $restTag) {
$generator->startObjectElement('Tag');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_eztags_loadTag', array('tagPath' => trim($restTag->tag->pathString, '/'))));
$generator->endAttribute('href');
$generator->endObjectElement('Tag');
}
$generator->endList('Tag');
$generator->endObjectElement('TagList');
}
示例12: visit
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ViewInput');
$generator->startValueElement('identifier', $data->identifier);
$generator->endValueElement('identifier');
if ($data->locationQuery !== null) {
$queryElementName = 'LocationQuery';
} elseif ($data->contentQuery !== null) {
$queryElementName = 'ContentQuery';
} else {
throw new Exceptions\InvalidArgumentException("ViewInput Query", "No content nor location query found in ViewInput");
}
$generator->startObjectElement($queryElementName);
$generator->endObjectElement($queryElementName);
$generator->endObjectElement('ViewInput');
}
示例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\URLAliasRefList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('UrlAliasRefList');
$visitor->setHeader('Content-Type', $generator->getMediaType('UrlAliasRefList'));
$generator->startAttribute('href', $data->path);
$generator->endAttribute('href');
$generator->startList('UrlAlias');
foreach ($data->urlAliases as $urlAlias) {
$generator->startObjectElement('UrlAlias');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadURLAlias', array('urlAliasId' => $urlAlias->id)));
$generator->endAttribute('href');
$generator->endObjectElement('UrlAlias');
}
$generator->endList('UrlAlias');
$generator->endObjectElement('UrlAliasRefList');
}
示例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\API\Repository\Values\Content\URLAlias $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('UrlAlias');
$visitor->setHeader('Content-Type', $generator->getMediaType('UrlAlias'));
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadURLAlias', array('urlAliasId' => $data->id)));
$generator->endAttribute('href');
$generator->startAttribute('id', $data->id);
$generator->endAttribute('id');
$generator->startAttribute('type', $this->serializeType($data->type));
$generator->endAttribute('type');
if ($data->type === Values\Content\URLAlias::LOCATION) {
$generator->startObjectElement('location', 'Location');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadLocation', array('locationPath' => $data->destination)));
$generator->endAttribute('href');
$generator->endObjectElement('location');
} else {
$generator->startValueElement('resource', $data->destination);
$generator->endValueElement('resource');
}
$generator->startValueElement('path', $data->path);
$generator->endValueElement('path');
$generator->startValueElement('languageCodes', implode(',', $data->languageCodes));
$generator->endValueElement('languageCodes');
$generator->startValueElement('alwaysAvailable', $this->serializeBool($generator, $data->alwaysAvailable));
$generator->endValueElement('alwaysAvailable');
$generator->startValueElement('isHistory', $this->serializeBool($generator, $data->isHistory));
$generator->endValueElement('isHistory');
$generator->startValueElement('forward', $this->serializeBool($generator, $data->forward));
$generator->endValueElement('forward');
$generator->startValueElement('custom', $this->serializeBool($generator, $data->isCustom));
$generator->endValueElement('custom');
$generator->endObjectElement('UrlAlias');
}
示例15: visit
public function visit(Visitor $visitor, Generator $generator, $data)
{
if ($data instanceof LocationQueryValue) {
$rootObjectElement = 'LocationQuery';
} else {
if ($data instanceof ContentQueryValue) {
$rootObjectElement = 'ContentQuery';
} else {
throw new Exceptions\InvalidArgumentException("ViewInput Query", "No content nor location query found in ViewInput");
}
}
$generator->startObjectElement($rootObjectElement, 'Query');
if (isset($data->filter)) {
$generator->startHashElement('Filter');
$visitor->visitValueObject($data->filter);
$generator->endHashElement('Filter');
}
if (isset($data->query)) {
$generator->startHashElement('Query');
$visitor->visitValueObject($data->query);
$generator->endhashElement('Query');
}
// $generator->startObjectElement('SortClauses');
// foreach ($data->sortClauses as $sortClause) {
// $visitor->visitValueObject($sortClause);
// }
// $generator->endObjectElement('SortClauses');
$generator->endObjectElement($rootObjectElement);
}