src/ProductBundle/Controller/FrontEnd/CollectionController.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\ProductBundle\Controller\FrontEnd;
  3. use App\BaseBundle\Controller\AbstractController;
  4. use App\CMSBundle\Lib\Paginator;
  5. use App\ProductBundle\Repository\CollectionRepository;
  6. use PN\SeoBundle\Repository\SeoPageRepository;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. /**
  11. * @Route("collection")
  12. */
  13. class CollectionController extends AbstractController
  14. {
  15. /**
  16. * @Route("/{page}", requirements={"page": "\d+"}, name="fe_collection_index" ,methods={"GET"})
  17. */
  18. public function index(
  19. Request $request,
  20. SeoPageRepository $seoPageRepository,
  21. CollectionRepository $collectionRepository,
  22. int $page = 1
  23. ): Response
  24. {
  25. $search = new \stdClass;
  26. $search->deleted = 0;
  27. $search->publish = 1;
  28. $search->ordr = ["column" => 0, "dir" => "ASC"];
  29. if ($request->query->has("content")) {
  30. $request->query->remove("content");
  31. $count = $collectionRepository->filter($search, true);
  32. $paginator = new Paginator($count, $page, 12);
  33. $collections = ($count > 0) ? $collectionRepository->filter($search, false, $paginator->getLimitStart(),
  34. $paginator->getPageLimit()) : [];
  35. return $this->render("product/frontEnd/collection/_content.html.twig", [
  36. 'seoPage' => $seoPageRepository->findOneByType("collections"),
  37. 'collections' => $collections,
  38. "paginator" => $paginator->getPagination(),
  39. ]);
  40. }
  41. return $this->render("product/frontEnd/collection/index.html.twig", [
  42. 'search' => $search,
  43. 'seoPage' => $seoPageRepository->findOneByType("collections"),
  44. ]);
  45. }
  46. }