vendor/ibexa/core/src/bundle/Core/Routing/UrlAliasRouter.php line 53

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. namespace Ibexa\Bundle\Core\Routing;
  7. use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
  8. use Ibexa\Core\MVC\Symfony\Routing\UrlAliasRouter as BaseUrlAliasRouter;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\Routing\Exception\ResourceNotFoundException;
  11. class UrlAliasRouter extends BaseUrlAliasRouter
  12. {
  13.     /** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */
  14.     protected $configResolver;
  15.     public function setConfigResolver(ConfigResolverInterface $configResolver)
  16.     {
  17.         $this->configResolver $configResolver;
  18.     }
  19.     public function matchRequest(Request $request)
  20.     {
  21.         // UrlAliasRouter might be disabled from configuration.
  22.         // An example is for running the admin interface: it needs to be entirely run through the legacy kernel.
  23.         if ($this->configResolver->getParameter('url_alias_router') === false) {
  24.             throw new ResourceNotFoundException('Config requires bypassing UrlAliasRouter');
  25.         }
  26.         return parent::matchRequest($request);
  27.     }
  28.     /**
  29.      * Will return the right UrlAlias in regards to configured root location.
  30.      *
  31.      * @param string $pathinfo
  32.      *
  33.      * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException if the path does not exist or is not valid for the given language
  34.      *
  35.      * @return \Ibexa\Contracts\Core\Repository\Values\Content\URLAlias
  36.      */
  37.     protected function getUrlAlias($pathinfo)
  38.     {
  39.         $pathPrefix $this->generator->getPathPrefixByRootLocationId($this->rootLocationId);
  40.         if (
  41.             $this->rootLocationId === null ||
  42.             $this->generator->isUriPrefixExcluded($pathinfo) ||
  43.             $pathPrefix === '/'
  44.         ) {
  45.             return parent::getUrlAlias($pathinfo);
  46.         }
  47.         return $this->urlAliasService->lookup($pathPrefix $pathinfo);
  48.     }
  49. }
  50. class_alias(UrlAliasRouter::class, 'eZ\Bundle\EzPublishCoreBundle\Routing\UrlAliasRouter');