/**
  * @Route("/rooms/{id}", name="showRoom")
  * @param string $id
  * @param Request $request
  * @throws \Exception
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function roomsAction($id, Request $request)
 {
     if ($id == 'random') {
         $page = $this->getDoctrine()->getRepository('AppBundle:Pages')->getRandomPage();
         if (!$page) {
             return $this->render('default/empty.html.twig');
         }
     } else {
         $page = $this->getDoctrine()->getRepository('AppBundle:Pages')->find($id);
         if (!$page) {
             throw $this->createNotFoundException('No page found for request param ' . $id);
         }
     }
     $imagesCollector = new ImagesViewCollector();
     $bookingEntity = new Booking();
     $calculator = new Calculator();
     $context = new CalculationContext();
     $context->setPricePerNight($page->getRawValue('priceNight'));
     $now = new \DateTime();
     $context->setCheckInDate($now->format('Y-m-d'));
     $context->setCheckOutDate($now->modify('+1 day')->format('Y-m-d'));
     $calcResult = $calculator->calculate($context);
     $bookingEntity->setGuestsCount($calcResult['guestsCount']);
     $bookingEntity->setPriceString($calcResult['pricePerNight']);
     $bookingEntity->setCheckinDate($calcResult['checkinDate']);
     $bookingEntity->setCheckoutDate($calcResult['checkoutDate']);
     $bookingEntity->setPage($page);
     $bookingEntity->setPageId($page->getId());
     $form = $this->createForm(new BookingForm('/add-booking/' . $page->getId()), $bookingEntity);
     $form->handleRequest($request);
     return $this->render('default/index.html.twig', array('page' => $page, 'images' => $imagesCollector->collect($page), 'bookingCalc' => $calcResult, 'form' => $form->createView()));
 }