src/AppBundle/Controller/DefaultController.php line 231

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Controller;
  3. use AppBundle\Entity\Message;
  4. use AppBundle\Entity\Subscribe;
  5. use AppBundle\Services\Date;
  6. use AppBundle\Services\SoapService;
  7. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\HttpFoundation\Session\Session;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. class DefaultController extends Controller
  14. {
  15.     /**
  16.      * @Route("/{_locale}", name="homepage",
  17.      *     defaults={"_locale":"en"
  18.      * },
  19.      *     requirements={"_locale":"en|ru|am"
  20.      * }
  21.      * )
  22.      */
  23.     public function indexAction(Request $request$_locale)
  24.     {
  25.         $sliders $this->getDoctrine()->getRepository('AppBundle:Slider')->findBy([], ['orderSlider' => 'ASC']);
  26. //        page
  27.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(7);
  28.         $aboutPage $this->getDoctrine()->getRepository('AppBundle:Page')->find(1);
  29.         $roomPage $this->getDoctrine()->getRepository('AppBundle:Page')->find(2);
  30.         $eventsPage $this->getDoctrine()->getRepository('AppBundle:Page')->find(3);
  31.         $diningPage $this->getDoctrine()->getRepository('AppBundle:Page')->find(4);
  32.         $fitnessPage $this->getDoctrine()->getRepository('AppBundle:Page')->find(5);
  33.         $galleryCategory $this->getDoctrine()->getRepository('AppBundle:GalleryCategory')->findBy([],['orderCategory'=>'ASC']);
  34.         $gallery $this->getDoctrine()->getRepository('AppBundle:Gallery')->findAll();
  35.         $galleryPage $this->getDoctrine()->getRepository('AppBundle:Page')->find(6);
  36.         return $this->render('page/index.html.twig', [
  37.             'page' => $page,
  38.             'sliders' => $sliders,
  39.             'aboutPage' => $aboutPage,
  40.             'roomPage' => $roomPage,
  41.             'eventsPage' => $eventsPage,
  42.             'diningPage' => $diningPage,
  43.             'fitnessPage' => $fitnessPage,
  44.             'galleryPage' => $galleryPage,
  45.             'galleryCateg' => $galleryCategory,
  46.             'gallery' => $gallery,
  47.         ]);
  48.     }
  49.     /**
  50.      * @Route("/{_locale}/about", name="about_page",
  51.      *     defaults={"_locale":"en"
  52.      * },
  53.      *     requirements={"_locale":"en|ru|am"
  54.      * }
  55.      * )
  56.      */
  57.     public function aboutAction(Request $request$_locale)
  58.     {
  59.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(1);
  60.         $wyndhamPage $this->getDoctrine()->getRepository('AppBundle:Page')->find(8);
  61.         return $this->render('page/about.html.twig', [
  62.             'page' => $page,
  63.             'wyndham' => $wyndhamPage,
  64.         ]);
  65.     }
  66.     /**
  67.      * @Route("/{_locale}/contact", name="contact_page",
  68.      *     defaults={"_locale":"en"
  69.      * },
  70.      *     requirements={"_locale":"en|ru|am"
  71.      * }
  72.      * )
  73.      */
  74.     public function contactAction(Request $request$_locale)
  75.     {
  76.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(10);
  77.         $contact $this->getDoctrine()->getRepository('AppBundle:Contact')->findAll();
  78.         return $this->render('page/contact.html.twig', [
  79.             'page' => $page,
  80.             'contact' => $contact
  81.         ]);
  82.     }
  83.     /**
  84.      * @Route("/{_locale}/dining", name="dining_page",
  85.      *     defaults={"_locale":"en"
  86.      * },
  87.      *     requirements={"_locale":"en|ru|am"
  88.      * }
  89.      * )
  90.      */
  91.     public function diningAction(Request $request$_locale)
  92.     {
  93.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(4);
  94.         $dining $this->getDoctrine()->getRepository('AppBundle:Dining')->findBy([], ['orderDining' => 'ASC']);
  95.         return $this->render('page/dining.html.twig', [
  96.             'dining' => $dining,
  97.             'page' => $page,
  98.         ]);
  99.     }
  100.     /**
  101.      * @Route("/{_locale}/dining_view/{slug}", name="dining_view_page",
  102.      *     defaults={"_locale":"en"
  103.      * },
  104.      *     requirements={"_locale":"en|ru|am"
  105.      * }
  106.      * )
  107.      */
  108.     public function diningViewAction(Request $request$_locale$slug)
  109.     {
  110.         $dining $this->getDoctrine()->getRepository('AppBundle:Dining')->find($slug);
  111.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(4);
  112.         return $this->render('page/dining-view.html.twig', [
  113.             'dining' => $dining,
  114.             'page' => $page,
  115.         ]);
  116.     }
  117.     /**
  118.      * @Route("/{_locale}/events_list", name="events_list_page",
  119.      *     defaults={"_locale":"en"
  120.      * },
  121.      *     requirements={"_locale":"en|ru|am"
  122.      * }
  123.      * )
  124.      */
  125.     public function eventsListAction(Request $request$_locale)
  126.     {
  127.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(3);
  128.         $events $this->getDoctrine()->getRepository('AppBundle:EventsCategory')->findBy([], ['orderEvents' => 'ASC']);
  129.         $aboutPage $this->getDoctrine()->getRepository('AppBundle:page')->find(1);
  130.         return $this->render('page/events-list.html.twig', [
  131.             'page' => $page,
  132.             'events' => $events,
  133.             'about' => $aboutPage,
  134.         ]);
  135.     }
  136.     /**
  137.      * @Route("/{_locale}/events_view/{slug}", name="events_view_page",
  138.      *     defaults={"_locale":"en"
  139.      * },
  140.      *     requirements={"_locale":"en|ru|am"
  141.      * }
  142.      * )
  143.      */
  144.     public function eventsViewAction(Request $request$_locale$slug)
  145.     {
  146.         $events $this->getDoctrine()->getRepository('AppBundle:Events')->findBy(['category' => $slug], ['orderEvents' => 'ASC']);
  147.         $category $this->getDoctrine()->getRepository('AppBundle:EventsCategory')->find($slug);
  148.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(3);
  149.         $aboutPage $this->getDoctrine()->getRepository('AppBundle:page')->find(1);
  150.         if (empty($events)) {
  151.             return $this->redirectToRoute('events_list_page');
  152.         }
  153.         return $this->render('page/events_view.html.twig', [
  154.             'event' => $events,
  155.             'page' => $page,
  156.             'about' => $aboutPage,
  157.             'category' => $category,
  158.         ]);
  159.     }
  160.     /**
  161.      * @Route("/{_locale}/fitness_page", name="fitness_page",
  162.      *     defaults={"_locale":"en"
  163.      * },
  164.      *     requirements={"_locale":"en|ru|am"
  165.      * }
  166.      * )
  167.      */
  168.     public function fitnessAction(Request $request$_locale)
  169.     {
  170.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(5);
  171.         $fitness $this->getDoctrine()->getRepository('AppBundle:Fitness')->findBy([], ['orderFitness' => 'asc']);
  172.         return $this->render('page/fitness.html.twig', [
  173.             'page' => $page,
  174.             'fitness' => $fitness
  175.         ]);
  176.     }
  177.     /**
  178.      * @Route("/{_locale}/gallery_page", name="gallery_page",
  179.      *     defaults={"_locale":"en"
  180.      * },
  181.      *     requirements={"_locale":"en|ru|am"
  182.      * }
  183.      * )
  184.      */
  185.     public function galleryAction(Request $request$_locale)
  186.     {
  187.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(6);
  188.         $galleryCategory $this->getDoctrine()->getRepository('AppBundle:GalleryCategory')->findAll();
  189.         $gallery $this->getDoctrine()->getRepository('AppBundle:Gallery')->findAll();
  190. //        $paginator = $this->get('knp_paginator');
  191. //        $pagination = $paginator->paginate(
  192. //            $gallery,
  193. //            $request->query->getInt('page',1),
  194. //            2
  195. //        );
  196.         return $this->render('page/gallery.html.twig', [
  197.             'page' => $page,
  198.             'gallery' => $gallery,
  199.             'galleryCategory' => $galleryCategory,
  200.         ]);
  201.     }
  202.     /**
  203.      * @Route("/{_locale}/rooms_list", name="rooms_list_page",
  204.      *     defaults={"_locale":"en"
  205.      * },
  206.      *     requirements={"_locale":"en|ru|am"
  207.      * }
  208.      * )
  209.      */
  210.     public function roomsListAction(Request $requestDate $date$_locale)
  211.     {
  212.         $currenc $request->getSession()->get('cba');
  213.         if ($currenc !== 'AMD' && $currenc !== null) {
  214.             $rates $date->getCbaRatesCurrent()['rates'][$currenc];
  215.         } else {
  216.             $rates = ['rate' => '1''iso' => 'AMD'];
  217.         }
  218.         $page $this->getDoctrine()->getRepository('AppBundle:Page')->find(2);
  219.         $rooms $this->getDoctrine()->getRepository('AppBundle:Room')->findBy([], ['orderRoom' => 'ASC']);
  220.         return $this->render('page/rooms_list.html.twig', [
  221.             'page' => $page,
  222.             'rooms' => $rooms,
  223.             'rates' => (int)$rates['rate'],
  224.             'iso' => $rates['iso'],
  225.         ]);
  226.     }
  227.     /**
  228.      * @Route("/{_locale}/rooms_view/{slug}", name="rooms_view_page",
  229.      *     defaults={"_locale":"en"
  230.      * },
  231.      *     requirements={"_locale":"en|ru|am"
  232.      * }
  233.      * )
  234.      */
  235.     public function roomsViewAction(Request $requestDate $date$_locale$slug)
  236.     {
  237.         $currenc $request->getSession()->get('cba');
  238.         if ($currenc !== 'AMD' && $currenc !== null) {
  239.             $rates $date->getCbaRatesCurrent()['rates'][$currenc];
  240.         } else {
  241.             $rates = ['rate' => '1''iso' => 'AMD'];
  242.         }
  243.         $arr = [];
  244.         $room $this->getDoctrine()->getRepository('AppBundle:Room')->find($slug);
  245.         $allRooms $this->getDoctrine()->getRepository('AppBundle:Room')->findBy([], [], 3,4);
  246.         $index 0;
  247.         foreach ($allRooms as $item) {
  248.             if ($item->getId() != $slug) {
  249.                 $arr[$index] = $item;
  250.                 $index++;
  251.             }
  252.         }
  253.         return $this->render('page/rooms_view.html.twig', [
  254.             'room' => $room,
  255.             'other' => $arr,
  256.             'rates' => (int)$rates['rate'],
  257.             'iso' => $rates['iso'],
  258.         ]);
  259.     }
  260.     /**
  261.      * @Route("/{_locale}/message", name="message",
  262.      *     defaults={"_locale":"en"
  263.      * },
  264.      *     requirements={"_locale":"en|ru|am"
  265.      * }
  266.      * )
  267.      */
  268.     public function messageAction(Request $request$_locale)
  269.     {
  270.         $em $this->getDoctrine()->getManager();
  271.         $name $request->get('name');
  272.         $mail $request->get('mail');
  273.         $subject $request->get('subject');
  274.         $message $request->get('message');
  275.         $emMessage = new Message();
  276.         if
  277.         (!empty($name) && !empty($mail) &&
  278.             !empty($subject) && !empty($message)) {
  279.             $emMessage->setName($name);
  280.             $emMessage->setEmail($mail);
  281.             $emMessage->setSubject($subject);
  282.             $emMessage->setMessage($message);
  283.             $em->persist($emMessage);
  284.             $em->flush();
  285.             $this->addFlash('success''Your Message Successful Send');
  286.         } else {
  287.             $this->addFlash('error''Your Message Not Send');
  288.         }
  289.         return $this->redirectToRoute('contact_page');
  290.     }
  291.     /**
  292.      * @Route("/{_locale}/subscribe", name="subscribe",
  293.      *     defaults={"_locale":"en"
  294.      * },
  295.      *     requirements={"_locale":"en|ru|am"
  296.      * }
  297.      * )
  298.      */
  299.     public function subscribeAction(Request $request$_locale)
  300.     {
  301.         $url $request->server->get('HTTP_REFERER');
  302.         $mail $request->get('mailSubs');
  303.         $em $this->getDoctrine()->getManager();
  304.         if (!empty($mail) && filter_var($mailFILTER_VALIDATE_EMAIL)) {
  305.             $subscribe = new Subscribe();
  306.             $subscribe->setEmail($mail);
  307.             $em->persist($subscribe);
  308.             $em->flush();
  309.             $this->addFlash('subSuccess''Your Mail Successful Subscribe');
  310.         } else {
  311.             $this->addFlash('subError''Your Mail Not Subscribe');
  312.         }
  313.         return $this->redirect($url);
  314.     }
  315.     /**
  316.      * @Route("/{_locale}/booking/", name="reservation_room",
  317.      *     defaults={"_locale":"en"
  318.      * },
  319.      *     requirements={"_locale":"en|ru|am"
  320.      * }
  321.      * )
  322.      */
  323.     public function reservationAction(Request $request$_locale)
  324.     {
  325.         return $this->render('page/register.html.twig');
  326.     }
  327.     /**
  328.      * @Route("/{_locale}/cba/{cba}", name="cba",
  329.      *     defaults={"_locale":"en"
  330.      * },
  331.      *     requirements={"_locale":"en|ru|am"
  332.      * }
  333.      * )
  334.      */
  335.     public function sessionAction(Request $request$cba$_locale)
  336.     {
  337.         $url $request->server->get('HTTP_REFERER');
  338.         $session = new Session();
  339.         $session->set('cba'$cba);
  340.         return $this->redirect($url);
  341.     }
  342.     /**
  343.      * @Route("/{_locale}/test", name="test",
  344.      *     defaults={"_locale":"en"
  345.      * },
  346.      *     requirements={"_locale":"en|ru|am"
  347.      * }
  348.      * )
  349.      */
  350.     public function testAction(Request $request,  $_locale)
  351.     {
  352.         return $this->render('default/index.html.twig');
  353.     }
  354. }