src/Controller/ConnectToServiceController.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\HttpFoundation\Response;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Symfony\Component\String\Slugger\AsciiSlugger;
  6. class ConnectToServiceController extends CoreController
  7. {
  8.     /**
  9.     * @Route("/se-connecter-au-service", name="app_connect")
  10.     */
  11.     public function connectToService(): Response
  12.     {
  13.         // Extracting the slug to know what department and category the user chose
  14.         $session $this->requestStack->getSession();
  15.         
  16.         extract($this->handleUrlParams($session));
  17.         
  18.         $serviceName $category->getXlab();
  19.         // Checks if the service or dep is closed
  20.         $isClosed $this->isServiceOrDepartmentOpen($category);
  21.         // If it is, returns the proper view
  22.         if ($isClosed)  {
  23.             return $this->render('closed-service.html.twig', [
  24.                 "sector" => $department,
  25.                 "service" => $service,
  26.                 "strService" => $serviceName,
  27.             ]);
  28.         }
  29.         
  30.         // We sluggify the department in order to have a proper URL
  31.         $slugger = new AsciiSlugger();
  32.         $slug strtolower($slugger->slug($department));
  33.         return $this->render('connect-to-service.html.twig', [
  34.             "sector" => $department,               // name of the department
  35.             "service" => $service,                 // service name as an array
  36.             "strService" => $serviceName,          // service name as a string
  37.             "sectorId" => $sector,                 // id of the sector
  38.             "serviceId" => $serviceId,             // id of the service
  39.             "slug" => $slug,                       // slug for the route
  40.             "headerLink" => 'app_department_3'     // path for the department home route
  41.         ]);
  42.     }
  43. }