src/Controller/Blog/PageController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Blog;
  3. use App\Entity\Main\Blog;
  4. use App\Repository\Main\BlogRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class PageController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/blog/page/{page}", name="blog_page")
  13.      */
  14.     public function index(Request $requestBlogRepository $blogRepository$page): Response
  15.     {
  16.         $request->query->set('status_id'Blog::STATUS['ACTIVE']);
  17.         $request->query->set('locale'$request->getLocale());
  18.         $request->query->set('sort_by''id');
  19.         $request->query->set('sort_order''DESC');
  20.         $request->query->set('per_page'6);
  21.         $request->query->set('page'$page);
  22.         $blogPaginator $blogRepository->findByRequest($request);
  23.         return $this->render('blog/index.html.twig', [
  24.             'blogPaginator' => $blogPaginator,
  25.         ]);
  26.     }
  27. }