Example #1
0
 /**
  *@Route("/createProduct",name="createProduct")
  */
 public function createProductAction()
 {
     // echo "123";exit;
     $data = new \Doctrine\Common\Collections\ArrayCollection(array(1, 2, 3));
     $data = $data->filter(function ($count) {
         return $count > 1;
     });
     exit;
     $category = new Category();
     $category->setName('Main Products');
     $product = new Product();
     $product->setName('Foo');
     $product->setPrice(19.99);
     $product->setDescription('Lorem ipsum dolor');
     // 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());
 }
 /**
  * {@inheritDoc}
  */
 public function getCategory()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCategory', array());
     return parent::getCategory();
 }