src/Controller/MainController.php line 28

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. class MainController extends AbstractController
  7. {
  8.     /**
  9.      * The front door.
  10.      *
  11.      * This used to be a leftover from an unrelated car-service project: it
  12.      * queried App\Entity\AutoService, About, Banner and Car — none of which
  13.      * exist here — and passed undefined $work/$step variables into a template
  14.      * that has since become the map. Every request to "/" answered with a
  15.      * 500, which also broke signing in, because the login form redirects to
  16.      * page_home on success.
  17.      *
  18.      * The map is the product, so the home page now simply goes there. Replace
  19.      * this with a real landing page when there is one to show.
  20.      *
  21.      * Drivers, though, have their own app — they sign in to work, not to browse
  22.      * — so a ROLE_DRIVER user is sent straight there.
  23.      */
  24.     #[Route('/{_locale}'name'page_home'requirements: ['_locale' => 'ru|hy'], defaults: ['_locale' => 'hy'])]
  25.     public function index(): RedirectResponse
  26.     {
  27.         if ($this->isGranted('ROLE_DRIVER')) {
  28.             return $this->redirectToRoute('driver_app');
  29.         }
  30.         return $this->redirectToRoute('app_map');
  31.     }
  32. }