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());
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $commande1 = new Commandes();
     $commande1->setUtilisateur($this->getReference('utilisateurs1'));
     $commande1->setValider('1');
     $commande1->setDate(new \DateTime());
     $commande1->setReference('1');
     $commande1->setProduits(array('0' => array('1' => '2'), '1' => array('2' => '1'), '2' => array('4' => '5')));
     $manager->persist($commande1);
     $commande2 = new Commandes();
     $commande2->setUtilisateur($this->getReference('utilisateurs2'));
     $commande2->setValider('1');
     $commande2->setDate(new \DateTime());
     $commande2->setReference('2');
     $commande2->setProduits(array('0' => array('1' => '2'), '1' => array('2' => '1'), '2' => array('4' => '5')));
     $manager->persist($commande2);
     $manager->flush();
 }
 /**
  * {@inheritDoc}
  */
 public function setDate($date)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDate', array($date));
     return parent::setDate($date);
 }