vendor/ezsystems/ezplatform-kernel/eZ/Publish/Core/Repository/SiteAccessAware/URLAliasService.php line 19

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\URLAliasService as URLAliasServiceInterface;
  9. use eZ\Publish\API\Repository\Values\Content\Location;
  10. use eZ\Publish\API\Repository\LanguageResolver;
  11. use eZ\Publish\API\Repository\Values\Content\URLAlias;
  12. /**
  13.  * SiteAccess aware implementation of URLAliasService injecting languages where needed.
  14.  */
  15. class URLAliasService implements URLAliasServiceInterface
  16. {
  17.     /** @var \eZ\Publish\API\Repository\URLAliasService */
  18.     protected $service;
  19.     /** @var \eZ\Publish\API\Repository\LanguageResolver */
  20.     protected $languageResolver;
  21.     /**
  22.      * Construct service object from aggregated service and LanguageResolver.
  23.      *
  24.      * @param \eZ\Publish\API\Repository\URLAliasService $service
  25.      * @param \eZ\Publish\API\Repository\LanguageResolver $languageResolver
  26.      */
  27.     public function __construct(
  28.         URLAliasServiceInterface $service,
  29.         LanguageResolver $languageResolver
  30.     ) {
  31.         $this->service $service;
  32.         $this->languageResolver $languageResolver;
  33.     }
  34.     public function createUrlAlias(
  35.         Location $location,
  36.         string $path,
  37.         string $languageCode,
  38.         bool $forwarding false,
  39.         bool $alwaysAvailable false
  40.     ): URLAlias {
  41.         return $this->service->createUrlAlias($location$path$languageCode$forwarding$alwaysAvailable);
  42.     }
  43.     public function createGlobalUrlAlias(
  44.         string $resource,
  45.         string $path,
  46.         string $languageCode,
  47.         bool $forwarding false,
  48.         bool $alwaysAvailable false
  49.     ): URLAlias {
  50.         return $this->service->createGlobalUrlAlias($resource$path$languageCode$forwarding$alwaysAvailable);
  51.     }
  52.     public function listLocationAliases(
  53.         Location $location,
  54.         bool $custom true,
  55.         ?string $languageCode null,
  56.         ?bool $showAllTranslations null,
  57.         ?array $prioritizedLanguages null
  58.     ): iterable {
  59.         return $this->service->listLocationAliases(
  60.             $location,
  61.             $custom,
  62.             $languageCode,
  63.             $this->languageResolver->getShowAllTranslations($showAllTranslations),
  64.             $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
  65.         );
  66.     }
  67.     public function listGlobalAliases(?string $languageCode nullint $offset 0int $limit = -1): iterable
  68.     {
  69.         return $this->service->listGlobalAliases($languageCode$offset$limit);
  70.     }
  71.     public function removeAliases(array $aliasList): void
  72.     {
  73.         $this->service->removeAliases($aliasList);
  74.     }
  75.     public function lookup(string $url, ?string $languageCode null): URLAlias
  76.     {
  77.         return $this->service->lookup($url$languageCode);
  78.     }
  79.     public function reverseLookup(
  80.         Location $location,
  81.         ?string $languageCode null,
  82.         ?bool $showAllTranslations null,
  83.         ?array $prioritizedLanguages null
  84.     ): URLAlias {
  85.         return $this->service->reverseLookup(
  86.             $location,
  87.             $languageCode,
  88.             $this->languageResolver->getShowAllTranslations($showAllTranslations),
  89.             $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
  90.         );
  91.     }
  92.     public function load(string $id): URLAlias
  93.     {
  94.         return $this->service->load($id);
  95.     }
  96.     public function refreshSystemUrlAliasesForLocation(Location $location): void
  97.     {
  98.         $this->service->refreshSystemUrlAliasesForLocation($location);
  99.     }
  100.     public function deleteCorruptedUrlAliases(): int
  101.     {
  102.         return $this->service->deleteCorruptedUrlAliases();
  103.     }
  104. }