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


PHP Repository::getContentTypeService方法代码示例

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


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

示例1: getContentDecorator

 /**
  * @param Location $location
  * @return mixed
  */
 public function getContentDecorator(Location $location)
 {
     $mappingEntities = $this->configResolver->getParameter('class_mapping', 'ezcontentdecorator');
     $contentTypeIdentifier = $this->repository->getContentTypeService()->loadContentType($location->contentInfo->contentTypeId)->identifier;
     $className = array_key_exists($contentTypeIdentifier, $mappingEntities) ? $mappingEntities[$contentTypeIdentifier] : $this->defaultClassName;
     return new $className($this->container, $location, $contentTypeIdentifier);
 }
开发者ID:truffo,项目名称:ez-content-decorator-bundle,代码行数:11,代码来源:ContentDecoratorFactory.php

示例2: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!$request->attributes->get('is_rest_request')) {
         return;
     }
     if (($contentTypeHeaderValue = $request->headers->get('content-type')) === null) {
         return;
     }
     list($mediaType) = explode('+', $contentTypeHeaderValue);
     if (strtolower($mediaType) == !'application/vnd.ez.api.contentcreate') {
         return;
     }
     $message = $this->buildMessage($request);
     if (!$message->body) {
         return;
     }
     $result = $this->restInputDispatcher->parse($message);
     if (!$result instanceof RestContentCreateStruct) {
         return;
     }
     // Not a user
     if (($userCreateData = $this->mapContentCreateToUserCreate($result)) === false) {
         return;
     }
     list($userCreateStruct, $userGroup) = $userCreateData;
     $createdUser = $this->repository->getUserService()->createUser($userCreateStruct, [$userGroup]);
     $createdContentInfo = $createdUser->contentInfo;
     $createdLocation = $this->repository->getLocationService()->loadLocation($createdContentInfo->mainLocationId);
     $contentType = $this->repository->getContentTypeService()->loadContentType($createdContentInfo->contentTypeId);
     $result = new CreatedContent(array('content' => new RestContent($createdContentInfo, $createdLocation, $this->repository->getContentService()->loadContent($createdContentInfo->id), $contentType, $this->repository->getContentService()->loadRelations($createdUser->getVersionInfo()))));
     $event->setResponse($this->viewDispatcher->dispatch($event->getRequest(), $result));
 }
开发者ID:gbalcewicz,项目名称:PlatformUIBundle,代码行数:33,代码来源:ContentUserGateway.php

示例3: castContentInfo

 public function castContentInfo(ContentInfo $info, array $a, Stub $stub, $isNested, $filter = 0)
 {
     $a = [Caster::PREFIX_PROTECTED . 'id' => $info->id, Caster::PREFIX_PROTECTED . 'name' => $info->name] + $a;
     if (!$filter & Caster::EXCLUDE_VERBOSE) {
         $contentType = $this->repository->getContentTypeService()->loadContentType($info->contentTypeId);
         $a[Caster::PREFIX_VIRTUAL . 'contentTypeName'] = $contentType->getName($info->mainLanguageCode);
     }
     return $a;
 }
开发者ID:lolautruche,项目名称:ezsh,代码行数:9,代码来源:EzCaster.php

示例4: getContentTypeIdentifier

 /**
  * Gets content type identifier of field corresponding with the given node
  *
  * @param TreeNodeInterface $node
  * @return string
  */
 public function getContentTypeIdentifier(TreeNodeInterface $node)
 {
     $parent = $node->getParent();
     $fieldName = $parent->getName();
     $grandPa = $parent->getParent()->getParent();
     $contentTypeNode = $grandPa->getChildByName('content_type');
     $contentType = $this->repository->getContentTypeService()->loadContentTypeByIdentifier($contentTypeNode->getValue());
     $fieldDefinition = $contentType->getFieldDefinition($fieldName);
     return $fieldDefinition->fieldTypeIdentifier;
 }
开发者ID:silversolutions,项目名称:content-loader-bundle,代码行数:16,代码来源:AbstractFieldLoader.php

示例5: __construct

 /**
  * @param \eZ\Publish\API\Repository\Repository $repository
  * @param ConfigResolverInterface|\Psr\Log\LoggerInterface $resolver
  */
 public function __construct(Repository $repository, ConfigResolverInterface $resolver)
 {
     $this->repository = $repository;
     $this->searchService = $this->repository->getSearchService();
     $this->locationService = $this->repository->getLocationService();
     $this->contentService = $this->repository->getContentService();
     $this->languageService = $this->repository->getContentLanguageService();
     $this->userService = $this->repository->getUserService();
     $this->contentTypeService = $this->repository->getContentTypeService();
     $this->configResolver = $resolver;
 }
开发者ID:intermundiasolutions,项目名称:CjwPublishToolsBundle,代码行数:15,代码来源:PublishToolsService.php

