src/Controller/Blog/BlogController.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 BlogController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/blog", name="blog")
  13.      */
  14.     public function index(Request $requestBlogRepository $blogRepository): 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.         $blogPaginator $blogRepository->findByRequest($request);
  22.         return $this->render('blog/index.html.twig', [
  23.             'blogPaginator' => $blogPaginator,
  24.         ]);
  25.     }
  26. }