public function render($limit = 25) { $user = $this->userManager->getUserFromAuthenticator(); $key = hash('sha256', serialize($user)); $output = ''; if ($this->storage->hasItem($key)) { //return $this->storage->getItem($key); } if ($user) { $notifications = $this->notificationManager->findNotificationsBySubscriber($user, $limit); $output = $this->renderer->render($this->template, ['notifications' => $notifications]); $this->storage->setItem($key, $output); } return $output; }
/** * @param UuidInterface $object * @return $this */ public function __invoke(UuidInterface $object) { $user = $this->userManager->getUserFromAuthenticator(); $this->object = $object; $this->emailsActive = false; $this->isSubscribed = false; if (!is_object($user)) { return $this; } $this->isSubscribed = $this->subscriptionManager->isUserSubscribed($user, $object); if (!$this->isSubscribed) { return $this; } $subscription = $this->subscriptionManager->findSubscription($user, $object); $this->emailsActive = $subscription->getNotifyMailman(); return $this; }
/** * @return \User\Entity\UserInterface */ public function getAuthenticatedUserID() { $user = $this->userManager->getUserFromAuthenticator(); return $user ? $user->getId() : ''; }