vendor/ezsystems/ezplatform-kernel/eZ/Publish/Core/Repository/SiteAccessAware/LocationService.php line 26

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. declare(strict_types=1);
  7. namespace eZ\Publish\Core\Repository\SiteAccessAware;
  8. use eZ\Publish\API\Repository\LocationService as LocationServiceInterface;
  9. use eZ\Publish\API\Repository\Values\Content\Location;
  10. use eZ\Publish\API\Repository\Values\Content\ContentInfo;
  11. use eZ\Publish\API\Repository\Values\Content\LocationList;
  12. use eZ\Publish\API\Repository\Values\Content\VersionInfo;
  13. use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
  14. use eZ\Publish\API\Repository\Values\Content\LocationUpdateStruct;
  15. use eZ\Publish\API\Repository\LanguageResolver;
  16. use eZ\Publish\API\Repository\Values\Filter\Filter;
  17. /**
  18.  * LocationService for SiteAccessAware layer.
  19.  *
  20.  * Currently does nothing but hand over calls to aggregated service.
  21.  */
  22. class LocationService implements LocationServiceInterface
  23. {
  24.     /** @var \eZ\Publish\API\Repository\LocationService */
  25.     protected $service;
  26.     /** @var \eZ\Publish\API\Repository\LanguageResolver */
  27.     protected $languageResolver;
  28.     /**
  29.      * Construct service object from aggregated service and LanguageResolver.
  30.      *
  31.      * @param \eZ\Publish\API\Repository\LocationService $service
  32.      * @param \eZ\Publish\API\Repository\LanguageResolver $languageResolver
  33.      */
  34.     public function __construct(
  35.         LocationServiceInterface $service,
  36.         LanguageResolver $languageResolver
  37.     ) {
  38.         $this->service $service;
  39.         $this->languageResolver $languageResolver;
  40.     }
  41.     public function copySubtree(Location $subtreeLocation $targetParentLocation): Location
  42.     {
  43.         return $this->service->copySubtree($subtree$targetParentLocation);
  44.     }
  45.     public function loadLocation(int $locationId, ?array $prioritizedLanguages null, ?bool $useAlwaysAvailable null): Location
  46.     {
  47.         return $this->service->loadLocation(
  48.             $locationId,
  49.             $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages),
  50.             $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
  51.         );
  52.     }
  53.     public function loadLocationList(array $locationIds, ?array $prioritizedLanguages null, ?bool $useAlwaysAvailable null): iterable
  54.     {
  55.         return $this->service->loadLocationList(
  56.             $locationIds,
  57.             $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages),
  58.             $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
  59.         );
  60.     }
  61.     public function loadLocationByRemoteId(string $remoteId, ?array $prioritizedLanguages null, ?bool $useAlwaysAvailable null): Location
  62.     {
  63.         return $this->service->loadLocationByRemoteId(
  64.             $remoteId,
  65.             $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages),
  66.             $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
  67.         );
  68.     }
  69.     public function loadLocations(ContentInfo $contentInfo, ?Location $rootLocation null, ?array $prioritizedLanguages null): iterable
  70.     {
  71.         return $this->service->loadLocations(
  72.             $contentInfo,
  73.             $rootLocation,
  74.             $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
  75.         );
  76.     }
  77.     public function loadLocationChildren(Location $locationint $offset 0int $limit 25, ?array $prioritizedLanguages null): LocationList
  78.     {
  79.         return $this->service->loadLocationChildren(
  80.             $location,
  81.             $offset,
  82.             $limit,
  83.             $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
  84.         );
  85.     }
  86.     public function loadParentLocationsForDraftContent(VersionInfo $versionInfo, ?array $prioritizedLanguages null): iterable
  87.     {
  88.         return $this->service->loadParentLocationsForDraftContent(
  89.             $versionInfo,
  90.             $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
  91.         );
  92.     }
  93.     public function getLocationChildCount(Location $location): int
  94.     {
  95.         return $this->service->getLocationChildCount($location);
  96.     }
  97.     public function createLocation(ContentInfo $contentInfoLocationCreateStruct $locationCreateStruct): Location
  98.     {
  99.         return $this->service->createLocation($contentInfo$locationCreateStruct);
  100.     }
  101.     public function updateLocation(Location $locationLocationUpdateStruct $locationUpdateStruct): Location
  102.     {
  103.         return $this->service->updateLocation($location$locationUpdateStruct);
  104.     }
  105.     public function swapLocation(Location $location1Location $location2): void
  106.     {
  107.         $this->service->swapLocation($location1$location2);
  108.     }
  109.     public function hideLocation(Location $location): Location
  110.     {
  111.         return $this->service->hideLocation($location);
  112.     }
  113.     public function unhideLocation(Location $location): Location
  114.     {
  115.         return $this->service->unhideLocation($location);
  116.     }
  117.     public function moveSubtree(Location $locationLocation $newParentLocation): void
  118.     {
  119.         $this->service->moveSubtree($location$newParentLocation);
  120.     }
  121.     public function deleteLocation(Location $location): void
  122.     {
  123.         $this->service->deleteLocation($location);
  124.     }
  125.     public function newLocationCreateStruct(int $parentLocationId): LocationCreateStruct
  126.     {
  127.         return $this->service->newLocationCreateStruct($parentLocationId);
  128.     }
  129.     public function newLocationUpdateStruct(): LocationUpdateStruct
  130.     {
  131.         return $this->service->newLocationUpdateStruct();
  132.     }
  133.     /**
  134.      * Get the total number of all existing Locations. Can be combined with loadAllLocations.
  135.      *
  136.      * @see loadAllLocations
  137.      *
  138.      * @return int Total number of Locations
  139.      */
  140.     public function getAllLocationsCount(): int
  141.     {
  142.         return $this->service->getAllLocationsCount();
  143.     }
  144.     /**
  145.      * Bulk-load all existing Locations, constrained by $limit and $offset to paginate results.
  146.      *
  147.      * @param int $limit
  148.      * @param int $offset
  149.      *
  150.      * @return \eZ\Publish\API\Repository\Values\Content\Location[]
  151.      */
  152.     public function loadAllLocations(int $offset 0int $limit 25): array
  153.     {
  154.         return $this->service->loadAllLocations($offset$limit);
  155.     }
  156.     public function find(Filter $filter, ?array $languages null): LocationList
  157.     {
  158.         return $this->service->find(
  159.             $filter,
  160.             $this->languageResolver->getPrioritizedLanguages($languages)
  161.         );
  162.     }
  163. }