From 252fc775bb95348e1bfb640a43dd6479f74ffa38 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 11 Feb 2026 14:39:15 +0100 Subject: [PATCH] Dynamically display Organization Tab --- src/Twig/MenuExtension.php | 41 +++++++++++++++++++++++++++++++ templates/elements/menu.html.twig | 8 +++--- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 src/Twig/MenuExtension.php diff --git a/src/Twig/MenuExtension.php b/src/Twig/MenuExtension.php new file mode 100644 index 0000000..e3115d0 --- /dev/null +++ b/src/Twig/MenuExtension.php @@ -0,0 +1,41 @@ +security->getUser(); + + if (!$user) { + return false; + } + + // 1. If Super Admin, they see it + if ($this->security->isGranted('ROLE_ADMIN')) { + return true; + } + + return $this->userService->isAdminInAnyOrganization($user); + } +} \ No newline at end of file diff --git a/templates/elements/menu.html.twig b/templates/elements/menu.html.twig index 7e01b6f..334d54f 100644 --- a/templates/elements/menu.html.twig +++ b/templates/elements/menu.html.twig @@ -30,13 +30,13 @@ {% endif %} - + + {% endif %} \ No newline at end of file