point-tools/src/Skobkin/Bundle/PointToolsBundle/Controller/PublicFeedController.php

34 lines
1.1 KiB
PHP
Raw Normal View History

2017-11-04 21:30:32 +00:00
<?php
namespace Skobkin\Bundle\PointToolsBundle\Controller;
use Knp\Component\Pager\PaginatorInterface;
use Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository;
2017-11-05 02:03:26 +00:00
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2017-11-04 21:30:32 +00:00
use Symfony\Component\HttpFoundation\Request;
2017-11-05 02:03:26 +00:00
class PublicFeedController extends AbstractController
2017-11-04 21:30:32 +00:00
{
private const POSTS_PER_PAGE = 20;
public function indexAction(Request $request, PostRepository $postRepository, PaginatorInterface $paginator)
2017-11-04 21:30:32 +00:00
{
$postsPagination = $paginator->paginate(
$postRepository->createPublicFeedPostsQuery(),
$request->query->getInt('page', 1),
self::POSTS_PER_PAGE
);
return $this->render(
'SkobkinPointToolsBundle:Post:feed.html.twig',
[
// @todo Move to translation
2017-11-05 23:23:15 +00:00
'feed_title' => 'Public feed',
2017-11-04 21:30:32 +00:00
'posts' => $postsPagination,
// Special feed mark (to not show comments and other)
'is_feed' => true,
]
);
}
}