original_string: public function editAction(Request $request, Product $product)
      {
          //access control
          $user = $this->container->get('security.token_storage')->getToken()->getUser();  
          if ($user->isGranted('ROLE_USER') && $product->getActor()->getId() != $user->getId()) {
              return $this->redirect($this->generateUrl('ecommerce_product_index'));
          }
         
          $formConfig = array();
          if ($user->isGranted('ROLE_USER')) { $formConfig['actor'] = $user; }
          $deleteForm = $this->createDeleteForm($product);
  
          $editForm = $this->createForm('EcommerceBundle\Form\ProductType', $product, $formConfig);
          $attributesForm = $this->createForm('EcommerceBundle\Form\ProductAttributesType', $product, array('category' => $product->getCategory()->getId()));
          $featuresForm = $this->createForm('EcommerceBundle\Form\ProductFeaturesType', $product, array('category' => $product->getCategory()->getId()));
          $relatedProductsForm = $this->createForm('EcommerceBundle\Form\ProductRelatedType', $product);
  
          if($request->getMethod('POST')){
              $redirectParams = array('id' => $product->getId());
  
              if ($request->request->has('product_attributes')) {
                  // attributes were submitted
                  $editForm = $attributesForm;
                  $redirectParams = array_merge($redirectParams, array('attributes' => 1));
              } else if ($request->request->has('product_features')) {
                  // features were submitted
                  $editForm = $featuresForm;
                  $redirectParams = array_merge($redirectParams, array('features' => 1));
              } else if ($request->request->has('product_related')) {
                  // related products were submitted
                  $editForm = $relatedProductsForm;
                  $redirectParams = array_merge($redirectParams, array('related' => 1));
              }
              $editForm->handleRequest($request);
  
              if ($editForm->isSubmitted() && $editForm->isValid()) {
                  $em = $this->getDoctrine()->getManager();
                  $em->persist($product);
                  $em->flush();
  
                  $this->get('session')->getFlashBag()->add('success', 'product.edited');
                  
                  return $this->redirectToRoute('ecommerce_product_show', $redirectParams);
              }
          }
          
          return array(
              'entity'          => $product,
              'edit_form'       => $editForm->createView(),
              'attributes_form' => $attributesForm->createView(),
              'features_form'   => $featuresForm->createView(),
              'related_form'    => $relatedProductsForm->createView(),
              'delete_form'     => $deleteForm->createView(),
          );
      }
code: public function editAction(Request $request, Product $product)
      {
          //access control
          $user = $this->container->get('security.token_storage')->getToken()->getUser();  
          if ($user->isGranted('ROLE_USER') && $product->getActor()->getId() != $user->getId()) {
              return $this->redirect($this->generateUrl('ecommerce_product_index'));
          }
         
          $formConfig = array();
          if ($user->isGranted('ROLE_USER')) { $formConfig['actor'] = $user; }
          $deleteForm = $this->createDeleteForm($product);
  
          $editForm = $this->createForm('EcommerceBundle\Form\ProductType', $product, $formConfig);
          $attributesForm = $this->createForm('EcommerceBundle\Form\ProductAttributesType', $product, array('category' => $product->getCategory()->getId()));
          $featuresForm = $this->createForm('EcommerceBundle\Form\ProductFeaturesType', $product, array('category' => $product->getCategory()->getId()));
          $relatedProductsForm = $this->createForm('EcommerceBundle\Form\ProductRelatedType', $product);
  
          if($request->getMethod('POST')){
              $redirectParams = array('id' => $product->getId());
  
              if ($request->request->has('product_attributes')) {
                  // attributes were submitted
                  $editForm = $attributesForm;
                  $redirectParams = array_merge($redirectParams, array('attributes' => 1));
              } else if ($request->request->has('product_features')) {
                  // features were submitted
                  $editForm = $featuresForm;
                  $redirectParams = array_merge($redirectParams, array('features' => 1));
              } else if ($request->request->has('product_related')) {
                  // related products were submitted
                  $editForm = $relatedProductsForm;
                  $redirectParams = array_merge($redirectParams, array('related' => 1));
              }
              $editForm->handleRequest($request);
  
              if ($editForm->isSubmitted() && $editForm->isValid()) {
                  $em = $this->getDoctrine()->getManager();
                  $em->persist($product);
                  $em->flush();
  
                  $this->get('session')->getFlashBag()->add('success', 'product.edited');
                  
                  return $this->redirectToRoute('ecommerce_product_show', $redirectParams);
              }
          }
          
          return array(
              'entity'          => $product,
              'edit_form'       => $editForm->createView(),
              'attributes_form' => $attributesForm->createView(),
              'features_form'   => $featuresForm->createView(),
              'related_form'    => $relatedProductsForm->createView(),
              'delete_form'     => $deleteForm->createView(),
          );
      }
code_tokens: public function editAction ( Request $ request , Product $ product ) { //access control $ user = $ this -> container -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ; if ( $ user -> isGranted ( 'ROLE_USER' ) && $ product -> getActor ( ) -> getId ( ) != $ user -> getId ( ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_product_index' ) ) ; } $ formConfig = array ( ) ; if ( $ user -> isGranted ( 'ROLE_USER' ) ) { $ formConfig [ 'actor' ] = $ user ; } $ deleteForm = $ this -> createDeleteForm ( $ product ) ; $ editForm = $ this -> createForm ( 'EcommerceBundle\Form\ProductType' , $ product , $ formConfig ) ; $ attributesForm = $ this -> createForm ( 'EcommerceBundle\Form\ProductAttributesType' , $ product , array ( 'category' => $ product -> getCategory ( ) -> getId ( ) ) ) ; $ featuresForm = $ this -> createForm ( 'EcommerceBundle\Form\ProductFeaturesType' , $ product , array ( 'category' => $ product -> getCategory ( ) -> getId ( ) ) ) ; $ relatedProductsForm = $ this -> createForm ( 'EcommerceBundle\Form\ProductRelatedType' , $ product ) ; if ( $ request -> getMethod ( 'POST' ) ) { $ redirectParams = array ( 'id' => $ product -> getId ( ) ) ; if ( $ request -> request -> has ( 'product_attributes' ) ) { // attributes were submitted $ editForm = $ attributesForm ; $ redirectParams = array_merge ( $ redirectParams , array ( 'attributes' => 1 ) ) ; } else if ( $ request -> request -> has ( 'product_features' ) ) { // features were submitted $ editForm = $ featuresForm ; $ redirectParams = array_merge ( $ redirectParams , array ( 'features' => 1 ) ) ; } else if ( $ request -> request -> has ( 'product_related' ) ) { // related products were submitted $ editForm = $ relatedProductsForm ; $ redirectParams = array_merge ( $ redirectParams , array ( 'related' => 1 ) ) ; } $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isSubmitted ( ) && $ editForm -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ product ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'product.edited' ) ; return $ this -> redirectToRoute ( 'ecommerce_product_show' , $ redirectParams ) ; } } return array ( 'entity' => $ product , 'edit_form' => $ editForm -> createView ( ) , 'attributes_form' => $ attributesForm -> createView ( ) , 'features_form' => $ featuresForm -> createView ( ) , 'related_form' => $ relatedProductsForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
docstring: Displays a form to edit an existing Product entity.
  
  @Route("/{id}/edit")
  @Method({"GET", "POST"})
  @Template()
docstring_tokens: Displays a form to edit an existing Product entity .