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


PHP Repository::getLocationService方法代码示例

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


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

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

示例2: getController

 /**
  * Detects if there is a custom controller to use to render a Location/Content.
  *
  * @param FilterControllerEvent $event
  *
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  */
 public function getController(FilterControllerEvent $event)
 {
     $request = $event->getRequest();
     // Only taking content related controller (i.e. ez_content:viewLocation or ez_content:viewContent)
     if (strpos($request->attributes->get('_controller'), 'ez_content:') === false) {
         return;
     }
     try {
         if ($request->attributes->has('locationId')) {
             $valueObject = $this->repository->getLocationService()->loadLocation($request->attributes->get('locationId'));
         } elseif ($request->attributes->get('location') instanceof Location) {
             $valueObject = $request->attributes->get('location');
             $request->attributes->set('locationId', $valueObject->id);
         } elseif ($request->attributes->has('contentId')) {
             $valueObject = $this->repository->sudo(function (Repository $repository) use($request) {
                 return $repository->getContentService()->loadContentInfo($request->attributes->get('contentId'));
             });
         } elseif ($request->attributes->get('contentInfo') instanceof ContentInfo) {
             $valueObject = $request->attributes->get('contentInfo');
             $request->attributes->set('contentId', $valueObject->id);
         }
     } catch (UnauthorizedException $e) {
         throw new AccessDeniedException();
     }
     if (!isset($valueObject)) {
         $this->logger->error('Could not resolver a view controller, invalid value object to match.');
         return;
     }
     $controllerReference = $this->controllerManager->getControllerReference($valueObject, $request->attributes->get('viewType'));
     if (!$controllerReference instanceof ControllerReference) {
         return;
     }
     $request->attributes->set('_controller', $controllerReference->controller);
     $event->setController($this->controllerResolver->getController($request));
 }
