Пример #1
0
 /**
  * @Route("/paquete_addtocart/{id}", name="paquete_addtocart")
  */
 public function paqueteAddtocartAction(Paquete $paquete, Request $request)
 {
     if ($request->getMethod() == 'POST') {
         $idPaquete = $paquete->getId();
         $fecha = $this->get('request')->request->get('fecha');
         $pasajeros = $this->get('request')->request->get('pasajeros');
         $em = $this->getDoctrine()->getManager();
         $repoFecha = $em->getRepository('AppBundle:Fecha');
         $fechaObject = $repoFecha->findOneBy(array('paquete' => $paquete, 'fecha' => new \DateTime($fecha)));
         $carrito = new Carrito();
         $carrito->setFecha($fechaObject);
         $carrito->setCurrency("ARS");
         $carrito->setPasajeros($pasajeros);
         $em->persist($carrito);
         $em->flush();
         $this->get('session')->set('fechaId', $fechaObject->getId());
         $this->get('session')->set('pasajeros', $pasajeros);
         return $this->redirect($this->generateUrl('carrito_detalle', array('id' => 2)));
     }
 }
Пример #2
0
 /**
  * Creates a form to delete a Paquete entity by id.
  *
  * This is necessary because browsers don't support HTTP methods different
  * from GET and POST. Since the controller that removes the paquete paquetes expects
  * a DELETE method, the trick is to create a simple form that *fakes* the
  * HTTP DELETE method.
  * See http://symfony.com/doc/current/cookbook/routing/method_parameters.html.
  *
  * @param Paquete $paquete The paquete object
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Paquete $paquete)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('admin_paquete_delete', array('id' => $paquete->getId())))->setMethod('DELETE')->getForm();
 }