src/Controller/AgencesvoyagesController.php line 51

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Agencesvoyages\Agencesvoyages;
  4. use App\Repository\Agencesvoyages\AgencesvoyagesRepository;
  5. use Knp\Component\Pager\PaginatorInterface;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. /**
  11.  * @Route("/agences/voyages")
  12.  */
  13. class AgencesvoyagesController extends AbstractController
  14. {
  15.     /**
  16.      * @var AgencesvoyagesRepository
  17.      */
  18.     private $repository;
  19.     /**
  20.      * AgencesvoyagesController constructor.
  21.      * @param AgencesvoyagesRepository $repository
  22.      */
  23.     public function __construct(AgencesvoyagesRepository $repository)
  24.     {
  25.         $this->repository $repository;
  26.     }
  27.     /**
  28.      * @Route("/", name="agencesvoyages.index", defaults={"title":"Agences de voyages"})
  29.      * @param Request $request
  30.      * @param $title
  31.      * @param PaginatorInterface $paginator
  32.      * @return Response
  33.      */
  34.     public function agencesVoyages(Request $request$titlePaginatorInterface $paginator)
  35.     {
  36.         $agences $paginator->paginate(
  37.             $this->repository->findBy(['online' => true]), /* query NOT result */
  38.             $request->query->getInt('page'1)/*page number*/,
  39.             $request->query->getInt('limit'6)/*limit per page*/
  40.         );
  41.         return $this->render('pages/internes/agencesvoyages/index.html.twig', [
  42.             'title' => $title,
  43.             'agences' => $agences,
  44.             'menu' => "Séjourner",
  45.             'current_page' => 'sejours'
  46.         ]);
  47.     }
  48.     /**
  49.      * @Route("/{slug}/{id}", name="agencesvoyages.show")
  50.      * @param $slug
  51.      * @param Agencesvoyages $agencesvoyage
  52.      * @return Response
  53.      */
  54.     public function show($slugAgencesvoyages $agencesvoyage)
  55.     {
  56.         if ($agencesvoyage->getSlug() !== $slug) {
  57.             return $this->redirectToRoute('agencesvoyages.show', [
  58.                 'id' => $agencesvoyage->getId(),
  59.                 'slug' => $agencesvoyage->getSlug(),
  60.             ], 301);
  61.         }
  62.         $othersAgences $this->repository->getAgencesvoyagesRandom($agencesvoyage3);
  63.         return $this->render('pages/internes/agencesvoyages/show.html.twig', [
  64.             'title' => $agencesvoyage->getName(),
  65.             'agence' => $agencesvoyage,
  66.             'agences' => $othersAgences,
  67.             'menu' => "Côte d'Ivoire Tourisme",
  68.             'current_page' => 'cit'
  69.         ]);
  70.     }
  71. }