adapt to support admin users

This commit is contained in:
Julien Fastré 2018-05-14 14:39:13 +02:00
parent 8f4be568e9
commit d8c1f9d1dc

View File

@ -18,6 +18,7 @@
namespace Chill\TaskBundle\Templating\UI; namespace Chill\TaskBundle\Templating\UI;
use Chill\MainBundle\Templating\UI\NotificationCounterInterface; use Chill\MainBundle\Templating\UI\NotificationCounterInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\TaskBundle\Repository\SingleTaskRepository; use Chill\TaskBundle\Repository\SingleTaskRepository;
use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheItemPoolInterface;
@ -52,8 +53,12 @@ class CountNotificationTask implements NotificationCounterInterface
$this->cachePool = $cachePool; $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)); $sumCache = $this->cachePool->getItem($this->getCacheKey($u));
if ($sumCache->isHit()) { if ($sumCache->isHit()) {
@ -82,7 +87,7 @@ class CountNotificationTask implements NotificationCounterInterface
return $sum; return $sum;
} }
public function addNotification(User $u): int public function addNotification(UserInterface $u): int
{ {
return $this->countNotification($u); return $this->countNotification($u);
} }