src/Flowcode/ShopBundle/Controller/AdminProductController.php
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()) {
            /* @var ProductRawMaterial $productRawMaterial */
            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()) {
            /* @var ProductRawMaterial $productRawMaterial */
            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 ( ) ) { /* @var ProductRawMaterial $productRawMaterial */ 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.

@Route("/{id}", name="admin_product_update")
@Method("PUT")
@Template("FlowcodeShopBundle:AdminProduct:edit.html.twig")
Edits an existing Product entity .