示例6: createNewUser

 /**
  * @param $login
  * @param $email
  * @param $firstName
  * @param $lastName
  * @return User
  */
 public function createNewUser($login, $email, $firstName, $lastName)
 {
     $userService = $this->repository->getUserService();
     $userCreateStruct = $userService->newUserCreateStruct($login, $email, md5($email . $login . time() . rand(1, 10000)), 'eng-GB', $this->repository->getContentTypeService()->loadContentTypeByIdentifier('user'));
     $userCreateStruct->setField('first_name', $firstName);
     $userCreateStruct->setField('last_name', $lastName);
     $user = $this->repository->sudo(function () use($userService, $userCreateStruct) {
         $userGroup = $userService->loadUserGroup('11');
         // guest accounts
         return $userService->createUser($userCreateStruct, array($userGroup));
     });
     return $user;
 }
开发者ID:crevillo,项目名称:ezsocialloginbundle,代码行数:20,代码来源:EzSocialLoginUserManager.php

示例7: newUserGroupCreateStruct

 /**
  * Instantiate a user group create class
  *
  * @param string $mainLanguageCode The main language for the underlying content object
  * @param null|\eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType 5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration
  *
  * @return \eZ\Publish\API\Repository\Values\User\UserGroupCreateStruct
  */
 public function newUserGroupCreateStruct($mainLanguageCode, $contentType = null)
 {
     if ($contentType === null) {
         $contentType = $this->repository->getContentTypeService()->loadContentType($this->settings['userGroupClassID']);
     }
     return new UserGroupCreateStruct(array('contentType' => $contentType, 'mainLanguageCode' => $mainLanguageCode, 'fields' => array()));
 }
开发者ID:masev,项目名称:ezpublish-kernel,代码行数:15,代码来源:UserService.php

示例8: resolveNameSchema

 /**
  * Convenience method for resolving name schema
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param array $fieldMap
  * @param array $languageCodes
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType|null $contentType
  *
  * @return array
  */
 public function resolveNameSchema(Content $content, array $fieldMap = array(), array $languageCodes = array(), ContentType $contentType = null)
 {
     if ($contentType === null) {
         $contentType = $this->repository->getContentTypeService()->loadContentType($content->contentInfo->contentTypeId);
     }
     $languageCodes = $languageCodes ?: $content->versionInfo->languageCodes;
     return $this->resolve($contentType->nameSchema, $contentType, $this->mergeFieldMap($content, $fieldMap, $languageCodes), $languageCodes);
 }
开发者ID:xrowgmbh,项目名称:EzPublishSolrDocsBundle,代码行数:18,代码来源:NameSchemaService.php

示例9: getContentTypeService

 /**
  * Get Content Type Service
  *
  * Get service object to perform operations on Content Type objects and it's aggregate members.
  * ( Group, Field & FieldCategory )
  *
  * @return \eZ\Publish\API\Repository\ContentTypeService
  */
 public function getContentTypeService()
 {
     if ($this->contentTypeService !== null) {
         return $this->contentTypeService;
     }
     $this->contentTypeService = new ContentTypeService($this->repository->getContentTypeService(), $this->signalDispatcher);
     return $this->contentTypeService;
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:16,代码来源:Repository.php

示例10: getContentType

 /**
  * Get ContentType by Content/ContentInfo.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content|\eZ\Publish\API\Repository\Values\Content\ContentInfo $content
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType|null
  */
 private function getContentType(ValueObject $content)
 {
     if ($content instanceof Content) {
         return $this->repository->getContentTypeService()->loadContentType($content->getVersionInfo()->getContentInfo()->contentTypeId);
     } elseif ($content instanceof ContentInfo) {
         return $this->repository->getContentTypeService()->loadContentType($content->contentTypeId);
     }
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:15,代码来源:ContentExtension.php

示例11: getFieldValue

 /**
  * Returns a field value for the given value
  * $version->fields[$fieldDefId][$languageCode] is an equivalent call
  * if no language is given on a translatable field this method returns
  * the value of the initial language of the version if present, otherwise null.
  * On non translatable fields this method ignores the languageCode parameter.
  *
  * @param string $fieldDefIdentifier
  * @param string $languageCode
  *
  * @return mixed a primitive type or a field type Value object depending on the field type.
  */
 public function getFieldValue($fieldDefIdentifier, $languageCode = null)
 {
     $contentType = $this->repository->getContentTypeService()->loadContentType($this->contentTypeId);
     $translatable = $contentType->getFieldDefinition($fieldDefIdentifier)->isTranslatable;
     if (null === $languageCode) {
         $languageCode = $this->getVersionInfo()->getContentInfo()->mainLanguageCode;
     }
     foreach ($this->getFields() as $field) {
         if ($field->fieldDefIdentifier !== $fieldDefIdentifier) {
             continue;
         }
         if ($translatable && $field->languageCode !== $languageCode) {
             continue;
         }
         return $field->value;
     }
     return null;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:30,代码来源:ContentStub.php

示例12: __construct

 public function __construct(Repository $repository, CategoryServiceInterface $categoryService, PostServiceInterface $postService)
 {
     $this->repository = $repository;
     $this->categoryService = $categoryService;
     $this->postService = $postService;
     $this->searchService = $repository->getSearchService();
     $this->contentService = $repository->getContentService();
     $this->locationService = $repository->getLocationService();
     $this->contentTypeService = $repository->getContentTypeService();
     $this->userService = $repository->getUserService();
 }
开发者ID:bdunogier,项目名称:wordpressapibundle,代码行数:11,代码来源:DefaultController.php

示例13: buildRelationDomainObject

 /**
  * Builds API Relation object from provided SPI Relation object
  *
  * @param \eZ\Publish\SPI\Persistence\Content\Relation $spiRelation
  * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $sourceContentInfo
  * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContentInfo
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Relation
  */
 public function buildRelationDomainObject(SPIRelation $spiRelation, ContentInfo $sourceContentInfo, ContentInfo $destinationContentInfo)
 {
     $sourceFieldDefinitionIdentifier = null;
     if ($spiRelation->sourceFieldDefinitionId !== null) {
         /** @var \eZ\Publish\Core\Repository\Values\ContentType\ContentType $contentType */
         $contentType = $this->repository->getContentTypeService()->loadContentType($sourceContentInfo->contentTypeId);
         // Note: getFieldDefinitionById() is not part of API
         $sourceFieldDefinitionIdentifier = $contentType->getFieldDefinitionById($spiRelation->sourceFieldDefinitionId)->identifier;
     }
     return new Relation(array("id" => $spiRelation->id, "sourceFieldDefinitionIdentifier" => $sourceFieldDefinitionIdentifier, "type" => $spiRelation->type, "sourceContentInfo" => $sourceContentInfo, "destinationContentInfo" => $destinationContentInfo));
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:20,代码来源:DomainMapper.php

示例14: createDraft

 /**
  * Uses a content type identifier + a hash of fields values
  * to create and publish a draft below the root location.
  *
  * @param string $contentTypeIdentifier
  * @param array $fields Hash of field def identifier => field value
  *
  * @return Content the created draft.
  */
 public function createDraft($contentTypeIdentifier, array $fields)
 {
     $contentService = $this->repository->getContentService();
     $createStruct = $contentService->newContentCreateStruct($this->repository->getContentTypeService()->loadContentTypeByIdentifier($contentTypeIdentifier), 'eng-GB');
     foreach ($fields as $fieldDefIdentifier => $fieldValue) {
         $createStruct->setField($fieldDefIdentifier, $fieldValue);
     }
     $locationCreateStruct = $this->repository->getLocationService()->newLocationCreateStruct(2);
     $this->currentDraft = $this->repository->sudo(function () use($createStruct, $locationCreateStruct) {
         return $this->repository->getContentService()->createContent($createStruct, [$locationCreateStruct]);
     });
     return $this->currentDraft;
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:22,代码来源:ContentContext.php

示例15: createContent

 /**
  * Helper to quickly create content.
  *
  * @see https://github.com/ezsystems/CookbookBundle/blob/master/Command/CreateContentCommand.php eZ Publish Cookbook
  *
  * Usage:
  * <code>
  * $this->createContent(2, 'folder', 'eng-GB', [
  *     'title' => 'Folder Title',
  * ]);
  * </code>
  *
  * @param int    $parentLocationId
  * @param string $contentTypeIdentifier
  * @param string $languageCode
  * @param array  $fields
  *
  * @throws NotFoundException               If the content type or parent location could not be found
  * @throws ContentFieldValidationException If an invalid field value has been provided
  * @throws ContentValidationException      If a required field is missing or empty
  *
  * @return Content
  */
 protected function createContent($parentLocationId, $contentTypeIdentifier, $languageCode, array $fields)
 {
     $contentService = $this->repository->getContentService();
     $locationService = $this->repository->getLocationService();
     $contentTypeService = $this->repository->getContentTypeService();
     $contentType = $contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
     $contentCreateStruct = $contentService->newContentCreateStruct($contentType, $languageCode);
     foreach ($fields as $key => $value) {
         $contentCreateStruct->setField($key, $value);
     }
     $locationCreateStruct = $locationService->newLocationCreateStruct($parentLocationId);
     $draft = $contentService->createContent($contentCreateStruct, [$locationCreateStruct]);
     $content = $contentService->publishVersion($draft->getVersionInfo());
     return $content;
 }
开发者ID:kreait,项目名称:ezpublish-migrations-bundle,代码行数:38,代码来源:EzPublishMigration.php


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