当前位置: 首页>>代码示例>>PHP>>正文


PHP Visitor::setHeader方法代码示例

本文整理汇总了PHP中eZ\Publish\Core\REST\Common\Output\Visitor::setHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Visitor::setHeader方法的具体用法?PHP Visitor::setHeader怎么用?PHP Visitor::setHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZ\Publish\Core\REST\Common\Output\Visitor的用法示例。


在下文中一共展示了Visitor::setHeader方法的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\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');
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:36,代码来源:ContentTypeGroup.php

示例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\Common\Values\RestObjectState $data
  */
 public function visit(Visitor $visitor, Generator $generator, $data)
 {
     $generator->startObjectElement('ObjectState');
     $visitor->setHeader('Content-Type', $generator->getMediaType('ObjectState'));
     $visitor->setHeader('Accept-Patch', $generator->getMediaType('ObjectStateUpdate'));
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadObjectState', array('objectStateGroupId' => $data->groupId, 'objectStateId' => $data->objectState->id)));
     $generator->endAttribute('href');
     $generator->startValueElement('id', $data->objectState->id);
     $generator->endValueElement('id');
     $generator->startValueElement('identifier', $data->objectState->identifier);
     $generator->endValueElement('identifier');
     $generator->startValueElement('priority', $data->objectState->priority);
     $generator->endValueElement('priority');
     $generator->startObjectElement('ObjectStateGroup');
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadObjectStateGroup', array('objectStateGroupId' => $data->groupId)));
     $generator->endAttribute('href');
     $generator->endObjectElement('ObjectStateGroup');
     $generator->startValueElement('defaultLanguageCode', $data->objectState->defaultLanguageCode);
     $generator->endValueElement('defaultLanguageCode');
     $generator->startValueElement('languageCodes', implode(',', $data->objectState->languageCodes));
     $generator->endValueElement('languageCodes');
     $this->visitNamesList($generator, $data->objectState->getNames());
     $this->visitDescriptionsList($generator, $data->objectState->getDescriptions());
     $generator->endObjectElement('ObjectState');
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:32,代码来源:RestObjectState.php

示例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\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');
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:32,代码来源:Policy.php

示例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\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');
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:32,代码来源:Version.php

示例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\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');
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:34,代码来源:UserGroupRefList.php

示例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 \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');
 }
开发者ID:netgen,项目名称:tagsbundle,代码行数:66,代码来源:RestTag.php

示例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 \eZ\Publish\Core\REST\Server\Values\RestLocation $data
  */
 public function visit(Visitor $visitor, Generator $generator, $data)
 {
     $generator->startObjectElement('Location');
     $visitor->setHeader('Content-Type', $generator->getMediaType('Location'));
     $visitor->setHeader('Accept-Patch', $generator->getMediaType('LocationUpdate'));
     $location = $data->location;
     $contentInfo = $location->getContentInfo();
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadLocation', array('locationPath' => trim($location->pathString, '/'))));
     $generator->endAttribute('href');
     $generator->startValueElement('id', $location->id);
     $generator->endValueElement('id');
     $generator->startValueElement('priority', $location->priority);
     $generator->endValueElement('priority');
     $generator->startValueElement('hidden', $this->serializeBool($generator, $location->hidden));
     $generator->endValueElement('hidden');
     $generator->startValueElement('invisible', $this->serializeBool($generator, $location->invisible));
     $generator->endValueElement('invisible');
     $generator->startObjectElement('ParentLocation', 'Location');
     if (trim($location->pathString, '/') !== '1') {
         $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadLocation', array('locationPath' => implode('/', array_slice($location->path, 0, count($location->path) - 1)))));
         $generator->endAttribute('href');
     }
     $generator->endObjectElement('ParentLocation');
     $generator->startValueElement('pathString', $location->pathString);
     $generator->endValueElement('pathString');
     $generator->startValueElement('depth', $location->depth);
     $generator->endValueElement('depth');
     $generator->startValueElement('childCount', $data->childCount);
     $generator->endValueElement('childCount');
     $generator->startValueElement('remoteId', $location->remoteId);
     $generator->endValueElement('remoteId');
     $generator->startObjectElement('Children', 'LocationList');
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadLocationChildren', array('locationPath' => trim($location->pathString, '/'))));
     $generator->endAttribute('href');
     $generator->endObjectElement('Children');
     $generator->startObjectElement('Content');
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadContent', array('contentId' => $contentInfo->id)));
     $generator->endAttribute('href');
     $generator->endObjectElement('Content');
     $generator->startValueElement('sortField', $this->serializeSortField($location->sortField));
     $generator->endValueElement('sortField');
     $generator->startValueElement('sortOrder', $this->serializeSortOrder($location->sortOrder));
     $generator->endValueElement('sortOrder');
     $generator->startObjectElement('UrlAliases', 'UrlAliasRefList');
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_listLocationURLAliases', array('locationPath' => trim($location->pathString, '/'))));
     $generator->endAttribute('href');
     $generator->endObjectElement('UrlAliases');
     $generator->startObjectElement('ContentInfo', 'ContentInfo');
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadContent', array('contentId' => $contentInfo->id)));
     $generator->endAttribute('href');
     $visitor->visitValueObject(new RestContentValue($contentInfo));
     $generator->endObjectElement('ContentInfo');
     $generator->endObjectElement('Location');
 }
开发者ID:kuborgh,项目名称:ezpublish-kernel,代码行数:61,代码来源:RestLocation.php

示例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\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');
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:22,代码来源:ObjectStateList.php

示例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\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');
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:22,代码来源:ContentList.php

示例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\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');
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:22,代码来源:ContentTypeInfoList.php

示例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\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');
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:22,代码来源:ContentObjectStates.php

示例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\API\Repository\Values\Content\Section $data
  */
 public function visit(Visitor $visitor, Generator $generator, $data)
 {
     $generator->startObjectElement('Section');
     $visitor->setHeader('Content-Type', $generator->getMediaType('Section'));
     $visitor->setHeader('Accept-Patch', $generator->getMediaType('SectionInput'));
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadSection', array('sectionId' => $data->id)));
     $generator->endAttribute('href');
     $generator->startValueElement('sectionId', $data->id);
     $generator->endValueElement('sectionId');
     $generator->startValueElement('identifier', $data->identifier);
     $generator->endValueElement('identifier');
     $generator->startValueElement('name', $data->name);
     $generator->endValueElement('name');
     $generator->endObjectElement('Section');
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:22,代码来源:Section.php

示例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\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');
 }
开发者ID:xcorp1986,项目名称:ezpublish-kernel,代码行数:22,代码来源:Role.php

示例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('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');
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:33,代码来源:ObjectStateCreateStruct.php

示例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\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');
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:33,代码来源:ContentTypeGroupRefList.php


注:本文中的eZ\Publish\Core\REST\Common\Output\Visitor::setHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。