當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Output\Generator類代碼示例

本文整理匯總了PHP中eZ\Publish\Core\REST\Common\Output\Generator的典型用法代碼示例。如果您正苦於以下問題:PHP Generator類的具體用法?PHP Generator怎麽用?PHP Generator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Generator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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');
 }
開發者ID:ezsystems,項目名稱:ezpublish-kernel,代碼行數:15,代碼來源:ContentTypeIdentifier.php

示例2: visit

 /**
  * @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
  * @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
  * @param mixed $data
  * @return mixed
  * @throws \EzSystems\RecommendationBundle\Rest\Exception\ResponseClassNotImplementedException
  */
 public function visit(Visitor $visitor, Generator $generator, $data)
 {
     $visitor->setHeader('Content-Type', $generator->getMediaType('ContentList'));
     if (empty($data->contents)) {
         $visitor->setStatus(204);
         return;
     }
     if (!isset($this->responseRenderers[$data->options['responseType']])) {
         throw new ResponseClassNotImplementedException(sprintf('Renderer for %s response not implemented.', $data->options['responseType']));
     }
     return $this->responseRenderers[$data->options['responseType']]->render($generator, $data);
 }
開發者ID:kamilmusial,項目名稱:EzSystemsRecommendationBundle,代碼行數:19,代碼來源:ContentData.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 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');
 }
開發者ID:CG77,項目名稱:ezpublish-kernel,代碼行數:21,代碼來源:ContentObjectStates.php

示例4: visit

 /**
  * @param Visitor $visitor
  * @param Generator $generator
  * @param \eZ\Publish\Core\REST\Client\Values\ViewInput $data
  * @throws Exceptions\InvalidArgumentException
  */
 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");
     }
     $visitor->visitValueObject($data->{$queryElementName});
     $generator->endObjectElement('ViewInput');
 }
開發者ID:ezsystems,項目名稱:ezpublish-kernel,代碼行數:21,代碼來源:ViewInput.php

示例5: visitField

 /**
  * Visits a single content field and generates its content
  *
  * @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
  * @param \eZ\Publish\API\Repository\Values\Content\Field $field
  */
 public function visitField(Generator $generator, ContentType $contentType, Field $field)
 {
     $generator->startHashElement('field');
     $generator->startValueElement('id', $field->id);
     $generator->endValueElement('id');
     $generator->startValueElement('fieldDefinitionIdentifier', $field->fieldDefIdentifier);
     $generator->endValueElement('fieldDefinitionIdentifier');
     $generator->startValueElement('languageCode', $field->languageCode);
     $generator->endValueElement('languageCode');
     $this->fieldTypeSerializer->serializeFieldValue($generator, $contentType, $field);
     $generator->endHashElement('field');
 }
開發者ID:CG77,項目名稱:ezpublish-kernel,代碼行數:19,代碼來源:Version.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 mixed $data
  */
 public function visit(Visitor $visitor, Generator $generator, $data)
 {
     $generator->startObjectElement('SectionInput');
     $visitor->setHeader('Content-Type', $generator->getMediaType('SectionInput'));
     $generator->startValueElement('identifier', $data->identifier);
     $generator->endValueElement('identifier');
     $generator->startValueElement('name', $data->name);
     $generator->endValueElement('name');
     $generator->endObjectElement('SectionInput');
 }
開發者ID:CG77,項目名稱:ezpublish-kernel,代碼行數:17,代碼來源:SectionCreateStruct.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 mixed $data
  */
 public function visit(Visitor $visitor, Generator $generator, $data)
 {
     $generator->startObjectElement('SessionInput');
     $visitor->setHeader('Content-Type', $generator->getMediaType('SessionInput'));
     $generator->startValueElement('login', $data->login);
     $generator->endValueElement('login');
     $generator->startValueElement('password', $data->password);
     $generator->endValueElement('password');
     $generator->endObjectElement('SessionInput');
 }
開發者ID:Pixy,項目名稱:ezpublish-kernel,代碼行數:17,代碼來源:SessionInput.php

示例8: 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);
 }
開發者ID:ezsystems,項目名稱:ezpublish-kernel,代碼行數:29,代碼來源:Query.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\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');
 }
開發者ID:Pixy,項目名稱:ezpublish-kernel,代碼行數:20,代碼來源:RoleAssignmentList.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\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');
 }
開發者ID:Pixy,項目名稱:ezpublish-kernel,代碼行數:20,代碼來源:URLWildcardList.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\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');
 }
開發者ID:Pixy,項目名稱:ezpublish-kernel,代碼行數:20,代碼來源:URLAliasList.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\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');
 }
開發者ID:ezsystems,項目名稱:ezpublish-kernel,代碼行數:20,代碼來源:Trash.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 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');
 }
開發者ID:CG77,項目名稱:ezpublish-kernel,代碼行數:21,代碼來源:RoleAssignment.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 \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

示例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\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


注:本文中的eZ\Publish\Core\REST\Common\Output\Generator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。