cache) && array_key_exists($relatedEntityId, $this->cache[$relatedEntityClass])) { return $this->cache[$relatedEntityClass][$relatedEntityId]; } $user = $this->security->getUser(); if ($user instanceof User) { $counter = $this->notificationRepository->countNotificationByRelatedEntityAndUserAssociated( $relatedEntityClass, $relatedEntityId, $user ); $this->cache[$relatedEntityClass][$relatedEntityId] = $counter; return $counter; } return ['unread' => 0, 'read' => 0]; } /** * @return array|Notification[] */ public function getNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId): array { $user = $this->security->getUser(); if ($user instanceof User) { return $this->notificationRepository->findNotificationByRelatedEntityAndUserAssociated( $relatedEntityClass, $relatedEntityId, $user ); } return []; } }