| @@ 25-43 (lines=19) @@ | ||
| 22 | /** |
|
| 23 | * @inheritdoc} |
|
| 24 | */ |
|
| 25 | public function findComments($type, $entityId, $page = 1, $pageSize = null) |
|
| 26 | { |
|
| 27 | $query = $this->createQueryBuilder('c') |
|
| 28 | ->join('c.thread', 't') |
|
| 29 | ->leftJoin('c.creator', 'creator') |
|
| 30 | ->leftJoin('c.changer', 'changer') |
|
| 31 | ->where('t.type = :type AND t.entityId = :entityId') |
|
| 32 | ->setParameter('type', $type) |
|
| 33 | ->setParameter('entityId', $entityId) |
|
| 34 | ->orderBy('c.created', 'DESC') |
|
| 35 | ->getQuery(); |
|
| 36 | ||
| 37 | if ($pageSize) { |
|
| 38 | $query->setMaxResults($pageSize); |
|
| 39 | $query->setFirstResult(($page - 1) * $pageSize); |
|
| 40 | } |
|
| 41 | ||
| 42 | return $query->getResult(); |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @inheritdoc} |
|
| @@ 48-68 (lines=21) @@ | ||
| 45 | /** |
|
| 46 | * @inheritdoc} |
|
| 47 | */ |
|
| 48 | public function findPublishedComments($type, $entityId, $page, $pageSize) |
|
| 49 | { |
|
| 50 | $query = $this->createQueryBuilder('c') |
|
| 51 | ->join('c.thread', 't') |
|
| 52 | ->leftJoin('c.creator', 'creator') |
|
| 53 | ->leftJoin('c.changer', 'changer') |
|
| 54 | ->where('c.state = :state') |
|
| 55 | ->andWhere('t.type = :type AND t.entityId = :entityId') |
|
| 56 | ->setParameter('state', CommentInterface::STATE_PUBLISHED) |
|
| 57 | ->setParameter('type', $type) |
|
| 58 | ->setParameter('entityId', $entityId) |
|
| 59 | ->orderBy('c.created', 'DESC') |
|
| 60 | ->getQuery(); |
|
| 61 | ||
| 62 | if ($pageSize) { |
|
| 63 | $query->setMaxResults($pageSize); |
|
| 64 | $query->setFirstResult(($page - 1) * $pageSize); |
|
| 65 | } |
|
| 66 | ||
| 67 | return $query->getResult(); |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * @inheritdoc} |
|