コード例 #1
0
 public function unSubscribe(UserInterface $user, UuidInterface $object)
 {
     $className = $this->getClassResolver()->resolveClassName('Notification\\Entity\\SubscriptionInterface');
     $criteria = ['user' => $user->getId(), 'object' => $object->getId()];
     $subscription = $this->getObjectManager()->getRepository($className)->findOneBy($criteria);
     if (is_object($subscription)) {
         $this->objectManager->remove($subscription);
     }
 }
コード例 #2
0
ファイル: Subscribe.php プロジェクト: andreas-serlo/athene2
 /**
  * @return string
  */
 public function subMenuItem()
 {
     /* @var Partial */
     $partial = $this->getView()->plugin('partial');
     $template = $this->isSubscribed ? 'opt-out' : 'opt-in';
     return $partial('notification/subscription/' . $template . '/sub-menu-item', ['object' => $this->object->getId(), 'emailsActive' => $this->emailsActive]);
 }
コード例 #3
0
 public function findMetadataByObjectAndKeyAndValue(UuidInterface $object, $key, $value)
 {
     if (!is_string($key)) {
         throw new Exception\InvalidArgumentException(sprintf('Expected parameter 2 to be string but got %s', gettype($key)));
     }
     if (!is_string($value)) {
         throw new Exception\InvalidArgumentException(sprintf('Expected parameter 3 to be string but got %s', gettype($value)));
     }
     $key = $this->findKeyByName($key);
     $className = $this->getClassResolver()->resolveClassName('Metadata\\Entity\\MetadataInterface');
     $criteria = ['object' => $object->getId(), 'key' => $key->getId(), 'value' => $value];
     $entity = $this->getObjectManager()->getRepository($className)->findOneBy($criteria);
     if (!is_object($entity)) {
         throw new Exception\MetadataNotFoundException(sprintf('Could not find metadata by object `%s`, key `%s` and value `%s`', $object->getId(), $key, $value));
     }
     return $entity;
 }
コード例 #4
0
 public function findDiscussionsOn(UuidInterface $uuid, $archived = null)
 {
     $className = $this->getClassResolver()->resolveClassName($this->entityInterface);
     $objectRepository = $this->getObjectManager()->getRepository($className);
     $criteria = ['object' => $uuid->getId()];
     if ($archived !== null) {
         $criteria['archived'] = $archived;
     }
     $discussions = $objectRepository->findBy($criteria);
     foreach ($discussions as $discussion) {
         $this->assertGranted('discussion.get', $discussion);
     }
     $collection = new ArrayCollection($discussions);
     return $this->sortDiscussions($collection);
 }
コード例 #5
0
ファイル: Discussion.php プロジェクト: andreas-serlo/athene2
 public function getForm($type, UuidInterface $object, TaxonomyTermInterface $forum = null)
 {
     $view = $this->getView();
     $queries = ['query' => ['redirect' => $view->serverUrl(true)]];
     switch ($type) {
         case 'discussion':
             $form = clone $this->discussionForm;
             $form->setAttribute('action', $view->url('discussion/discussion/start', ['on' => $object->getId()], $queries));
             return $form;
             break;
         case 'comment':
             $form = clone $this->commentForm;
             $form->setAttribute('action', $view->url('discussion/discussion/comment', ['discussion' => $object->getId()], $queries));
             return $form;
             break;
         default:
             throw new RuntimeException();
     }
 }
コード例 #6
0
 public function findAliasByObject(UuidInterface $uuid)
 {
     /* @var $entity Entity\AliasInterface */
     $criteria = ['uuid' => $uuid->getId()];
     $order = ['timestamp' => 'DESC'];
     $results = $this->getAliasRepository()->findBy($criteria, $order);
     $entity = current($results);
     if (!is_object($entity)) {
         throw new Exception\AliasNotFoundException();
     }
     return $entity;
 }