SHARE
TWEET

Untitled

a guest Apr 24th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     /**
  2.      * @Route("/{id}/edit", name="product_edit", methods={"GET","POST"})
  3.      */
  4.     public function edit(Request $request, ProductDTO $productDTO, Product $product): Response
  5.     {
  6.         $productDTO->setEntity($product);
  7.  
  8.         $form = $this->createForm(ProductType::class, $productDTO);
  9.         $form->handleRequest($request);
  10.  
  11.         if ($form->isSubmitted() && $form->isValid()) {
  12.             $entityManager = $this->getDoctrine()->getManager();
  13.             $entityManager->persist($productDTO->commit());
  14.             $entityManager->flush();
  15.  
  16.             $this->addFlash('success','Prodotto salvato con successo.');
  17.  
  18.             return $this->redirectToRoute('product_index', [
  19.                 'id' => $product->getId(),
  20.             ]);
  21.         }
  22.  
  23.         return $this->render('product/edit.html.twig', [
  24.             'product' => $productDTO,
  25.             'form' => $form->createView(),
  26.         ]);
  27.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top