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


PHP ContentTypeService::loadContentTypeByIdentifier方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: iSetTheContentToUserContentCreateStruct

 /**
  * @Given /^I set the Content to a User RestContentCreateStruct$/
  */
 public function iSetTheContentToUserContentCreateStruct()
 {
     $contentCreateStruct = $this->contentService->newContentCreateStruct($this->contentTypeService->loadContentTypeByIdentifier('user'), 'eng-GB');
     $userFieldValue = new UserValue(['login' => 'user_content_' . time(), 'email' => 'user_content_' . time() . '@example.com', 'passwordHash' => 'not_a_hash']);
     $contentCreateStruct->setField('first_name', new TextLineValue('User Content'));
     $contentCreateStruct->setField('last_name', new TextLineValue('@' . microtime(true)));
     $contentCreateStruct->setField('user_account', $userFieldValue);
     $restStruct = new RestContentCreateStruct($contentCreateStruct, new LocationCreateStruct(['parentLocationId' => 12]));
     $this->restContext->requestObject = $restStruct;
 }
開發者ID:Pixy,項目名稱:ezpublish-kernel,代碼行數:13,代碼來源:UserContentContext.php

示例4: 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

示例5: getUpdatedDraft

 /**
  * Update content type definition and returns a draft
  *
  * @param array $data
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft
  */
 private function getUpdatedDraft(array &$data)
 {
     $contentType = $this->contentTypeService->loadContentTypeByIdentifier($data['identifier']);
     $draft = $this->contentTypeService->createContentTypeDraft($contentType);
     // Update content type
     $struct = $this->contentTypeService->newContentTypeUpdateStruct($data);
     $this->fillValueObject($struct, $data);
     $diff = $this->diff->diff($contentType->fieldDefinitions, $data['field_definitions'], 'identifier');
     // @todo: introduce field updates (now only remove and add are supported)
     $this->updateDraftFields($draft, $diff, $data);
     $this->contentTypeService->updateContentTypeDraft($draft, $struct);
     return $draft;
 }
開發者ID:silversolutions,項目名稱:content-loader-bundle,代碼行數:19,代碼來源:ContentType.php

示例6: 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

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

示例8: 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

示例9: createContentDraft

 /**
  * Creates a content draft.
  *
  * @param eZ\Publish\API\Repository\Values\Content\Location $parentLocationId
  * @param string $contentTypeIdentifier
  * @param string $languageCode
  * @param array $fields Fields, as primitives understood by setField
  *
  * @return eZ\Publish\API\Repository\Values\Content\Content an unpublished Content draft
  */
 public function createContentDraft($parentLocationId, $contentTypeIdentifier, $fields, $languageCode = null)
 {
     $languageCode = $languageCode ?: self::DEFAULT_LANGUAGE;
     $repository = $this->getRepository();
     $locationCreateStruct = $repository->getLocationService()->newLocationCreateStruct($parentLocationId);
     $contentTypeIdentifier = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
     $contentCreateStruct = $this->contentService->newContentCreateStruct($contentTypeIdentifier, $languageCode);
     foreach (array_keys($fields) as $key) {
         $contentCreateStruct->setField($key, $fields[$key]);
     }
     return $this->contentService->createContent($contentCreateStruct, array($locationCreateStruct));
 }
開發者ID:emodric,項目名稱:ezpublish-kernel,代碼行數:22,代碼來源:BasicContentContext.php

示例10: loadContentTypeByIdentifier

 /**
  * Load and return a content type by its identifier.
  *
  * @param  string  $identifier       content type identifier
  * @param  bool $throwIfNotFound  if true, throws an exception if it is not found.
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup|null
  */
 protected function loadContentTypeByIdentifier($identifier, $throwIfNotFound = true)
 {
     $contentType = null;
     try {
         $contentType = $this->contentTypeService->loadContentTypeByIdentifier($identifier);
     } catch (ApiExceptions\NotFoundException $e) {
         $notFoundException = $e;
     }
     if (!$contentType && $throwIfNotFound) {
         throw $notFoundException;
     }
     return $contentType;
 }
開發者ID:ezsystems,項目名稱:ezpublish-kernel,代碼行數:21,代碼來源:ContentTypeContext.php

示例11: loadContentTypeByIdentifier

 /**
  * Get a Content Type object by identifier
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If content type with the given identifier and status DEFINED can not be found
  *
  * @param string $identifier
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
  */
 public function loadContentTypeByIdentifier($identifier)
 {
     return $this->service->loadContentTypeByIdentifier($identifier);
 }
開發者ID:Jenkosama,項目名稱:ezpublish-kernel,代碼行數:13,代碼來源:ContentTypeService.php

示例12: getContentTypeId

 /**
  * Returns ContentType ID based on $contentType name.
  *
  * @param string $contentType
  *
  * @return int
  */
 protected function getContentTypeId($contentType)
 {
     return $this->contentTypeService->loadContentTypeByIdentifier($contentType)->id;
 }
開發者ID:kamilmusial,項目名稱:EzSystemsRecommendationBundle,代碼行數:11,代碼來源:RecommendationTwigExtension.php

示例13: loadContentTypeByIdentifier

 /**
  * Loads a content type by its identifier
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
  */
 public function loadContentTypeByIdentifier(Request $request)
 {
     return $this->contentTypeService->loadContentTypeByIdentifier($request->query->get('identifier'));
 }
開發者ID:nlescure,項目名稱:ezpublish-kernel,代碼行數:9,代碼來源:ContentType.php


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