开发者ID:xcorp1986,项目名称:ezpublish-kernel,代码行数:42,代码来源:ViewControllerListener.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: recover

 /**
  * Recovers the $trashedLocation at its original place if possible.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to recover the trash item at the parent location location
  *
  * If $newParentLocation is provided, $trashedLocation will be restored under it.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\TrashItem $trashItem
  * @param \eZ\Publish\API\Repository\Values\Content\Location $newParentLocation
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Location the newly created or recovered location
  */
 public function recover(APITrashItem $trashItem, Location $newParentLocation = null)
 {
     if (!is_numeric($trashItem->id)) {
         throw new InvalidArgumentValue("id", $trashItem->id, "TrashItem");
     }
     if ($newParentLocation === null && !is_numeric($trashItem->parentLocationId)) {
         throw new InvalidArgumentValue("parentLocationId", $trashItem->parentLocationId, "TrashItem");
     }
     if ($newParentLocation !== null && !is_numeric($newParentLocation->id)) {
         throw new InvalidArgumentValue("parentLocationId", $newParentLocation->id, "Location");
     }
     if ($this->repository->hasAccess('content', 'restore') !== true) {
         throw new UnauthorizedException('content', 'restore');
     }
     $this->repository->beginTransaction();
     try {
         $newParentLocationId = $newParentLocation ? $newParentLocation->id : $trashItem->parentLocationId;
         $newLocationId = $this->persistenceHandler->trashHandler()->recover($trashItem->id, $newParentLocationId);
         $content = $this->repository->getContentService()->loadContent($trashItem->contentId);
         $urlAliasNames = $this->nameSchemaService->resolveUrlAliasSchema($content);
         // Publish URL aliases for recovered location
         foreach ($urlAliasNames as $languageCode => $name) {
             $this->persistenceHandler->urlAliasHandler()->publishUrlAliasForLocation($newLocationId, $newParentLocationId, $name, $languageCode, $content->contentInfo->alwaysAvailable);
         }
         $this->repository->commit();
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
     return $this->repository->getLocationService()->loadLocation($newLocationId);
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:43,代码来源:TrashService.php

示例6: appendFieldRelations

 /**
  * Appends destination Content ids of given $fieldValue to the $relation array.
  *
  * If $fieldValue contains Location ids, the will be converted to the Content id that Location encapsulates.
  *
  * @param array $relations
  * @param array $locationIdToContentIdMapping An array with Location Ids as keys and corresponding Content Id as values
  * @param \eZ\Publish\SPI\FieldType\FieldType $fieldType
  * @param \eZ\Publish\Core\FieldType\Value $fieldValue Accepted field value.
  * @param string $fieldDefinitionId
  *
  * @return void
  */
 public function appendFieldRelations(array &$relations, array &$locationIdToContentIdMapping, SPIFieldType $fieldType, BaseValue $fieldValue, $fieldDefinitionId)
 {
     foreach ($fieldType->getRelations($fieldValue) as $relationType => $destinationIds) {
         if ($relationType === Relation::FIELD) {
             if (!isset($relations[$relationType][$fieldDefinitionId])) {
                 $relations[$relationType][$fieldDefinitionId] = array();
             }
             $relations[$relationType][$fieldDefinitionId] += array_flip($destinationIds);
         } else {
             if ($relationType & (Relation::LINK | Relation::EMBED)) {
                 if (!isset($relations[$relationType])) {
                     $relations[$relationType] = array();
                 }
                 if (isset($destinationIds["locationIds"])) {
                     foreach ($destinationIds["locationIds"] as $locationId) {
                         if (!isset($locationIdToContentIdMapping[$locationId])) {
                             $location = $this->repository->getLocationService()->loadLocation($locationId);
                             $locationIdToContentIdMapping[$locationId] = $location->contentId;
                         }
                         $relations[$relationType][$locationIdToContentIdMapping[$locationId]] = true;
                     }
                 }
                 if (isset($destinationIds["contentIds"])) {
                     $relations[$relationType] += array_flip($destinationIds["contentIds"]);
                 }
             }
         }
     }
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:42,代码来源:RelationProcessor.php

示例7: buildSPILocationCreateStruct

 /**
  * Creates an array of SPI location create structs from given array of API location create structs
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
  *
  * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $locationCreateStruct
  * @param \eZ\Publish\API\Repository\Values\Content\Location $parentLocation
  * @param mixed $mainLocation
  * @param mixed $contentId
  * @param mixed $contentVersionNo
  *
  * @return \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct
  */
 public function buildSPILocationCreateStruct($locationCreateStruct, APILocation $parentLocation, $mainLocation, $contentId, $contentVersionNo)
 {
     if ($locationCreateStruct->priority !== null && !is_int($locationCreateStruct->priority)) {
         throw new InvalidArgumentValue("priority", $locationCreateStruct->priority, "LocationCreateStruct");
     }
     if (!is_bool($locationCreateStruct->hidden)) {
         throw new InvalidArgumentValue("hidden", $locationCreateStruct->hidden, "LocationCreateStruct");
     }
     if ($locationCreateStruct->remoteId !== null && (!is_string($locationCreateStruct->remoteId) || empty($locationCreateStruct->remoteId))) {
         throw new InvalidArgumentValue("remoteId", $locationCreateStruct->remoteId, "LocationCreateStruct");
     }
     if ($locationCreateStruct->sortField !== null && !$this->isValidLocationSortField($locationCreateStruct->sortField)) {
         throw new InvalidArgumentValue("sortField", $locationCreateStruct->sortField, "LocationCreateStruct");
     }
     if ($locationCreateStruct->sortOrder !== null && !$this->isValidLocationSortOrder($locationCreateStruct->sortOrder)) {
         throw new InvalidArgumentValue("sortOrder", $locationCreateStruct->sortOrder, "LocationCreateStruct");
     }
     $remoteId = $locationCreateStruct->remoteId;
     if (null === $remoteId) {
         $remoteId = $this->getUniqueHash($locationCreateStruct);
     } else {
         try {
             $this->repository->getLocationService()->loadLocationByRemoteId($remoteId);
             throw new InvalidArgumentException("\$locationCreateStructs", "Another Location with remoteId '{$remoteId}' exists");
         } catch (NotFoundException $e) {
             // Do nothing
         }
     }
     return new SPILocationCreateStruct(array("priority" => $locationCreateStruct->priority, "hidden" => $locationCreateStruct->hidden, "invisible" => $locationCreateStruct->hidden === true || $parentLocation->invisible, "remoteId" => $remoteId, "contentId" => $contentId, "contentVersion" => $contentVersionNo, "pathIdentificationString" => null, "mainLocationId" => $mainLocation, "sortField" => $locationCreateStruct->sortField !== null ? $locationCreateStruct->sortField : Location::SORT_FIELD_NAME, "sortOrder" => $locationCreateStruct->sortOrder !== null ? $locationCreateStruct->sortOrder : Location::SORT_ORDER_ASC, "parentId" => $locationCreateStruct->parentLocationId));
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:43,代码来源:DomainMapper.php

示例8: createGlobalUrlAlias

 /**
  * Create a user chosen $alias pointing to a resource in $languageCode.
  *
  * This method does not handle location resources - if a user enters a location target
  * the createCustomUrlAlias method has to be used.
  * This method runs URL filters and and transformers before storing them.
  * Hence the path returned in the URLAlias Value may differ from the given.
  *
  * $alwaysAvailable makes the alias available in all languages.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the path already exists for the given
  *         language or if resource is not valid
  *
  * @param string $resource
  * @param string $path
  * @param string $languageCode
  * @param bool $forwarding
  * @param bool $alwaysAvailable
  *
  * @return \eZ\Publish\API\Repository\Values\Content\URLAlias
  */
 public function createGlobalUrlAlias($resource, $path, $languageCode, $forwarding = false, $alwaysAvailable = false)
 {
     if (!preg_match('#^([a-zA-Z0-9_]+):(.+)$#', $resource, $matches)) {
         throw new InvalidArgumentException('$resource', 'argument is not valid');
     }
     $path = $this->cleanUrl($path);
     if ($matches[1] === 'eznode' || 0 === strpos($resource, 'module:content/view/full/')) {
         if ($matches[1] === 'eznode') {
             $locationId = $matches[2];
         } else {
             $resourcePath = explode('/', $matches[2]);
             $locationId = end($resourcePath);
         }
         return $this->createUrlAlias($this->repository->getLocationService()->loadLocation($locationId), $path, $languageCode, $forwarding, $alwaysAvailable);
     }
     $this->repository->beginTransaction();
     try {
         $spiUrlAlias = $this->urlAliasHandler->createGlobalUrlAlias($matches[1] . ':' . $this->cleanUrl($matches[2]), $path, $forwarding, $languageCode, $alwaysAvailable);
         $this->repository->commit();
     } catch (ForbiddenException $e) {
         $this->repository->rollback();
         throw new InvalidArgumentException('$path', $e->getMessage(), $e);
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
     return $this->buildUrlAliasDomainObject($spiUrlAlias, $path);
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:49,代码来源:URLAliasService.php

示例9: getLocationService

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

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

示例11: buildDomainUserGroupObject

 /**
  * Builds the domain UserGroup object from provided Content object
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  *
  * @return \eZ\Publish\API\Repository\Values\User\UserGroup
  */
 protected function buildDomainUserGroupObject(APIContent $content)
 {
     $locationService = $this->repository->getLocationService();
     $subGroupCount = 0;
     if ($content->getVersionInfo()->getContentInfo()->mainLocationId !== null) {
         $mainLocation = $locationService->loadLocation($content->getVersionInfo()->getContentInfo()->mainLocationId);
         $parentLocation = $locationService->loadLocation($mainLocation->parentLocationId);
         $subGroups = $this->searchSubGroups($mainLocation->id, null, Location::SORT_ORDER_ASC, 0, 0);
         $subGroupCount = $subGroups->totalCount;
     }
     return new UserGroup(array('content' => $content, 'parentId' => isset($parentLocation) ? $parentLocation->contentId : null, 'subGroupCount' => $subGroupCount));
 }
开发者ID:masev,项目名称:ezpublish-kernel,代码行数:19,代码来源:UserService.php

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

示例13: testManifestRun

 public function testManifestRun()
 {
     // design/plainsite location id
     $parentLocationId = 56;
     $completed = false;
     $location = static::$repository->getLocationService()->loadLocation($parentLocationId);
     $children = static::$repository->getLocationService()->loadLocationChildren($location);
     $this->assertLessThan(4, $children->totalCount);
     $manifest = new GoogleNewsToEzPlatformContentManifest(static::$repository, array('url' => 'https://news.google.com/news?cf=all&hl=en&ned=us&topic=t&output=rss', 'location_id' => $parentLocationId));
     $this->assertInstanceOf(EventDrivenProcessor::class, $manifest->getProcessor());
     $manifest->getProcessor()->addListener(TransferEvents::POST_PROCEDURE, function () use(&$completed) {
         $completed = true;
     });
     $manifest->configureProcessor($manifest->getProcessor());
     $runner = new ManifestRunner($manifest);
     $runner->run($manifest);
     $this->assertTrue($completed);
     $this->assertEquals('googlenews_to_ezplatform_content', $manifest->getName());
     $location = static::$repository->getLocationService()->loadLocation($parentLocationId);
     $children = static::$repository->getLocationService()->loadLocationChildren($location);
     $this->assertGreaterThan(4, $children->totalCount);
 }
开发者ID:htollefsen,项目名称:examples,代码行数:22,代码来源:GoogleNewsToEzContentManifestTest.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: renderLocation

 /**
  *  render a viewtemplate with a twigfunction uses the ezpulish  override.yml
  *
  *     {{ cjw_render_location( {'locationId': locationObject.id, 'viewType': 'line'} ) }}
  *
  *     => faster is the following call
  *
  *     {{ cjw_render_location( {'location': locationObject, 'viewType': 'line'} ) }}
  *
  * @param array  $parameters  hash
  *
  * @return string
  */
 public function renderLocation(array $params)
 {
     $viewType = $params['viewType'];
     if (isset($params['location']) && $params['location'] instanceof Location) {
         $location = $params['location'];
         $locationId = $location->id;
     } elseif (isset($params['locationId'])) {
         $locationId = $params['locationId'];
         $location = $this->repository->getLocationService()->loadLocation($locationId);
         if ($location->invisible) {
             throw new NotFoundHttpException("Location #{$locationId} cannot be displayed as it is flagged as invisible.");
         }
     } else {
         // TODO Fehler wenn locationId nicht gesetzt oder location keine Location objekt
         return false;
     }
     $templateFileName = 'CjwPublishToolsBundle::line.html.twig';
     $this->template = $this->environment->loadTemplate($templateFileName);
     $locationObject = $this->repository->getLocationService()->loadLocation($locationId);
     $contentId = $locationObject->contentInfo->id;
     $contentObject = $this->repository->getContentService()->loadContent($contentId);
     // $view = 'CjwPublishToolsBundle::line.html.twig';
     // find override template
     $template = $this->getOverrideTemplate($locationObject, $contentObject, $viewType);
     //var_dump( $template );
     $params['location'] = $locationObject;
     $params['content'] = $contentObject;
     // name of the rendered template
     $params['_template'] = $template;
     // loop params array, and set as tpl var
     if (isset($params['params'])) {
         foreach ($params['params'] as $param => $value) {
             $params[$param] = $value;
         }
     }
     $temapleRenderedContent = $this->getTemplateEngine()->render($template, $params);
     // TODO  wenn templatedebug eingeschaltet ist dieses anzeigen
     if ($this->templateDebug == true) {
         $temapleContentDebug = "\n<!-- cjw_render_location: LocationId: {$locationId}, viewType: {$viewType}, Template: {$template} -->\n";
         $temapleRenderedContent = $temapleContentDebug . "\n" . $temapleRenderedContent;
     }
     return $temapleRenderedContent;
 }
开发者ID:intermundiasolutions,项目名称:CjwPublishToolsBundle,代码行数:56,代码来源:TwigContentFunctionsService.php


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