public function indexAction() { $product = new Product(); $product->setName('Hello'); $this->model->persist($product); $this->model->flush(); echo "Created Product with ID " . $product->getId() . "\n"; var_dump($this->request->getParams()); }
public function addProductAction() { if (!empty($_POST)) { $product = new Product(); $product->setName(htmlentities($_POST["name"])); $product->setContent(htmlentities($_POST["content"])); $em = $this->getEntityManager(); $em->persist($product); $em->flush(); return $this->redirectTo(); } return $this->renderView("productAdd.html.twig"); }