public function preparecommandeAction() { $session = $this->getRequest()->getSession(); $em = $this->getDoctrine()->getManager(); if (!$session->has('commande')) { $commande = new Commandes(); $commande->setDate(new \DateTime()); $commande->setUtilisateur($this->container->get('security.Context')->getToken()->getUser()); $commande->setValider(0); $commande->setReference(0); $commande->setCommande($this->facture()); $em->persist($commande); $session->set('commande', $commande); } else { $commande = $em->getRepository('EcommerceBundle:Commandes')->find($session->get('commande')); } //$commande= new Commandes(); /*if(!$session->has('commande')){ $em->persist($commande); $session->set('commande', $commande); } */ $em->flush(); //return $this->render("EcommerceBundle:Public:commande.html.twig"); return new Response($commande->getId()); }
/** * {@inheritDoc} */ public function setCommande($commande) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCommande', array($commande)); return parent::setCommande($commande); }