2017-11-04 21:30:32 +00:00
|
|
|
<?php
|
2023-04-01 17:31:40 +00:00
|
|
|
declare(strict_types=1);
|
2017-11-04 21:30:32 +00:00
|
|
|
|
2023-04-01 17:31:40 +00:00
|
|
|
namespace App\Controller;
|
2017-11-04 21:30:32 +00:00
|
|
|
|
2019-01-18 23:20:58 +00:00
|
|
|
use Knp\Component\Pager\PaginatorInterface;
|
2023-04-01 17:31:40 +00:00
|
|
|
use App\Repository\Blog\PostRepository;
|
2017-11-05 02:03:26 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
2023-04-01 17:31:40 +00:00
|
|
|
use Symfony\Component\HttpFoundation\{Request, Response};
|
2017-11-04 21:30:32 +00:00
|
|
|
|
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;
|
|
|
|
|
2023-04-01 17:31:40 +00:00
|
|
|
public function indexAction(Request $request, PostRepository $postRepository, PaginatorInterface $paginator): Response
|
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,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|