Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function newOrderAction(Request $request)
- {
- $pedido = new Pedido();
- $metodoPago = new MetodoPago();
- $pedido = new Pedido();
- $repositoryMetodoPago = $this->getDoctrine()->getRepository('ProjectBackendBundle:MetodoPago');
- $metodoPago = $repositoryMetodoPago->find(1);
- $pedido->setMetodoPago($metodoPago);
- $session = $this->get('session');
- $session->set('pedido', $pedido);
- return new Response("jfs");
- }
- public function saveOrderAction(Request $request)
- {
- $this->getDoctrine()->resetManager();
- $session = $this->get('session');
- $pedido = $session->get('pedido');
- $em = $this->getDoctrine()->getManager();
- $em->persist($pedido);
- $em->flush();
- return new Response("jfs");
- }
- class Pedido
- {
- /**
- * @ORMId
- * @ORMColumn(type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORMManyToOne(targetEntity="MetodoPago", cascade={"persist", "remove"})
- * @ORMJoinColumn(name="metodo_pago_id", referencedColumnName="id")
- **/
- private $metodoPago;
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set metodoPago
- *
- * @param ProjectBackendBundleEntityMetodoPago $metodoPago
- * @return Pedido
- */
- public function setMetodoPago(ProjectBackendBundleEntityMetodoPago $metodoPago = null)
- {
- var_dump($metodoPago);
- $this->metodoPago = $metodoPago;
- return $this;
- }
- /**
- * Get metodoPago
- *
- * @return ProjectBackendBundleEntityMetodoPago
- */
- public function getMetodoPago()
- {
- return $this->metodoPago;
- }
- }
- class MetodoPago
- {
- /**
- * @ORMId
- * @ORMColumn(type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORMColumn(type="string", name="nombre")
- */
- protected $nombre;
- /**
- * @ORMColumn(type="float", name="precio")
- */
- protected $precio;
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set nombre
- *
- * @param string $nombre
- * @return MetodoPago
- */
- public function setNombre($nombre)
- {
- $this->nombre = $nombre;
- return $this;
- }
- /**
- * Get nombre
- *
- * @return string
- */
- public function getNombre()
- {
- return $this->nombre;
- }
- /**
- * Set precio
- *
- * @param float $precio
- * @return MetodoPago
- */
- public function setPrecio($precio)
- {
- $this->precio = $precio;
- return $this;
- }
- /**
- * Get precio
- *
- * @return float
- */
- public function getPrecio()
- {
- return $this->precio;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement