Ejemplo n.º 1
0
 public function photosAction(Hotel $hotel)
 {
     $em = $this->getDoctrine()->getManager();
     $session = $this->getRequest()->getSession();
     $session->set("routing", $this->generateUrl("photos_hotel", array('id' => $hotel->getId())));
     $media = new Media();
     $media->setHotel($hotel);
     $form = $this->createForm(new MediaType(), $media);
     $request = $this->getRequest();
     if ($request->isMethod("POST")) {
         $form->bind($request);
         if ($form->isValid()) {
             $media = $form->getData();
             $em->persist($media);
             $em->flush();
             $session->getFlashBag()->add('success', " Votre Photo a été ajoutée avec succées ");
             return $this->redirect($this->generateUrl("photos_hotel", array('id' => $hotel->getId())));
         }
     }
     return $this->render('BackHotelTunisieBundle:Hotels:photo.html.twig', array('hotel' => $hotel, 'form' => $form->createView(), 'images' => $hotel->getImages()));
 }
Ejemplo n.º 2
0
 public function villesphotoAction(Ville $ville)
 {
     $session = $this->getRequest()->getSession();
     $session->set("routing", $this->generateUrl("photos_villes", array('id' => $ville->getId())));
     $em = $this->getDoctrine()->getManager();
     $media = new Media();
     $media->setVille($ville);
     $form = $this->createForm(new MediaType(), $media);
     $request = $this->getRequest();
     if ($request->isMethod("POST")) {
         $form->bind($request);
         if ($form->isValid()) {
             $media = $form->getData();
             $em->persist($media);
             $em->flush();
             $session->getFlashBag()->add('success', " Votre Photo a été ajoutée avec succés ");
             return $this->redirect($this->generateUrl("photos_villes", array('id' => $ville->getId())));
         }
     }
     return $this->render('BackHotelTunisieBundle:referentiel/regionVille:photoVille.html.twig', array('ville' => $ville, 'form' => $form->createView(), 'images' => $ville->getImages()));
 }