src/Flowcode/ShopBundle/Controller/AdminProductController.php
/**
     * Edits an existing Product entity.
     *
     * @Route("/{id}", name="admin_product_update")
     * @Method("PUT")
     * @Template("FlowcodeShopBundle:AdminProduct:edit.html.twig")
     */
Edits an existing Product entity.
Edits an existing Product entity .
public function updateAction(Request $request, Product $entity)
    {
        $em = $this->getDoctrine()->getManager();
        $entity = $this->addProductItemFieldData($entity);
        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Product entity.');
        }
        $deleteForm = $this->createDeleteForm($entity->getId());
        $editForm = $this->createEditForm($entity);
        $editForm->handleRequest($request);
        if ($editForm->isValid()) {
            foreach ($entity->getRawMaterials() as $productRawMaterial) {
                $productRawMaterial->setProduct($entity);
            }
            $em->flush();
            return $this->redirect($this->generateUrl('admin_product_show', array('id' => $entity->getId())));
        }
        return array(
            'entity' => $entity,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
public function updateAction ( Request $ request , Product $ entity ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ this -> addProductItemFieldData ( $ entity ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Product entity.' ) ; } $ deleteForm = $ this -> createDeleteForm ( $ entity -> getId ( ) ) ; $ editForm = $ this -> createEditForm ( $ entity ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isValid ( ) ) { foreach ( $ entity -> getRawMaterials ( ) as $ productRawMaterial ) { $ productRawMaterial -> setProduct ( $ entity ) ; } $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_product_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Edits an existing Product entity.
Edits an existing Product entity .
/* @var ProductRawMaterial $productRawMaterial */