Пример #1
0
 /**
  * Finds all votes belonging to a comment.
  *
  * @param VotableCommentInterface $comment
  * @return array of VoteInterface
  */
 public function findVotesByComment(VotableCommentInterface $comment)
 {
     $qb = $this->repository->createQueryBuilder();
     $qb->field('comment.$id')->equals($comment->getId());
     $qb->sort('createdAt', 'ASC');
     $votes = $qb->getQuery()->execute();
     return $votes;
 }
Пример #2
0
 /**
  * Marks messages as read/unread
  * by updating directly the storage
  *
  * @param ParticipantInterface $participant
  * @param boolean $isRead
  * @param \Closure $condition
  */
 protected function markIsReadByCondition(ParticipantInterface $participant, $isRead, \Closure $condition)
 {
     $queryBuilder = $this->repository->createQueryBuilder();
     $condition($queryBuilder);
     $queryBuilder->update()->field('metadata.participant.$id')->equals(new \MongoId($participant->getId()));
     /* If marking the message as read for a participant, we should pull
      * their ID out of the unreadForParticipants array. The same is not
      * true for the inverse. We should only add a participant ID to this
      * array if the message is not considered spam.
      */
     if ($isRead) {
         $queryBuilder->field('unreadForParticipants')->pull($participant->getId());
     }
     $queryBuilder->field('metadata.$.isRead')->set((bool) $isRead)->getQuery(array('multiple' => true))->execute();
     /* If marking the message as unread for a participant, add their ID to
      * the unreadForParticipants array if the message is not spam. This must
      * be done in a separate query, since the criteria is more selective.
      */
     if (!$isRead) {
         $queryBuilder = $this->repository->createQueryBuilder();
         $condition($queryBuilder);
         $queryBuilder->update()->field('metadata.participant.$id')->equals(new \MongoId($participant->getId()))->field('isSpam')->equals(false)->field('unreadForParticipants')->addToSet($participant->getId())->getQuery(array('multiple' => true))->execute();
     }
 }
 public function assign($document)
 {
     return parent::assign($document, new Lineup());
 }
 /**
  * Gets threads created by a participant
  *
  * @param ParticipantInterface $participant
  * @return array of ThreadInterface
  */
 public function findThreadsCreatedBy(ParticipantInterface $participant)
 {
     return $this->repository->createQueryBuilder('t')->innerJoin('t.createdBy', 'p')->where('p.id = :participant_id')->setParameter('participant_id', $participant->getId())->getQuery()->execute();
 }
Пример #5
0
 /**
  * {@inheritDoc}
  */
 public function findUsers()
 {
     return $this->repository->findAll();
 }
 public function assign($document)
 {
     return parent::assign($document, new GameBatter());
 }
Пример #7
0
 /**
  * Gets threads created by a participant
  *
  * @param ParticipantInterface $participant
  * @return array of ThreadInterface
  */
 public function findThreadsCreatedBy(ParticipantInterface $participant)
 {
     return $this->repository->createQueryBuilder()->field('createdBy.$id')->equals(new \MongoId($participant->getId()))->getQuery()->execute();
 }
 public function assign($document, $object = null)
 {
     if (!$object) {
         $object = new Season();
     }
     return parent::assign($document, $object);
 }
Пример #9
0
 /**
  * Finds all threads.
  *
  * @return array of ThreadInterface
  */
 public function findAllThreads()
 {
     return $this->repository->findAll();
 }
Пример #10
0
 /**
  * Find one comment by its ID
  *
  * @return Comment or null
  **/
 public function findCommentById($id)
 {
     return $this->repository->find($id);
 }
 public function assign($document)
 {
     return parent::assign($document, new SearchQuery());
 }
 public function assign($document)
 {
     return parent::assign($document, new Coach());
 }
 public function assign($document)
 {
     return parent::assign($document, new Conference());
 }
 public function assign($document)
 {
     return parent::assign($document, new League());
 }
 public function assign($document)
 {
     return parent::assign($document, new Player());
 }
Пример #16
0
 /**
  * Tells how many unread messages this participant has
  *
  * @param ParticipantInterface $participant
  * @return int the number of unread messages
  */
 public function getNbUnreadMessageByParticipant(ParticipantInterface $participant)
 {
     $builder = $this->repository->createQueryBuilder('m');
     return (int) $builder->select($builder->expr()->count('mm.id'))->innerJoin('m.metadata', 'mm')->innerJoin('mm.participant', 'p')->where('p.id = :participant_id')->setParameter('participant_id', $participant->getId())->andWhere('m.sender != :sender')->setParameter('sender', $participant->getId())->andWhere('mm.isRead = :isRead')->setParameter('isRead', false, \PDO::PARAM_BOOL)->getQuery()->getSingleScalarResult();
 }
 public function __construct()
 {
     parent::__construct();
     $this->collection = 'page';
 }
 public function assign($document)
 {
     return parent::assign($document, new GamePlayerPitching());
 }