From e94e3e837e0069e76448f0d6c168e16729878554 Mon Sep 17 00:00:00 2001 From: Nicolas Godfraind Date: Thu, 3 Dec 2015 11:43:32 +0100 Subject: [PATCH] The notification bell can be hidden. --- Listener/ConfigureMenuListener.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Listener/ConfigureMenuListener.php b/Listener/ConfigureMenuListener.php index 3d57aba..03d41ab 100644 --- a/Listener/ConfigureMenuListener.php +++ b/Listener/ConfigureMenuListener.php @@ -8,6 +8,7 @@ use Symfony\Component\Translation\TranslatorInterface; use Icap\NotificationBundle\Manager\NotificationManager; use Symfony\Bundle\TwigBundle\TwigEngine; +use Claroline\CoreBundle\Library\Configuration\PlatformConfigurationHandler; /** * @DI\Service() @@ -18,25 +19,29 @@ class ConfigureMenuListener private $notificationManager; private $templating; private $tokenStorage; + private $ch; /** * @DI\InjectParams({ * "translator" = @DI\Inject("translator"), * "notificationManager" = @DI\Inject("icap.notification.manager"), * "templating" = @DI\Inject("templating"), - * "tokenStorage" = @DI\Inject("security.token_storage") + * "tokenStorage" = @DI\Inject("security.token_storage"), + * "ch" = @DI\Inject("claroline.config.platform_config_handler") * }) */ public function __construct( TranslatorInterface $translator, NotificationManager $notificationManager, TwigEngine $templating, - TokenStorageInterface $tokenStorage + TokenStorageInterface $tokenStorage, + PlatformConfigurationHandler $ch ) { $this->translator = $translator; $this->notificationManager = $notificationManager; $this->templating = $templating; $this->tokenStorage = $tokenStorage; + $this->ch = $ch; } /** @@ -49,7 +54,10 @@ public function onTopBarLeftMenuConfigure(ConfigureMenuEvent $event) { $user = $this->tokenStorage->getToken()->getUser(); - if ($user !== 'anon.') { + //this is still configurable in the core bundle and should be changed... + $isActive = $this->ch->getParameter('is_notification_active'); + + if ($user !== 'anon.' && $isActive) { $countUnviewedNotifications = $this->notificationManager->countUnviewedNotifications($user->getId()); $end = $this->templating->render(