Test Setup Failed
Push — master ( faa7b9...b8668c )
by Alexey
02:33
created

PublicFeedController::indexAction()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 1
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\Controller;
4
5
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\HttpFoundation\Request;
8
9
class PublicFeedController extends Controller
10
{
11
    private const POSTS_PER_PAGE = 20;
12
13
    public function indexAction(Request $request)
14
    {
15
        // @todo autowire
16
        $postRepository = $this->getDoctrine()->getRepository(Post::class);
17
18
        $paginator = $this->get('knp_paginator');
19
20
        $postsPagination = $paginator->paginate(
21
            $postRepository->createPublicFeedPostsQuery(),
22
            $request->query->getInt('page', 1),
23
            self::POSTS_PER_PAGE
24
        );
25
26
        return $this->render(
27
            'SkobkinPointToolsBundle:Post:feed.html.twig',
28
            [
29
                // @todo Move to translation
30
                'feed_title' => 'All',
31
                'posts' => $postsPagination,
32
                // Special feed mark (to not show comments and other)
33
                'is_feed' => true,
34
            ]
35
        );
36
    }
37
}
38