vendor/contao/core-bundle/src/Routing/LegacyRouteProvider.php line 41

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of Contao.
  5.  *
  6.  * (c) Leo Feyer
  7.  *
  8.  * @license LGPL-3.0-or-later
  9.  */
  10. namespace Contao\CoreBundle\Routing;
  11. use Symfony\Cmf\Component\Routing\RouteProviderInterface;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\Routing\Route;
  14. use Symfony\Component\Routing\RouteCollection;
  15. class LegacyRouteProvider implements RouteProviderInterface
  16. {
  17.     /**
  18.      * @var FrontendLoader
  19.      */
  20.     private $frontendLoader;
  21.     /**
  22.      * @var RouteProviderInterface
  23.      */
  24.     private $routeProvider;
  25.     /**
  26.      * @internal Do not inherit from this class; decorate the "contao.routing.legacy_route_provider" service instead
  27.      */
  28.     public function __construct(FrontendLoader $frontendLoaderRouteProviderInterface $routeProvider)
  29.     {
  30.         $this->frontendLoader $frontendLoader;
  31.         $this->routeProvider $routeProvider;
  32.     }
  33.     public function getRouteCollectionForRequest(Request $request): RouteCollection
  34.     {
  35.         return $this->routeProvider->getRouteCollectionForRequest($request);
  36.     }
  37.     public function getRouteByName($name): Route
  38.     {
  39.         if ('contao_frontend' === $name || 'contao_index' === $name) {
  40.             return $this->frontendLoader->load('.''contao_frontend')->get($name);
  41.         }
  42.         if ('contao_root' === $name) {
  43.             return new Route(
  44.                 '/',
  45.                 [
  46.                     '_scope' => 'frontend',
  47.                     '_token_check' => true,
  48.                     '_controller' => 'Contao\CoreBundle\Controller\FrontendController::indexAction',
  49.                 ]
  50.             );
  51.         }
  52.         if ('contao_catch_all' === $name) {
  53.             return new Route(
  54.                 '/{_url_fragment}',
  55.                 [
  56.                     '_scope' => 'frontend',
  57.                     '_token_check' => true,
  58.                     '_controller' => 'Contao\CoreBundle\Controller\FrontendController::indexAction',
  59.                 ],
  60.                 ['_url_fragment' => '.*']
  61.             );
  62.         }
  63.         return $this->routeProvider->getRouteByName($name);
  64.     }
  65.     public function getRoutesByNames($names): array
  66.     {
  67.         return $this->routeProvider->getRoutesByNames($names);
  68.     }
  69. }