Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. public function add($name, $price)
  2. {
  3. $entityManager = $this->getDoctrine()->getManager();
  4. $product = new Product();
  5. $product->setName($name);
  6. $product->setPrice($price);
  7.  
  8. $entityManager->persist($product);
  9.  
  10. $entityManager->flush();
  11.  
  12. return new Response('Saved new product with id '.$product->getId());
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement