src/AppBundle/Service/Routing/AppRouteLoader.php line 26

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Service\Routing;
  3. use Symfony\Component\Config\Loader\LoaderInterface;
  4. use Symfony\Component\Routing\RouteCollection;
  5. use Symfony\Component\Routing\RouteCollectionBuilder;
  6. use Symfony\Bundle\FrameworkBundle\Routing\RouteLoaderInterface;
  7. class AppRouteLoader implements RouteLoaderInterface
  8. {
  9.     private const CONFIG_EXTS '.{php,xml,yaml,yml}';
  10.     private string $projectDir;
  11.     private string $environment;
  12.     public function __construct(string $projectDirstring $environment)
  13.     {
  14.         $this->projectDir $projectDir;
  15.         $this->environment $environment;
  16.     }
  17.     /**
  18.      * @internal
  19.      */
  20.     public function loadRoutes(LoaderInterface $loader): RouteCollection
  21.     {
  22.         $routes = new RouteCollectionBuilder($loader);
  23.         $this->configureRoutes($routes);
  24.         return $routes->build();
  25.     }
  26.     protected function configureRoutes(RouteCollectionBuilder $routes): void
  27.     {
  28.         $confDir $this->projectDir.'/app/config';
  29.         $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS'/''glob');
  30.         $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS'/''glob');
  31.         $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS'/''glob');
  32.     }
  33. }