Пример #1
0
 /**
  * Returns a flat array of comments of a specific thread.
  *
  * @param ThreadInterface $thread
  * @param integer $depth
  * @return array of ThreadInterface
  */
 public function findCommentsByThread(ThreadInterface $thread, $depth = null, $sorterAlias = null)
 {
     $qb = $this->repository->createQueryBuilder('c')->join('c.thread', 't')->where('t.id = :thread')->orderBy('c.ancestors', 'ASC')->setParameter('thread', $thread->getId());
     if ($depth > 0) {
         // Queries for an additional level so templates can determine
         // if the final 'depth' layer has children.
         $qb->andWhere('c.depth <= :depth')->setParameter('depth', $depth + 1);
     }
     $comments = $qb->getQuery()->execute();
     if (null !== $sorterAlias) {
         $sorter = $this->getSortingFactory()->getSorter($sorterAlias);
         $comments = $sorter->sortFlat($comments);
     }
     return $comments;
 }
Пример #2
0
 /**
  * Returns a flat array of comments of a specific thread.
  *
  * @param  ThreadInterface $thread
  * @param  integer         $depth
  * @return array           of ThreadInterface
  */
 public function findCommentsByThread(ThreadInterface $thread, $depth = null, $sorterAlias = null)
 {
     $qb = $this->repository->createQueryBuilder()->field('thread.$id')->equals($thread->getId())->sort('ancestors', 'ASC');
     if ($depth > 0) {
         // Queries for an additional level so templates can determine
         // if the final 'depth' layer has children.
         $qb->field('depth')->lte($depth + 1);
     }
     $comments = $qb->getQuery()->execute();
     if (null !== $sorterAlias) {
         $sorter = $this->sortingFactory->getSorter($sorterAlias);
         $comments = $sorter->sortFlat($comments);
     }
     return $comments;
 }
 /**
  * Checks if the thread can be commented.
  *
  * @param ThreadInterface $thread
  *
  * @return bool
  */
 public function canCommentThread(ThreadInterface $thread)
 {
     return $thread->isCommentable() && (null === $this->commentAcl || $this->commentAcl->canCreate());
 }