diff --git a/Templating/UI/CountNotificationTask.php b/Templating/UI/CountNotificationTask.php index 76a350ae2..103e3ad8f 100644 --- a/Templating/UI/CountNotificationTask.php +++ b/Templating/UI/CountNotificationTask.php @@ -18,6 +18,7 @@ namespace Chill\TaskBundle\Templating\UI; use Chill\MainBundle\Templating\UI\NotificationCounterInterface; +use Symfony\Component\Security\Core\User\UserInterface; use Chill\MainBundle\Entity\User; use Chill\TaskBundle\Repository\SingleTaskRepository; use Psr\Cache\CacheItemPoolInterface; @@ -52,8 +53,12 @@ class CountNotificationTask implements NotificationCounterInterface $this->cachePool = $cachePool; } - public function countNotification(User $u): int + public function countNotification(UserInterface $u): int { + if (!$u instanceof User) { + return 0; + } + $sumCache = $this->cachePool->getItem($this->getCacheKey($u)); if ($sumCache->isHit()) { @@ -82,7 +87,7 @@ class CountNotificationTask implements NotificationCounterInterface return $sum; } - public function addNotification(User $u): int + public function addNotification(UserInterface $u): int { return $this->countNotification($u); }