original_string: public function editBillingAction(Request $request)
      {
          if($request->isXmlHttpRequest()){
              $em = $this->container->get('doctrine')->getManager();
              $checkoutManager = $this->container->get('checkout_manager');
  
              /** @var Address $address */
              $address = $checkoutManager->getBillingAddress();
              $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage')));
  
              if ('POST' === $request->getMethod()) {
                  $form->handleRequest($request);
  
                  if ($form->isValid()) {
                      $em->persist($address);
                      $em->flush();
                      $url = $this->container->get('router')->generate('core_actor_profile').'?billing=1';
                      $this->container->get('session')->getFlashBag()->add('success', 'account.address.added');
                      return new JsonResponse(array('status' => 'success', 'url' => $url));
                  }else{
                      $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Billing/billing.form.html.twig", array(
                          'billing_form' => $form->createView(),
                          'address' => $address
                      ));
                      return new JsonResponse(array('status' => 'error', 'answer' => $template));
                  }
              }
          }else {
              throw new \Exception('Only by ajax');
          }
          
      }
code: public function editBillingAction(Request $request)
      {
          if($request->isXmlHttpRequest()){
              $em = $this->container->get('doctrine')->getManager();
              $checkoutManager = $this->container->get('checkout_manager');
  
              /** @var Address $address */
              $address = $checkoutManager->getBillingAddress();
              $form = $this->createForm('EcommerceBundle\Form\AddressType', $address, array('token_storage' => $this->container->get('security.token_storage')));
  
              if ('POST' === $request->getMethod()) {
                  $form->handleRequest($request);
  
                  if ($form->isValid()) {
                      $em->persist($address);
                      $em->flush();
                      $url = $this->container->get('router')->generate('core_actor_profile').'?billing=1';
                      $this->container->get('session')->getFlashBag()->add('success', 'account.address.added');
                      return new JsonResponse(array('status' => 'success', 'url' => $url));
                  }else{
                      $template = $this->container->get('twig')->render("EcommerceBundle:Profile:Billing/billing.form.html.twig", array(
                          'billing_form' => $form->createView(),
                          'address' => $address
                      ));
                      return new JsonResponse(array('status' => 'error', 'answer' => $template));
                  }
              }
          }else {
              throw new \Exception('Only by ajax');
          }
          
      }
code_tokens: public function editBillingAction ( Request $ request ) { if ( $ request -> isXmlHttpRequest ( ) ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; $ checkoutManager = $ this -> container -> get ( 'checkout_manager' ) ; /** @var Address $address */ $ address = $ checkoutManager -> getBillingAddress ( ) ; $ form = $ this -> createForm ( 'EcommerceBundle\Form\AddressType' , $ address , array ( 'token_storage' => $ this -> container -> get ( 'security.token_storage' ) ) ) ; if ( 'POST' === $ request -> getMethod ( ) ) { $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em -> persist ( $ address ) ; $ em -> flush ( ) ; $ url = $ this -> container -> get ( 'router' ) -> generate ( 'core_actor_profile' ) . '?billing=1' ; $ this -> container -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'account.address.added' ) ; return new JsonResponse ( array ( 'status' => 'success' , 'url' => $ url ) ) ; } else { $ template = $ this -> container -> get ( 'twig' ) -> render ( "EcommerceBundle:Profile:Billing/billing.form.html.twig" , array ( 'billing_form' => $ form -> createView ( ) , 'address' => $ address ) ) ; return new JsonResponse ( array ( 'status' => 'error' , 'answer' => $ template ) ) ; } } } else { throw new \ Exception ( 'Only by ajax' ) ; } }
docstring: Edit the billing address
  
  @param Request $request
  
  @Route("/profile/billing/")
  @Method({"GET","POST"})
docstring_tokens: Edit the billing address