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

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\Exception\RouteNotFoundException;
  14. use Symfony\Component\Routing\Route;
  15. use Symfony\Component\Routing\RouteCollection;
  16. class LegacyRouteProvider implements RouteProviderInterface
  17. {
  18.     private FrontendLoader $frontendLoader;
  19.     /**
  20.      * @internal
  21.      */
  22.     public function __construct(FrontendLoader $frontendLoader)
  23.     {
  24.         $this->frontendLoader $frontendLoader;
  25.     }
  26.     public function getRouteCollectionForRequest(Request $request): RouteCollection
  27.     {
  28.         return new RouteCollection();
  29.     }
  30.     public function getRoutesByNames($names): array
  31.     {
  32.         return [];
  33.     }
  34.     public function getRouteByName($name): Route
  35.     {
  36.         $route $this->loadRoute((string) $name);
  37.         trigger_deprecation('contao/core-bundle''4.10'sprintf('The "%s" route has been deprecated and is only available in legacy routing mode.'$name));
  38.         return $route;
  39.     }
  40.     private function loadRoute(string $name): Route
  41.     {
  42.         if ('contao_frontend' === $name || 'contao_index' === $name) {
  43.             return $this->frontendLoader->load('.''contao_frontend')->get($name);
  44.         }
  45.         if ('contao_root' === $name) {
  46.             return new Route(
  47.                 '/',
  48.                 [
  49.                     '_scope' => 'frontend',
  50.                     '_token_check' => true,
  51.                     '_controller' => 'Contao\CoreBundle\Controller\FrontendController::indexAction',
  52.                 ]
  53.             );
  54.         }
  55.         if ('contao_catch_all' === $name) {
  56.             return new Route(
  57.                 '/{_url_fragment}',
  58.                 [
  59.                     '_scope' => 'frontend',
  60.                     '_token_check' => true,
  61.                     '_controller' => 'Contao\CoreBundle\Controller\FrontendController::indexAction',
  62.                 ],
  63.                 ['_url_fragment' => '.*']
  64.             );
  65.         }
  66.         throw new RouteNotFoundException('No route for '.$name);
  67.     }
  68. }