src/Controller/DefaultController.php line 75

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Continent;
  4. use App\Entity\Destination;
  5. use App\Entity\Flight;
  6. use App\Entity\Formule;
  7. use App\Entity\HebergemntOffer;
  8. use App\Entity\Highlight;
  9. use App\Entity\Included;
  10. use App\Entity\Itinerary;
  11. use App\Entity\ItineraryPic;
  12. use App\Entity\Offer;
  13. use App\Entity\OfferHebergement;
  14. use App\Entity\OfferInfo;
  15. use App\Entity\TypeVoyage;
  16. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. use Symfony\Component\HttpFoundation\Request;
  20. class DefaultController extends AbstractController
  21. {
  22.     /**
  23.      * @Route("/", name="app")
  24.      */
  25.     public function index()
  26.     {
  27.         $em $this->getDoctrine()->getManager();
  28.         $offEscapade $em->getRepository(Offer::class)->findBy(['type'=>1]);
  29.         $offCircuit $em->getRepository(Offer::class)->findBy(['type'=>2]);
  30.         $ourOffer $em->getRepository(Offer::class)->findBy(['OurOffer'=>1]);
  31.         $continents $em->getRepository(Continent::class)->findAll();
  32.         return $this->render('default/index.html.twig',[
  33.             'offEscapade'=>$offEscapade,
  34.             'offCircuit'=>$offCircuit,
  35.             'ourOffer'=>$ourOffer,
  36.             'continents'=>$continents
  37.         ]);
  38.     }
  39.      /**
  40.      * @Route("/oo", name="oo")
  41.      */
  42.     public function oo()
  43.     {
  44.         return $this->render('default/maintenance.html.twig');
  45.     }
  46.     /**
  47.      * @Route("/o-escapade", name="o.escapade")
  48.      */
  49.     public function escapade()
  50.     {
  51.         $em $this->getDoctrine()->getManager();
  52.         $offer $em->getRepository(TypeVoyage::class)->findBy(['type'=>1]);
  53.         $offers $em->getRepository(Offer::class)->findBy(['type'=>1]);
  54.         return $this->render('default/escapade.html.twig',
  55.         ['offers'=>$offers,
  56.          'offer'=>$offer,
  57.         ]);
  58.     }
  59.      /**
  60.      * @Route("/continent/{slug}", name="o.continent")
  61.      */
  62.     public function continent($slug)
  63.     {
  64.         $em $this->getDoctrine()->getManager();
  65.         $continent $em->getRepository(Continent::class)->findOneBy(['slug'=>$slug]);
  66.         $offers $em->getRepository(Offer::class)->findBy(['continent'=>$continent]);
  67.         return $this->render('default/continent.html.twig',
  68.         ['offers'=>$offers,
  69.          'continent'=>$continent,
  70.         ]);
  71.     }
  72.     /**
  73.      * @Route("/o-escapade/destination/{slug}", name="o.escapade.destination")
  74.      */
  75.     public function escapadeDestination($slug)
  76.     {
  77.         $em $this->getDoctrine()->getManager();
  78.         $destination $em->getRepository(Destination::class)->findOneBy(['slug'=>$slug]);
  79.         $offer $em->getRepository(Offer::class)->findOneBy(['destination'=>$destination->getId()]);
  80.         $offerHebergement $em->getRepository(OfferHebergement::class)->findBy(['offer'=>$offer->getId()]);
  81.         $formules $em->getRepository(Formule::class)->findBy(['offer'=>$offer->getId()]); ;
  82.        
  83.     
  84.         return $this->render('default/escapade-destination.html.twig',
  85.         ['destination'=>$destination,
  86.         'offerHebergement'=>$offerHebergement,
  87.         'formules'=>$formules,
  88.         'offer'=>$offer]);
  89.     }
  90.     /**
  91.      * @Route("/o-escapade", name="o.escapade")
  92.      * @Route("/o-circuit", name="o.circuit")
  93.      * @Route("/o-roadtrip", name="o.roadtrip")
  94.      * @Route("/o-croisiere", name="o.croisiere")
  95.      */
  96.     public function Ooffers(Request $request)
  97.     {   
  98.         $em $this->getDoctrine()->getManager();
  99.         $routeName $request->attributes->get('_route');
  100.          if($routeName == 'o.escapade'){
  101.         $typeOffer $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>1]);
  102.         $offers $em->getRepository(Offer::class)->findBy(['type'=>1]);
  103.         }
  104.         if($routeName == 'o.circuit'){
  105.         $typeOffer $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>2]);
  106.         $offers $em->getRepository(Offer::class)->findBy(['type'=>2]);
  107.         }
  108.          if($routeName == 'o.roadtrip'){
  109.         $typeOffer $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>3]);
  110.         $offers $em->getRepository(Offer::class)->findBy(['type'=>3]);
  111.          }
  112.         if($routeName == 'o.croisiere'){
  113.         $typeOffer $em->getRepository(TypeVoyage::class)->findOneBy(['id'=>4]);
  114.         $offers $em->getRepository(Offer::class)->findBy(['type'=>4]);
  115.          }
  116.         return $this->render('default/offers.html.twig', ['offers'=>$offers,'typeOffer'=> $typeOffer]);
  117.     }
  118.     
  119.     /**
  120.      * @Route("/o-circuit/destination-ex", name="o.circuit.destination-ex")
  121.      */
  122.     public function circuitDestinationEx()
  123.     {
  124.         $em $this->getDoctrine()->getManager();
  125.         return $this->render('default/circuit-destination-ex.html.twig');
  126.     }
  127.       /**
  128.      * @Route("/o-road/destination-ex", name="o.road.destination-ex")
  129.      */
  130.     public function roadtDestinationEx()
  131.     {
  132.         $em $this->getDoctrine()->getManager();
  133.         return $this->render('default/roadtrip-destination.html.twig');
  134.     }
  135.     /**
  136.      * @Route("/o-croisiere/destination-ex", name="o.ccroisiere.destination")
  137.      */
  138.     public function oCroisiere()
  139.     {
  140.         $em $this->getDoctrine()->getManager();
  141.         $id =3;
  142.         $offer $em->getRepository(Offer::class)->findOneBy(['id'=>$id]);
  143.         return $this->render('default/croisiere-destination.html.twig',
  144.         ['offer'=>$offer]);
  145.     }
  146.     /**
  147.      * @Route("/o-circuit/{slug}", name="o.circuit.destination")
  148.      * @Route("/o-roadtrip/{slug}", name="o.roadtrip.destination")
  149.      * @Route("/o-croisiere/{slug}", name="o.croisiere.destination")
  150.      */
  151.     public function oOffer(Request $request$slug)
  152.     {
  153.         $em $this->getDoctrine()->getManager();
  154.         $routeName $request->attributes->get('_route');
  155.         $offer $em->getRepository(Offer::class)->findOneBy(['slug'=>$slug]);
  156.         $highlight =  $em->getRepository(Highlight::class)->findBy(['offer'=>$offer]);
  157.         $itinerary $em->getRepository(Itinerary::class)->findBy(['offer'=>$offer]);
  158.         $photoItinerary $em->getRepository(ItineraryPic::class)->findBy(['Offer'=>$offer]);
  159.         $hebergementOffer $em->getRepository(HebergemntOffer::class)->findBy(['offer'=>$offer]);
  160.         $flight $em->getRepository(Flight::class)->findBy(['offer'=>$offer]) ;
  161.         $infos $em->getRepository(OfferInfo::class)->findBy(['offer'=>$offer]) ; 
  162.         $included $em->getRepository(Included::class)->findBy(['Offer'=>$offer]) ;
  163.           $routeName $request->attributes->get('_route');
  164.         if($routeName == 'o.circuit.destination'){
  165.         
  166.         return $this->render('default/circuit-destination.html.twig',
  167.          ['offer'=>$offer
  168.         'highlight'=>$highlight,
  169.         'photoItinerary'=>$photoItinerary,
  170.         'hebergementOffer'=>$hebergementOffer,
  171.         'included'=>$included,
  172.         'flight'=>$flight,
  173.         'infos'=>$infos,
  174.         'itinerary'=>$itinerary]);
  175.         }
  176.           if($routeName == 'o.roadtrip.destination'){
  177.         
  178.         return $this->render('default/roadtrip-destination.html.twig',
  179.         ['offer'=>$offer
  180.         'highlight'=>$highlight,
  181.         'flight'=>$flight,
  182.         'photoItinerary'=>$photoItinerary,
  183.         'hebergementOffer'=>$hebergementOffer,
  184.         'included'=>$included,
  185.         'infos'=>$infos,
  186.         'itinerary'=>$itinerary]);
  187.         }
  188.           if($routeName == 'o.croisiere.destination'){
  189.         
  190.         return $this->render('default/croisiere-destination.html.twig',
  191.         ['offer'=>$offer
  192.         'highlight'=>$highlight,
  193.         'flight'=>$flight,
  194.         'photoItinerary'=>$photoItinerary,
  195.         'hebergementOffer'=>$hebergementOffer,
  196.         'included'=>$included,
  197.         'infos'=>$infos,
  198.         'itinerary'=>$itinerary]);
  199.         }
  200.     }
  201.      /**
  202.      * @Route("/o-contact", name="o.contact")
  203.      * @Route("/demande-de-devis", name="o.devis")
  204.      */
  205.     public function contact(Request $request)
  206.     {
  207.         $em $this->getDoctrine()->getManager();
  208.         $routeName $request->attributes->get('_route');
  209.         if($routeName == 'o.contact'){
  210.         
  211.         return $this->render('default/contact.html.twig');
  212.         }
  213.          $routeName $request->attributes->get('_route');
  214.          if($routeName == 'o.devis'){
  215.             $typeSejour $em->getRepository(TypeVoyage::class)->findAll();
  216.          return $this->render('default/devis.html.twig',['typeSejour'=>$typeSejour]);
  217.         }
  218.     }
  219. }