Skip to content

Commit

Permalink
Merge pull request #13 from iCAPLyon1/hide-bell
Browse files Browse the repository at this point in the history
The notification bell can be hidden.
  • Loading branch information
ngodfraind committed Dec 3, 2015
2 parents 094b45c + e94e3e8 commit 5a286b4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Listener/ConfigureMenuListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
}

/**
Expand All @@ -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(
Expand Down

0 comments on commit 5a286b4

Please sign in to comment.