• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Repository\ContentTypeService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中eZ\Publish\API\Repository\ContentTypeService的典型用法代码示例。如果您正苦于以下问题:PHP ContentTypeService类的具体用法?PHP ContentTypeService怎么用?PHP ContentTypeService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ContentTypeService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: parse

 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\User\UserCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentType = null;
     if (array_key_exists('ContentType', $data) && is_array($data['ContentType'])) {
         if (!array_key_exists('_href', $data['ContentType'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for ContentType element in UserCreate.");
         }
         $contentType = $this->contentTypeService->loadContentType($this->requestParser->parseHref($data['ContentType']['_href'], 'contentTypeId'));
     }
     if (!array_key_exists('mainLanguageCode', $data)) {
         throw new Exceptions\Parser("Missing 'mainLanguageCode' element for UserCreate.");
     }
     if (!array_key_exists('login', $data)) {
         throw new Exceptions\Parser("Missing 'login' element for UserCreate.");
     }
     if (!array_key_exists('email', $data)) {
         throw new Exceptions\Parser("Missing 'email' element for UserCreate.");
     }
     if (!array_key_exists('password', $data)) {
         throw new Exceptions\Parser("Missing 'password' element for UserCreate.");
     }
     $userCreateStruct = $this->userService->newUserCreateStruct($data['login'], $data['email'], $data['password'], $data['mainLanguageCode'], $contentType);
     if (array_key_exists('Section', $data) && is_array($data['Section'])) {
         if (!array_key_exists('_href', $data['Section'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for Section element in UserCreate.");
         }
         $userCreateStruct->sectionId = $this->requestParser->parseHref($data['Section']['_href'], 'sectionId');
     }
     if (array_key_exists('remoteId', $data)) {
         $userCreateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('enabled', $data)) {
         $userCreateStruct->enabled = $this->parserTools->parseBooleanValue($data['enabled']);
     }
     if (!array_key_exists('fields', $data) || !is_array($data['fields']) || !is_array($data['fields']['field'])) {
         throw new Exceptions\Parser("Missing or invalid 'fields' element for UserCreate.");
     }
     foreach ($data['fields']['field'] as $fieldData) {
         if (!array_key_exists('fieldDefinitionIdentifier', $fieldData)) {
             throw new Exceptions\Parser("Missing 'fieldDefinitionIdentifier' element in field data for UserCreate.");
         }
         $fieldDefinition = $userCreateStruct->contentType->getFieldDefinition($fieldData['fieldDefinitionIdentifier']);
         if (!$fieldDefinition) {
             throw new Exceptions\Parser("'{$fieldData['fieldDefinitionIdentifier']}' is invalid field definition identifier for '{$userCreateStruct->contentType->identifier}' content type in UserCreate.");
         }
         if (!array_key_exists('fieldValue', $fieldData)) {
             throw new Exceptions\Parser("Missing 'fieldValue' element for '{$fieldData['fieldDefinitionIdentifier']}' identifier in UserCreate.");
         }
         $fieldValue = $this->fieldTypeParser->parseValue($fieldDefinition->fieldTypeIdentifier, $fieldData['fieldValue']);
         $languageCode = null;
         if (array_key_exists('languageCode', $fieldData)) {
             $languageCode = $fieldData['languageCode'];
         }
         $userCreateStruct->setField($fieldData['fieldDefinitionIdentifier'], $fieldValue, $languageCode);
     }
     return $userCreateStruct;
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:65,代码来源:UserCreate.php


示例2: getHandler

 /**
  * Returns form handler to use at $location
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @return \Heliopsis\eZFormsBundle\FormHandler\FormHandlerInterface
  */
 public function getHandler(Location $location)
 {
     $locationContentTypeId = $location->contentInfo->contentTypeId;
     /** @var ContentType $locationContentType */
     $locationContentType = $this->contentTypeService->loadContentType($locationContentTypeId);
     return array_key_exists($locationContentType->identifier, $this->map) ? $this->map[$locationContentType->identifier] : new NullHandler();
 }
开发者ID:heliopsis,项目名称:ezforms-bundle,代码行数:13,代码来源:ContentTypeIdentifierMap.php


示例3: getContentCreateStruct

 /**
  * Creates and prepares content create structure.
  *
  * @param array $data
  * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct
  */
 private function getContentCreateStruct($data)
 {
     $contentType = $this->contentTypeService->loadContentTypeByIdentifier($data['content_type']);
     $struct = $this->contentService->newContentCreateStruct($contentType, '');
     $this->fillValueObject($struct, $data, ['content_type']);
     return $struct;
 }
开发者ID:silversolutions,项目名称:content-loader-bundle,代码行数:13,代码来源:Content.php


示例4: updateFieldDefinition

 public function updateFieldDefinition($identifier, FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct)
 {
     $contentTypeDraft = $this->contentTypeService->createContentTypeDraft($this->currentContentType);
     $this->contentTypeService->updateFieldDefinition($contentTypeDraft, $this->currentContentType->getFieldDefinition($identifier), $fieldDefinitionUpdateStruct);
     $this->contentTypeService->publishContentTypeDraft($contentTypeDraft);
     $this->currentContentType = $this->contentTypeService->loadContentTypeByIdentifier($this->currentContentType->identifier);
 }
开发者ID:ezsystems,项目名称:repository-forms,代码行数:7,代码来源:ContentType.php


示例5: parseFieldValue

 /**
  * Parses the given $value for the field $fieldDefIdentifier in the content
  * identified by $contentInfoId.
  *
  * @param string $contentInfoId
  * @param string $fieldDefIdentifier
  * @param mixed $value
  *
  * @return mixed
  */
 public function parseFieldValue($contentInfoId, $fieldDefIdentifier, $value)
 {
     $contentInfo = $this->contentService->loadContentInfo($contentInfoId);
     $contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
     $fieldDefinition = $contentType->getFieldDefinition($fieldDefIdentifier);
     return $this->parseValue($fieldDefinition->fieldTypeIdentifier, $value);
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:17,代码来源:FieldTypeParser.php


示例6: visit

 /**
  * @inheritdoc
  */
 public function visit(TreeNodeInterface $node, &$data)
 {
     $struct = $this->contentTypeService->newFieldDefinitionCreateStruct('', '');
     $this->fillValueObject($struct, $data);
     // Get position from node index (starts from 1)
     $struct->position = $node->getIndex() + 1;
     return $struct;
 }
开发者ID:silversolutions,项目名称:content-loader-bundle,代码行数:11,代码来源:FieldDefinition.php


示例7: parse

 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\Core\REST\Server\Values\Version
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentId = $this->requestParser->parseHref($data['VersionInfo']['Content']['_href'], 'contentId');
     $content = $this->contentService->loadContent($contentId, null, $data['VersionInfo']['versionNo']);
     $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
     $relations = $this->contentService->loadRelations($content->versionInfo);
     return new VersionValue($content, $contentType, $relations);
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:16,代码来源:Version.php


示例8: parse

 /**
  * Parses input structure to a Criterion object
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @throws \eZ\Publish\Core\REST\Common\Exceptions\Parser
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeId
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists("ContentTypeIdentifierCriterion", $data)) {
         throw new Exceptions\Parser("Invalid <ContentTypeIdCriterion> format");
     }
     $contentType = $this->contentTypeService->loadContentTypeByIdentifier($data["ContentTypeIdentifierCriterion"]);
     return new ContentTypeIdCriterion($contentType->id);
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:18,代码来源:ContentTypeIdentifier.php


示例9: mapContentInfo

 /**
  * Maps Repository ContentInfo to the Site ContentInfo.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
  * @param string $languageCode
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType|null $contentType
  *
  * @return \Netgen\EzPlatformSiteApi\API\Values\ContentInfo
  */
 public function mapContentInfo(VersionInfo $versionInfo, $languageCode, ContentType $contentType = null)
 {
     $contentInfo = $versionInfo->contentInfo;
     if ($contentType === null) {
         $contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
     }
     return new ContentInfo(['name' => $versionInfo->getName($languageCode), 'languageCode' => $languageCode, 'innerContentInfo' => $versionInfo->contentInfo, 'innerContentType' => $contentType]);
 }
开发者ID:netgen,项目名称:ezplatform-site-api,代码行数:17,代码来源:DomainObjectMapper.php


示例10: getSelectionChoices

 protected function getSelectionChoices()
 {
     $contentTypeChoices = [];
     foreach ($this->contentTypeService->loadContentTypeGroups() as $group) {
         foreach ($this->contentTypeService->loadContentTypes($group) as $contentType) {
             $contentTypeChoices[$contentType->id] = $contentType->getName($contentType->mainLanguageCode);
         }
     }
     return $contentTypeChoices;
 }
开发者ID:crevillo,项目名称:repository-forms,代码行数:10,代码来源:ContentTypeLimitationMapper.php


示例11: buildForm

 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('contentTypeGroupId', 'hidden', ['constraints' => new Callback(function ($contentTypeGroupId, ExecutionContextInterface $context) {
         try {
             $this->contentTypeService->loadContentTypeGroup($contentTypeGroupId);
         } catch (NotFoundException $e) {
             $context->buildViolation('content_type.error.content_type_group.not_found')->setParameter('%id%', $contentTypeGroupId)->addViolation();
         }
     })])->add('create', 'submit', ['label' => 'content_type.create']);
 }
开发者ID:crevillo,项目名称:repository-forms,代码行数:10,代码来源:ContentTypeCreateType.php


示例12: getForm

 /**
  * @param Location $location
  * @return \Symfony\Component\Form\FormInterface
  * @throws \Heliopsis\eZFormsBundle\Exceptions\UnknownFormException
  */
 public function getForm(Location $location)
 {
     $locationContentTypeId = $location->contentInfo->contentTypeId;
     /** @var ContentType $locationContentType */
     $locationContentType = $this->contentTypeService->loadContentType($locationContentTypeId);
     if (!array_key_exists($locationContentType->identifier, $this->map)) {
         throw new UnknownFormException(sprintf("No form could be mapped to content type identifier '%s'", $locationContentType->identifier));
     }
     return $this->formFactory->create($this->map[$locationContentType->identifier]);
 }
开发者ID:heliopsis,项目名称:ezforms-bundle,代码行数:15,代码来源:ContentTypeIdentifierMap.php


示例13: parse

 /**
  * Parses input structure to a Criterion object.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @throws \eZ\Publish\Core\REST\Common\Exceptions\Parser
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeId
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     if (!array_key_exists('ContentTypeIdentifierCriterion', $data)) {
         throw new Exceptions\Parser('Invalid <ContentTypeIdCriterion> format');
     }
     if (!is_array($data['ContentTypeIdentifierCriterion'])) {
         $data['ContentTypeIdentifierCriterion'] = [$data['ContentTypeIdentifierCriterion']];
     }
     return new ContentTypeIdCriterion(array_map(function ($contentTypeIdentifier) {
         return $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier)->id;
     }, $data['ContentTypeIdentifierCriterion']));
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:22,代码来源:ContentTypeIdentifier.php


示例14: processUpdate

 public function processUpdate(FormActionEvent $event)
 {
     /** @var \EzSystems\RepositoryForms\Data\ContentTypeGroup\ContentTypeGroupUpdateData|\EzSystems\RepositoryForms\Data\ContentTypeGroup\ContentTypeGroupCreateData $data */
     $data = $event->getData();
     if ($data->isNew()) {
         $contentTypeGroup = $this->contentTypeService->createContentTypeGroup($data);
     } else {
         $this->contentTypeService->updateContentTypeGroup($data->contentTypeGroup, $data);
         $contentTypeGroup = $this->contentTypeService->loadContentTypeGroup($data->getId());
     }
     $data->setContentTypeGroup($contentTypeGroup);
 }
开发者ID:crevillo,项目名称:repository-forms,代码行数:12,代码来源:ContentTypeGroupFormProcessor.php


示例15: parse

 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeUpdateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentTypeUpdateStruct = $this->contentTypeService->newContentTypeUpdateStruct();
     if (array_key_exists('identifier', $data)) {
         $contentTypeUpdateStruct->identifier = $data['identifier'];
     }
     if (array_key_exists('mainLanguageCode', $data)) {
         $contentTypeUpdateStruct->mainLanguageCode = $data['mainLanguageCode'];
     }
     if (array_key_exists('remoteId', $data)) {
         $contentTypeUpdateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('urlAliasSchema', $data)) {
         $contentTypeUpdateStruct->urlAliasSchema = $data['urlAliasSchema'];
     }
     if (array_key_exists('nameSchema', $data)) {
         $contentTypeUpdateStruct->nameSchema = $data['nameSchema'];
     }
     if (array_key_exists('isContainer', $data)) {
         $contentTypeUpdateStruct->isContainer = $this->parserTools->parseBooleanValue($data['isContainer']);
     }
     if (array_key_exists('defaultSortField', $data)) {
         $contentTypeUpdateStruct->defaultSortField = $this->parserTools->parseDefaultSortField($data['defaultSortField']);
     }
     if (array_key_exists('defaultSortOrder', $data)) {
         $contentTypeUpdateStruct->defaultSortOrder = $this->parserTools->parseDefaultSortOrder($data['defaultSortOrder']);
     }
     if (array_key_exists('defaultAlwaysAvailable', $data)) {
         $contentTypeUpdateStruct->defaultAlwaysAvailable = $this->parserTools->parseBooleanValue($data['defaultAlwaysAvailable']);
     }
     if (array_key_exists('names', $data)) {
         if (!is_array($data['names']) || !array_key_exists('value', $data['names']) || !is_array($data['names']['value'])) {
             throw new Exceptions\Parser("Invalid 'names' element for ContentTypeUpdate.");
         }
         $contentTypeUpdateStruct->names = $this->parserTools->parseTranslatableList($data['names']);
     }
     if (array_key_exists('descriptions', $data)) {
         if (!is_array($data['descriptions']) || !array_key_exists('value', $data['descriptions']) || !is_array($data['descriptions']['value'])) {
             throw new Exceptions\Parser("Invalid 'descriptions' element for ContentTypeUpdate.");
         }
         $contentTypeUpdateStruct->descriptions = $this->parserTools->parseTranslatableList($data['descriptions']);
     }
     if (array_key_exists('modificationDate', $data)) {
         $contentTypeUpdateStruct->modificationDate = new DateTime($data['modificationDate']);
     }
     if (array_key_exists('User', $data)) {
         if (!array_key_exists('_href', $data['User'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for User element in ContentTypeUpdate.");
         }
         $contentTypeUpdateStruct->modifierId = $this->requestParser->parseHref($data['User']['_href'], 'userId');
     }
     return $contentTypeUpdateStruct;
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:61,代码来源:ContentTypeUpdate.php


示例16: createWithoutDraftAction

 /**
  * Displays and processes a content creation form. Showing the form does not create a draft in the repository.
  *
  * @param int $contentTypeIdentifier ContentType id to create
  * @param string $language Language code to create the content in (eng-GB, ger-DE, ...))
  * @param int $parentLocationId Location the content should be a child of
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createWithoutDraftAction($contentTypeIdentifier, $language, $parentLocationId, Request $request)
 {
     $contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
     $data = (new ContentCreateMapper())->mapToFormData($contentType, ['mainLanguageCode' => $language, 'parentLocation' => $this->locationService->newLocationCreateStruct($parentLocationId)]);
     $form = $this->createForm(ContentEditType::class, $data, ['languageCode' => $language]);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $this->contentActionDispatcher->dispatchFormAction($form, $data, $form->getClickedButton()->getName());
         if ($response = $this->contentActionDispatcher->getResponse()) {
             return $response;
         }
     }
     return $this->render('EzSystemsRepositoryFormsBundle:Content:content_edit.html.twig', ['form' => $form->createView(), 'languageCode' => $language, 'pagelayout' => $this->pagelayout]);
 }
开发者ID:ezsystems,项目名称:repository-forms,代码行数:24,代码来源:ContentEditController.php


示例17: assignUserToUserGroup

 /**
  * Assigns the user to a user group
  *
  * @param $userId
  *
  * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
  * @return \eZ\Publish\Core\REST\Server\Values\UserGroupRefList
  */
 public function assignUserToUserGroup($userId)
 {
     $user = $this->userService->loadUser($userId);
     try {
         $userGroupLocation = $this->locationService->loadLocation($this->extractLocationIdFromPath($this->request->query->get('group')));
     } catch (APINotFoundException $e) {
         throw new Exceptions\ForbiddenException($e->getMessage());
     }
     try {
         $userGroup = $this->userService->loadUserGroup($userGroupLocation->contentId);
     } catch (APINotFoundException $e) {
         throw new Exceptions\ForbiddenException($e->getMessage());
     }
     try {
         $this->userService->assignUserToUserGroup($user, $userGroup);
     } catch (InvalidArgumentException $e) {
         throw new Exceptions\ForbiddenException($e->getMessage());
     }
     $userGroups = $this->userService->loadUserGroupsOfUser($user);
     $restUserGroups = array();
     foreach ($userGroups as $userGroup) {
         $userGroupContentInfo = $userGroup->getVersionInfo()->getContentInfo();
         $userGroupLocation = $this->locationService->loadLocation($userGroupContentInfo->mainLocationId);
         $contentType = $this->contentTypeService->loadContentType($userGroupContentInfo->contentTypeId);
         $restUserGroups[] = new Values\RestUserGroup($userGroup, $contentType, $userGroupContentInfo, $userGroupLocation, $this->contentService->loadRelations($userGroup->getVersionInfo()));
     }
     return new Values\UserGroupRefList($restUserGroups, $this->router->generate('ezpublish_rest_loadUserGroupsOfUser', array('userId' => $userId)), $userId);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:36,代码来源:User.php


示例18: itContainsAVersionOfContentType

 /**
  * @Given /^it contains a Version of ContentType "([^"]*)"$/
  */
 public function itContainsAVersionOfContentType($contentTypeIdentifier)
 {
     $object = $this->restContext->getResponseObject();
     Assertion::assertInstanceOf('eZ\\Publish\\Core\\REST\\Server\\Values\\Version', $object);
     Assertion::assertEquals($contentTypeIdentifier, $this->contentTypeService->loadContentType($object->content->contentInfo->contentTypeId)->identifier);
     $this->currentContent = $this->contentService->loadContentByVersionInfo($object->content->versionInfo);
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:10,代码来源:UserContentContext.php


示例19: validate

 /**
  * Checks if the passed value is valid.
  *
  * @param ContentTypeData $value The value that should be validated
  * @param Constraint|UniqueFieldDefinitionIdentifier $constraint The constraint for the validation
  *
  * @api
  */
 public function validate($value, Constraint $constraint)
 {
     if (!$value instanceof ContentTypeData) {
         return;
     }
     try {
         $contentType = $this->contentTypeService->loadContentTypeByIdentifier($value->identifier);
         // It's of course OK to edit a draft of an existing ContentType :-)
         if ($contentType->id === $value->contentTypeDraft->id) {
             return;
         }
         $this->context->buildViolation($constraint->message)->atPath('identifier')->setParameter('%identifier%', $value->identifier)->addViolation();
     } catch (NotFoundException $e) {
         // Do nothing
     }
 }
开发者ID:crevillo,项目名称:repository-forms,代码行数:24,代码来源:UniqueContentTypeIdentifierValidator.php


示例20: 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 Result metadata
     $generator->startValueElement('count', $data->searchResults->totalCount);
     $generator->endValueElement('count');
     $generator->startValueElement('time', $data->searchResults->time);
     $generator->endValueElement('time');
     $generator->startValueElement('timedOut', $generator->serializeBool($data->searchResults->timedOut));
     $generator->endValueElement('timedOut');
     $generator->startValueElement('maxScore', $data->searchResults->maxScore);
     $generator->endValueElement('maxScore');
     // END Result metadata
     // 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');
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:66,代码来源:RestExecutedView.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Repository\LocationService类代码示例发布时间:2022-05-23
下一篇:
PHP Repository\ContentService类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap