vendor/ezsystems/ezplatform-kernel/eZ/Bundle/EzPublishCoreBundle/Routing/UrlAliasRouter.php line 14

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