Exemplo n.º 1
0
 /**
  * @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;
 }
 public function unsubscribeAction()
 {
     if (!$this->authorizationService->getIdentity()) {
         throw new UnauthorizedException();
     }
     $object = $this->params('object');
     $user = $this->authorizationService->getIdentity();
     try {
         $object = $this->uuidManager->getUuid($object);
     } catch (NotFoundException $e) {
         $this->getResponse()->setStatusCode(404);
         return false;
     }
     $this->subscriptionManager->unSubscribe($user, $object);
     $this->subscriptionManager->flush();
     $this->flashMessenger()->addSuccessMessage('You are no longer receiving notifications for this content.');
     return $this->redirect()->toReferer();
 }