You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
795 B
28 lines
795 B
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Repository\PostRepository;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
class PostController extends AbstractController
|
|
{
|
|
#[Route('/', name: 'app_posts')]
|
|
public function index(PostRepository $repository, Request $request): Response
|
|
{
|
|
$page = $request->query->getInt('page',1);
|
|
$posts = $repository->findPaginatedPosts($page, 10);
|
|
return $this->render('post/index.html.twig', [
|
|
'posts' => $posts,
|
|
'maxPosts' => $page * 10,
|
|
'currentPage' => $page
|
|
]);
|
|
}
|
|
}
|
|
|
|
|