Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. public function newOrderAction(Request $request)
  2. {
  3. $pedido = new Pedido();
  4. $metodoPago = new MetodoPago();
  5.  
  6. $pedido = new Pedido();
  7. $repositoryMetodoPago = $this->getDoctrine()->getRepository('ProjectBackendBundle:MetodoPago');
  8. $metodoPago = $repositoryMetodoPago->find(1);
  9.  
  10. $pedido->setMetodoPago($metodoPago);
  11.  
  12. $session = $this->get('session');
  13. $session->set('pedido', $pedido);
  14.  
  15. return new Response("jfs");
  16. }
  17.  
  18. public function saveOrderAction(Request $request)
  19. {
  20. $this->getDoctrine()->resetManager();
  21.  
  22. $session = $this->get('session');
  23. $pedido = $session->get('pedido');
  24.  
  25. $em = $this->getDoctrine()->getManager();
  26. $em->persist($pedido);
  27. $em->flush();
  28.  
  29. return new Response("jfs");
  30. }
  31.  
  32. class Pedido
  33. {
  34. /**
  35. * @ORMId
  36. * @ORMColumn(type="integer")
  37. * @ORMGeneratedValue(strategy="AUTO")
  38. */
  39. protected $id;
  40.  
  41. /**
  42. * @ORMManyToOne(targetEntity="MetodoPago", cascade={"persist", "remove"})
  43. * @ORMJoinColumn(name="metodo_pago_id", referencedColumnName="id")
  44. **/
  45. private $metodoPago;
  46.  
  47. /**
  48. * Get id
  49. *
  50. * @return integer
  51. */
  52. public function getId()
  53. {
  54. return $this->id;
  55. }
  56.  
  57. /**
  58. * Set metodoPago
  59. *
  60. * @param ProjectBackendBundleEntityMetodoPago $metodoPago
  61. * @return Pedido
  62. */
  63. public function setMetodoPago(ProjectBackendBundleEntityMetodoPago $metodoPago = null)
  64. {
  65. var_dump($metodoPago);
  66. $this->metodoPago = $metodoPago;
  67.  
  68. return $this;
  69. }
  70.  
  71. /**
  72. * Get metodoPago
  73. *
  74. * @return ProjectBackendBundleEntityMetodoPago
  75. */
  76. public function getMetodoPago()
  77. {
  78. return $this->metodoPago;
  79. }
  80. }
  81.  
  82.  
  83.  
  84.  
  85. class MetodoPago
  86. {
  87. /**
  88. * @ORMId
  89. * @ORMColumn(type="integer")
  90. * @ORMGeneratedValue(strategy="AUTO")
  91. */
  92. protected $id;
  93.  
  94. /**
  95. * @ORMColumn(type="string", name="nombre")
  96. */
  97. protected $nombre;
  98.  
  99. /**
  100. * @ORMColumn(type="float", name="precio")
  101. */
  102. protected $precio;
  103.  
  104.  
  105. /**
  106. * Get id
  107. *
  108. * @return integer
  109. */
  110. public function getId()
  111. {
  112. return $this->id;
  113. }
  114.  
  115. /**
  116. * Set nombre
  117. *
  118. * @param string $nombre
  119. * @return MetodoPago
  120. */
  121. public function setNombre($nombre)
  122. {
  123. $this->nombre = $nombre;
  124.  
  125. return $this;
  126. }
  127.  
  128. /**
  129. * Get nombre
  130. *
  131. * @return string
  132. */
  133. public function getNombre()
  134. {
  135. return $this->nombre;
  136. }
  137.  
  138. /**
  139. * Set precio
  140. *
  141. * @param float $precio
  142. * @return MetodoPago
  143. */
  144. public function setPrecio($precio)
  145. {
  146. $this->precio = $precio;
  147.  
  148. return $this;
  149. }
  150.  
  151. /**
  152. * Get precio
  153. *
  154. * @return float
  155. */
  156. public function getPrecio()
  157. {
  158. return $this->precio;
  159. }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement