Completed
Pull Request — master (#465)
by Marko
27:33
created

CommentListAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 12 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\Action;
13
14
use Sonata\NewsBundle\Model\CommentInterface;
15
use Sonata\NewsBundle\Model\CommentManagerInterface;
16
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
17
use Symfony\Component\HttpFoundation\Response;
18
19
final class CommentListAction extends Controller
20
{
21
    /**
22
     * @var CommentManagerInterface
23
     */
24
    private $commentManager;
25
26
    public function __construct(CommentManagerInterface $commentManager)
27
    {
28
        $this->commentManager = $commentManager;
29
    }
30
31
    /**
32
     * @param int $postId
33
     *
34
     * @return Response
35
     */
36
    public function __invoke($postId)
37
    {
38
        $pager = $this->commentManager
39
            ->getPager([
40
                'postId' => $postId,
41
                'status' => CommentInterface::STATUS_VALID,
42
            ], 1, 500); //no limit
43
44
        return $this->render('@SonataNews/Post/comments.html.twig', [
45
            'pager' => $pager,
46
        ]);
47
    }
48
}
49