<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\String\Slugger\AsciiSlugger;
class ConnectToServiceController extends CoreController
{
/**
* @Route("/se-connecter-au-service", name="app_connect")
*/
public function connectToService(): Response
{
// Extracting the slug to know what department and category the user chose
$session = $this->requestStack->getSession();
extract($this->handleUrlParams($session));
$serviceName = $category->getXlab();
// Checks if the service or dep is closed
$isClosed = $this->isServiceOrDepartmentOpen($category);
// If it is, returns the proper view
if ($isClosed) {
return $this->render('closed-service.html.twig', [
"sector" => $department,
"service" => $service,
"strService" => $serviceName,
]);
}
// We sluggify the department in order to have a proper URL
$slugger = new AsciiSlugger();
$slug = strtolower($slugger->slug($department));
return $this->render('connect-to-service.html.twig', [
"sector" => $department, // name of the department
"service" => $service, // service name as an array
"strService" => $serviceName, // service name as a string
"sectorId" => $sector, // id of the sector
"serviceId" => $serviceId, // id of the service
"slug" => $slug, // slug for the route
"headerLink" => 'app_department_3' // path for the department home route
]);
}
}