/** * Return the number of unread notifications for the currently logged in user * * @return int */ public function countNotifications() { $user = $this->userContext->getUser(); if (null === $user) { return 0; } return $this->repository->countUnreadForUser($user); }
/** * Count unread notifications for the given user * * @param UserInterface $user * * @return int * * @deprecated will be removed in 1.7. Please use Pim\Bundle\NotificationBundle\Entity\Repository\UserNotificationRepository::countUnreadForUser() */ public function countUnreadForUser(UserInterface $user) { return $this->userNotifRepository->countUnreadForUser($user); }
/** * Return the number of unread notifications for the current user * * @return JsonResponse */ public function countUnreadAction() { $user = $this->userContext->getUser(); return new JsonResponse($this->userNotifRepository->countUnreadForUser($user)); }