Completed
Push — 3.x-dev-kit ( 21be5a )
by
unknown
03:10
created

BasePostRepository::findLastPostQueryBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\NewsBundle\Entity;
13
14
use Doctrine\ORM\EntityRepository;
15
16
class BasePostRepository extends EntityRepository
17
{
18
    /**
19
     * return last post query builder.
20
     *
21
     * @param int $limit
22
     *
23
     * @return \Doctrine\ORM\QueryBuilder
24
     */
25
    public function findLastPostQueryBuilder($limit)
0 ignored issues
show
Unused Code introduced by
The parameter $limit is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27
        return $this->createQueryBuilder('p')
28
            ->where('p.enabled = true')
29
            ->orderby('p.createdAt', 'DESC');
30
    }
31
32
    /**
33
     * return count comments QueryBuilder.
34
     *
35
     * @param  Sonata\NewsBundle\Model\PostInterface
36
     *
37
     * @return \Doctrine\ORM\QueryBuilder
38
     */
39
    public function countCommentsQuery($post)
40
    {
41
        return $this->getEntityManager()->createQuery('SELECT COUNT(c.id)
42
                                          FROM Application\Sonata\NewsBundle\Entity\Comment c
43
                                          WHERE c.status = 1
44
                                          AND c.post = :post')
45
                    ->setParameters(array('post' => $post));
46
    }
47
}
48