← Back
Editing: ControlController.php
<?php namespace App\Controller\Organization; use App\Breadcrumb\BreadcrumbInterface; use App\Breadcrumb\BreadcrumbItem; use App\Entity\Controle; use App\Repository\ControleRepository; use App\Repository\ZoneRepository; use App\Service\OrganizationService; use App\Service\SupervisorService; use Knp\Component\Pager\PaginatorInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; #[Route(path: '/organization/control', name: 'organization_control_')] class ControlController extends AbstractController { public function __construct(BreadcrumbInterface $breadcrumb, SupervisorService $supervisorService) { $breadcrumb->addRootItem(BreadcrumbItem::set('Accueil', 'organization_index')); $breadcrumb->addItem(BreadcrumbItem::set('Contrôles', 'organization_control_index')); $supervisorService->setSection('control'); } #[Route(path: '/controles/{page}', name: 'index', requirements: ['page' => '\d+'])] #[Route(path: '/locataires/{page}', name: 'tenant_index', requirements: ['page' => '\d+'], defaults: ['type' => 'tenant'])] public function index( ControleRepository $controlRepository, PaginatorInterface $paginator, SupervisorService $supervisorService, OrganizationService $organizationService, int $page = 1, ?string $type = null ): Response { $agenciesId = $organizationService->getAgenciesId(); $query = $controlRepository->getQueryByAgencies($agenciesId)->orderBy( 'c.dateRealisation', 'desc' ); if ('tenant' === $type) { $supervisorService->setSection('control_tenant'); $aliases = $query->getAllAliases(); if (!in_array('ag', $aliases)) { $query->leftJoin('c.agent', 'ag'); } $query ->andWhere('ag.roles LIKE :agentRole') ->setParameter('agentRole', '%ROLE_TENANT%'); } $controls = $paginator->paginate($query, $page); return $this->render('organization/address/controls.html.twig', ['controls' => $controls]); } #[Route(path: '/detail/{id}.html', name: 'detail')] public function detail( Controle $controle, ZoneRepository $zoneRepository, BreadcrumbInterface $breadcrumb ): Response { $breadcrumb->addItem(BreadcrumbItem::set('Détail d\'un contrôle')); return $this->render( 'organization/control/detail.html.twig', [ 'controle' => $controle, 'zones' => $zoneRepository->findByControl($controle), ] ); } }
Save File
Cancel