From e818a17371e9fe50841b85f0388aaa354405b2a4 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 14 Oct 2025 09:34:09 +0200 Subject: [PATCH] Refactor --- src/Controller/OrganizationController.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Controller/OrganizationController.php b/src/Controller/OrganizationController.php index 33a8a5b..fdc2469 100644 --- a/src/Controller/OrganizationController.php +++ b/src/Controller/OrganizationController.php @@ -43,17 +43,7 @@ class OrganizationController extends AbstractController if ($this->isGranted("ROLE_SUPER_ADMIN")) { $organizations = $this->entityManager->getRepository(Organizations::class)->findBy(['isDeleted' => false]); - // Map the entities for tabulator - $organizationsData = array_map(function($org) { - return [ - 'id' => $org->getId(), - 'name' => $org->getName(), - 'email' => $org->getEmail(), - 'logoUrl' => $org->getLogoUrl() ? $org->getLogoUrl() : null, // or prepend base URL if needed - 'active' => $org->isActive(), - 'showUrl' => $this->generateUrl('organization_show', ['id' => $org->getId()]), - ]; - }, $organizations); + } else { //get all the UO of the user $uos = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $user]); @@ -70,6 +60,17 @@ class OrganizationController extends AbstractController } } + // Map the entities for tabulator + $organizationsData = array_map(function($org) { + return [ + 'id' => $org->getId(), + 'name' => $org->getName(), + 'email' => $org->getEmail(), + 'logoUrl' => $org->getLogoUrl() ? $org->getLogoUrl() : null, // or prepend base URL if needed + 'active' => $org->isActive(), + 'showUrl' => $this->generateUrl('organization_show', ['id' => $org->getId()]), + ]; + }, $organizations); return $this->render('organization/index.html.twig', [ 'organizationsData' => $organizationsData, ]);