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 @@