Exemplo n.º 1
0
 public function postProductsAction(Request $request)
 {
     $name = $request->get('name');
     if (empty($name)) {
         throw new HttpException(400, 'Missing required parameters');
     }
     $product = new Product();
     $product->setName($name);
     $dm = $this->get('doctrine_mongodb')->getManager();
     $dm->persist($product);
     $dm->flush();
     $view = $this->view($product, 201);
     return $this->handleView($view);
 }
Exemplo n.º 2
0
 /**
  * @Route("/", name="homepage")
  */
 public function indexAction(Request $request)
 {
     $product = new Product();
     $product->setName('Selim Fraoua');
     $product->setSlug('Selim-Fraoua');
     $productVariant = new ProductVariant();
     $productVariant->setName('Variant 1');
     $product->addVariant($productVariant);
     $em = $this->get('doctrine_mongodb')->getManager();
     $em->persist($product);
     $em->flush();
     return $this->render('default/index.html.twig');
     //        $form = $this->createForm(new ProductType());
     //
     //
     //        $form->handleRequest($request);
     //        if($form->isValid()){
     //        }
     //
     //        $products = $this->get('doctrine_mongodb')->getRepository('AppBundle:Product')->findAll();
     //        dump($products);
 }