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


PHP Repository\ContentTypeService類代碼示例

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


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


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