Exemplo n.º 1
0
 public function createProductAction()
 {
     $category = new Category();
     $category->setName("Rowery");
     $product = new Product();
     $product->setName("Rower biegowy");
     $product->setPrice(230.44);
     $product->setDescription("opis rowerka");
     $product->setCategory($category);
     $em = $this->getDoctrine()->getManager();
     $em->persist($category);
     $em->persist($product);
     $em->flush();
     return $this->render("AcmeStoreBundle:Default:Product.html.twig", array("product" => $product));
 }
Exemplo n.º 2
0
 public function createProductAction()
 {
     $category = new Category();
     $category->setName('Main Products ' . rand(1, 100));
     $product = new Product();
     $product->setName('Foo ' . rand(101, 200));
     $product->setPrice(19.99);
     $product->setDescription('Foo desc');
     // relate this product to the category
     $product->setCategory($category);
     $em = $this->getDoctrine()->getManager();
     $em->persist($category);
     $em->persist($product);
     $em->flush();
     return new Response('Created product id: ' . $product->getId() . ' and category id: ' . $category->getId());
 }
Exemplo n.º 3
0
 /**
  * Creates a form to delete a Category entity.
  *
  * @param Category $category The Category entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Category $category)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('category_delete', array('id' => $category->getId())))->setMethod('DELETE')->getForm();
 }