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


PHP Repository::getContentService方法代码示例

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


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

示例1: getContent

 /**
  * @return \eZ\Publish\API\Repository\Values\Content\Content
  */
 public function getContent()
 {
     if ($this->content == null) {
         $this->content = $this->repository->getContentService()->loadContent($this->location->contentId);
     }
     return $this->content;
 }
开发者ID:truffo,项目名称:ez-content-decorator-bundle,代码行数:10,代码来源:ContentDecorator.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: convert

 /**
  * Converts eZ Publish legacy objects and nodes to content and locations
  *
  * @param mixed $object
  *
  * @return mixed
  */
 public function convert($object)
 {
     if ($object instanceof eZContentObject) {
         return $this->repository->getContentService()->loadContent($object->attribute('id'));
     } else {
         if ($object instanceof eZContentObjectTreeNode) {
             return $this->repository->getLocationService()->loadLocation($object->attribute('node_id'));
         }
     }
     return $object;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:18,代码来源:ngsymfonytoolsapicontentconverter.php

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

示例5: getFieldRelations

 /**
  * Returns field relations data for the current version of the given $contentInfo.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  *
  * @return mixed
  */
 public function getFieldRelations(ContentInfo $contentInfo)
 {
     $relations = array();
     $locationIdToContentIdMapping = array();
     $content = $this->repository->getContentService()->loadContentByContentInfo($contentInfo);
     foreach ($content->getFields() as $field) {
         $fieldDefinition = $content->contentType->getFieldDefinition($field->fieldDefIdentifier);
         $fieldType = $this->repository->getFieldTypeService()->buildFieldType($fieldDefinition->fieldTypeIdentifier);
         $this->appendFieldRelations($relations, $locationIdToContentIdMapping, $fieldType, $fieldType->acceptValue($field->value), $fieldDefinition->id);
     }
     return $relations;
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:19,代码来源:RelationProcessor.php

示例6: buildDomainUserObject

 /**
  * Builds the domain user object from provided persistence user object
  *
  * @param \eZ\Publish\SPI\Persistence\User $spiUser
  * @param \eZ\Publish\API\Repository\Values\Content\Content|null $content
  *
  * @return \eZ\Publish\API\Repository\Values\User\User
  */
 protected function buildDomainUserObject(SPIUser $spiUser, APIContent $content = null)
 {
     if ($content === null) {
         $content = $this->repository->getContentService()->internalLoadContent($spiUser->id);
     }
     return new User(array('content' => $content, 'login' => $spiUser->login, 'email' => $spiUser->email, 'passwordHash' => $spiUser->passwordHash, 'hashAlgorithm' => (int) $spiUser->hashAlgorithm, 'enabled' => $spiUser->isEnabled, 'maxLogin' => (int) $spiUser->maxLogin));
 }
开发者ID:masev,项目名称:ezpublish-kernel,代码行数:15,代码来源:UserService.php

示例7: getContentService

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

示例8: buildLocationDomainObject

 /**
  * Builds domain location object from provided persistence location
  *
  * @param \eZ\Publish\SPI\Persistence\Content\Location $spiLocation
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Location
  */
 public function buildLocationDomainObject(SPILocation $spiLocation)
 {
     // TODO: this is hardcoded workaround for missing ContentInfo on root location
     if ($spiLocation->id == 1) {
         $contentInfo = new ContentInfo(array('id' => 0, 'name' => 'Top Level Nodes', 'sectionId' => 1, 'mainLocationId' => 1, 'contentTypeId' => 1));
     } else {
         $contentInfo = $this->repository->getContentService()->internalLoadContentInfo($spiLocation->contentId);
     }
     return new Location(array('contentInfo' => $contentInfo, 'id' => $spiLocation->id, 'priority' => $spiLocation->priority, 'hidden' => $spiLocation->hidden, 'invisible' => $spiLocation->invisible, 'remoteId' => $spiLocation->remoteId, 'parentLocationId' => $spiLocation->parentId, 'pathString' => $spiLocation->pathString, 'depth' => $spiLocation->depth, 'sortField' => $spiLocation->sortField, 'sortOrder' => $spiLocation->sortOrder));
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:17,代码来源:DomainMapper.php

示例9: renderLocation

 /**
  * Renders $location by selecting the right template for $viewType.
  * $content and $location will be injected in the selected template.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @param string $viewType Variation of display for your content. Default is 'full'.
  * @param array $parameters Parameters to pass to the template called to
  *        render the view. By default, it's empty. 'location' and 'content'
  *        entries are reserved for the Location (and its Content) that is
  *        viewed.
  *
  * @throws \RuntimeException
  *
  * @return string
  */
 public function renderLocation(Location $location, $viewType = ViewManagerInterface::VIEW_TYPE_FULL, $parameters = array())
 {
     if (!isset($parameters['location'])) {
         $parameters['location'] = $location;
     }
     if (!isset($parameters['content'])) {
         $parameters['content'] = $this->repository->getContentService()->loadContentByContentInfo($location->contentInfo, $this->configResolver->getParameter('languages'));
     }
     return $this->renderContent($parameters['content'], $viewType, $parameters);
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:25,代码来源:Manager.php

示例10: buildLocationDomainObject

 /**
  * Builds domain location object from provided persistence location
  *
  * @param \eZ\Publish\SPI\Persistence\Content\Location $spiLocation
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Location
  */
 public function buildLocationDomainObject(SPILocation $spiLocation)
 {
     // TODO: this is hardcoded workaround for missing ContentInfo on root location
     if ($spiLocation->id == 1) {
         $contentInfo = new ContentInfo(array('id' => 57, 'name' => 'Home', 'sectionId' => 1, 'mainLocationId' => 1, 'currentVersionNo' => 1, 'contentTypeId' => 1, 'published' => true, 'ownerId' => 14, 'alwaysAvailable' => true, 'remoteId' => "8a9c9c761004866fb458d89910f52bee", 'mainLanguageCode' => "ger-DE"));
     } else {
         $contentInfo = $this->repository->getContentService()->internalLoadContentInfo($spiLocation->contentId);
     }
     return new Location(array('contentInfo' => $contentInfo, 'id' => $spiLocation->id, 'priority' => $spiLocation->priority, 'hidden' => $spiLocation->hidden, 'invisible' => $spiLocation->invisible, 'remoteId' => $spiLocation->remoteId, 'parentLocationId' => $spiLocation->parentId, 'pathString' => $spiLocation->pathString, 'depth' => $spiLocation->depth, 'sortField' => $spiLocation->sortField, 'sortOrder' => $spiLocation->sortOrder));
 }
开发者ID:xrowgmbh,项目名称:EzPublishSolrDocsBundle,代码行数:17,代码来源:DomainMapper.php

示例11: renderLocation

 /**
  * Renders $location by selecting the right template for $viewType.
  * $content and $location will be injected in the selected template.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @param string $viewType Variation of display for your content. Default is 'full'.
  * @param array $parameters Parameters to pass to the template called to
  *        render the view. By default, it's empty. 'location' and 'content'
  *        entries are reserved for the Location (and its Content) that is
  *        viewed.
  * @throws \RuntimeException
  *
  * @return string
  */
 public function renderLocation(Location $location, $viewType = ViewManagerInterface::VIEW_TYPE_FULL, $parameters = array())
 {
     foreach ($this->getAllLocationViewProviders() as $viewProvider) {
         $view = $viewProvider->getView($location, $viewType);
         if ($view instanceof ContentViewInterface) {
             $parameters['location'] = $location;
             return $this->renderContentView($view, $parameters + array('content' => $this->repository->getContentService()->loadContentByContentInfo($location->getContentInfo(), $this->configResolver->getParameter('languages'))));
         }
     }
     throw new RuntimeException("Unable to find a view for location #{$location->id}");
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:25,代码来源:Manager.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: 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

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

示例15: assignSection

 /**
  * Assigns the content to the given section
  * this method overrides the current assigned section
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If user does not have access to view provided object
  *
  * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  * @param \eZ\Publish\API\Repository\Values\Content\Section $section
  */
 public function assignSection(ContentInfo $contentInfo, Section $section)
 {
     $loadedContentInfo = $this->repository->getContentService()->loadContentInfo($contentInfo->id);
     $loadedSection = $this->loadSection($section->id);
     if ($this->repository->canUser('section', 'assign', $loadedContentInfo, $loadedSection) !== true) {
         throw new UnauthorizedException('section', 'assign', array('name' => $loadedSection->name, 'content-name' => $loadedContentInfo->name));
     }
     $this->repository->beginTransaction();
     try {
         $this->sectionHandler->assign($loadedSection->id, $loadedContentInfo->id);
         $this->repository->commit();
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:25,代码来源:SectionService.php


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