From 8d095a368fc34361335a43e3408afe523def36c5 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 29 Aug 2025 11:02:19 +0200 Subject: [PATCH] Display all organization for super Admin --- src/Controller/OrganizationController.php | 19 ++++++++++++- templates/elements/menu.html.twig | 34 +++++++++++------------ templates/organization/index.html.twig | 10 +++---- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/Controller/OrganizationController.php b/src/Controller/OrganizationController.php index a8be762..c694be4 100644 --- a/src/Controller/OrganizationController.php +++ b/src/Controller/OrganizationController.php @@ -10,6 +10,7 @@ use App\Form\OrganizationForm; use App\Service\ActionService; use App\Service\OrganizationsService; use App\Service\UserOrganizationService; +use App\Service\UserService; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -26,9 +27,25 @@ class OrganizationController extends AbstractController public function __construct(private readonly EntityManagerInterface $entityManager, private readonly OrganizationsService $organizationsService, - private readonly UserOrganizationService $usersOrganizationService, private readonly ActionService $actionService) + private readonly UserOrganizationService $usersOrganizationService, private readonly ActionService $actionService, private readonly UserService $userService) { } + #[Route(path: '/', name: 'index', methods: ['GET'])] + public function index(): Response + { + $this->denyAccessUnlessGranted('ROLE_ADMIN'); + $user = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier()); + if ($this->isGranted("ROLE_SUPER_ADMIN")){ + $organizations = $this->entityManager->getRepository(Organizations::class)->findAll(); + } else { + $organizations = $this->organizationsService->getOrganizationsByUser($user); + } + + return $this->render('organization/index.html.twig', [ + 'organizations' => $organizations, + ]); + } + } diff --git a/templates/elements/menu.html.twig b/templates/elements/menu.html.twig index 4f6d589..82e78d4 100644 --- a/templates/elements/menu.html.twig +++ b/templates/elements/menu.html.twig @@ -37,23 +37,23 @@ {% endif %} diff --git a/templates/organization/index.html.twig b/templates/organization/index.html.twig index ff665ed..b4f6ecf 100644 --- a/templates/organization/index.html.twig +++ b/templates/organization/index.html.twig @@ -7,14 +7,14 @@

Gestion des organisations

{% if is_granted("ROLE_SUPER_ADMIN") %} - Ajouter une organisation +{# Ajouter une organisation#} {% endif %}
{% if organizations|length == 0 %} Aucune organisation trouvée. - Créer une organisation +{# Créer une organisation#} {% else %} @@ -38,9 +38,9 @@ {{ organization.name }} {{ organization.email }} - - {{ ux_icon('fa6-regular:eye', {height: '30px', width: '30px'}) }} - +{# #} +{# {{ ux_icon('fa6-regular:eye', {height: '30px', width: '30px'}) }}#} +{# #} {% endfor %}