Render the export form

When the method is POST, the form is stored if valid, and a redirection
is done to next step.

@param string $alias
@return \Symfony\Component\HttpFoundation\Response
510980
protected function exportFormStep(Request $request, $alias)
    {
        $exportManager = $this->get('chill.main.export_manager');
        
        // check we have data from the previous step (export step)
        $data = $this->get('session')->get('centers_step', null);
        
        if ($data === null) {
            
            return $this->redirectToRoute('chill_main_export_new', array(
               'step' => $this->getNextStep('export', true),
               'alias' => $alias
               ));
        }
        
        $export = $exportManager->getExport($alias);
                
        $form = $this->createCreateFormExport($alias, 'export', $data);
        
        if ($request->getMethod() === 'POST') {
            $form->handleRequest($request);
            if ($form->isValid()) {
                
                $this->get('logger')->debug('form export is valid', array(
                      'location' => __METHOD__));
                
                // store data for reusing in next steps
                $data = $form->getData();
                $this->get('session')->set('export_step_raw', 
                      $request->request->all());
                $this->get('session')->set('export_step', $data);
                
                //redirect to next step
                return $this->redirect(
                      $this->generateUrl('chill_main_export_new', array(
                         'step' => $this->getNextStep('export'),
                         'alias' => $alias
                      )));
            } else {
                $this->get('logger')->debug('form export is invalid', array(
                      'location' => __METHOD__));
            }
        }
        
        return $this->render('ChillMainBundle:Export:new.html.twig', array(
            'form' => $form->createView(),
            'export_alias' => $alias,
            'export' => $export
        ));
    }
508928
public function executeAction()
    {
        /**
         * The execute action will generate the Redsys
         * checkout form before redirecting
         */
        $formView = $this
            ->redsysManager
            ->processPayment();

        return new Response(
            $this
                ->templatingEngine
                ->render('RedsysBundle:Redsys:process.html.twig', [
                    'redsys_form' => $formView,
                ])
        );
    }
402787
public function editAction(Request $request, $type, $alias)
    {
        $this->performAccessChecks();

        $value = $request->get('value');

        $response = new Response();

        try {
            $this->cronService->updateCron($alias, $type, $value);
            $response->setStatusCode(
                200,
                $this->translator->trans('cron.edit.done', ['%type%' => $type, '%alias%' => $alias], 'smileezcron')
            );
        } catch (NotFoundException $e) {
            $response->setStatusCode(500, $e->getMessage());
        } catch (InvalidArgumentException $e) {
            $response->setStatusCode(500, $e->getMessage());
        }

        return $response;
    }
1244148
public function alias($alias = null)
    {
        if ($alias !== null) {
            $this->setAlias($alias);
        }

        return $this->getAlias();
    }
425972
public function render($template, array $parameters = null, Response $response = null)
    {
        return parent::render($this->bundle->getBaseDirectory().DIRECTORY_SEPARATOR.'Templates'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.$template, $parameters, $response);
    }
664230
public function display($alias)
    {
        $items = Nav::getMenu($alias, true);
        $this->set('menuItems', $this->_processMenuItems($items, $this->request->params));
    }
1037179
public function indexAction(Request $request)
    {
        $exportManager = $this->get('chill.main.export_manager');
        
        $exports = $exportManager->getExports(true);
        
        return $this->render('ChillMainBundle:Export:layout.html.twig', array(
            'exports' => $exports
        ));
    }
452712
public function export($format = 'text')
    {
        $className = '\\Expose\\Export\\'.ucwords(strtolower($format));
        if (class_exists($className)) {
            $export = new $className($this->getReports());
            return $export->render();
        }
        return null;
    }
419065
public function listAction(Request $request, FamilyInterface $family)
    {
        $this->setFamily($family);
        $dataGrid = $this->getDataGrid();

        $this->bindDataGridRequest($dataGrid, $request);

        // Handle quick export directly in datagrid
        $form = $dataGrid->getForm();
        if ($form->isSubmitted() && $form->isValid()) {
            $button = $form->getClickedButton();
            if ($button && 'export' === $button->getName()) {
                return $this->redirectToExport($dataGrid, $request->getSession());
            }
        }

        return $this->renderAction(
            array_merge(
                $this->getViewParameters($request),
                ['datagrid' => $dataGrid]
            )
        );
    }
185756
private function getLoader($alias)
    {
        if (!$this->hasLoader($alias)) {
            throw new \RuntimeException(sprintf('Form loader with alias "%s" not found.', $alias));
        }

        return $this->loaders[$alias];
    }
909765
public function saveAction(Request $request, Redirection $redirection)
    {
        $form = $this->getRedirectionForm($redirection, sprintf('#redirection-%d-item-container', $redirection->getId()));
        $form->handleRequest($request);

        if ($request->query->get('novalidate', false) === false) {
            $isOpened = true;
            if ($form->isValid()) {
                if ($redirection->getLink()->getLinkType() !== Link::TYPE_NONE) {
                    $isOpened = false;

                    $em = $this->getDoctrine()->getManager();
                    $em->flush();

                    $this->congrat($this->get('translator')->trans('victoire.redirection.modify.success'));
                } else {
                    // force form error when linkType === none
                    $form->addError(new FormError('victoire.404.form.error.blank'));
                }
            } else {
                $this->warn($this->get('translator')->trans('victoire.404.form.error.unvalid'));
            }

            return new Response($this->renderView('@VictoireSeo/Redirection/_list.html.twig', [
                'redirection' => $redirection,
                'form'        => $form->createView(),
                'isOpened'    => $isOpened,
            ]), 200, [
                'X-Inject-Alertify' => true,
            ]);
        }

        // rebuild form to avoid wrong form error
        $form = $this->getRedirectionForm($redirection, sprintf('#redirection-%d-item-container', $redirection->getId()));

        // refresh redirection.link to avoid empty link datas
        $this->getDoctrine()->getManager()->refresh($redirection->getLink());

        return new JsonResponse([
            'html' => $this->renderView('@VictoireSeo/Redirection/_list.html.twig', [
                'form'        => $form->createView(),
                'redirection' => $redirection,
                'isOpened'    => true,
            ]),
        ]);
    }
81145
public function render()
    {
        // set response headers
        @Common::stripHeader('Pragma');
        @Common::stripHeader('Expires');
        @Common::sendHeader('Content-Type: text/html; charset=UTF-8');
        @Common::sendHeader('Cache-Control: must-revalidate');
        @Common::sendHeader('X-Frame-Options: deny');

        $error = htmlspecialchars($this->error, ENT_QUOTES, 'UTF-8');
        $messages = htmlspecialchars(serialize($this->feedbackMessages), ENT_QUOTES, 'UTF-8');
        $tokenAuth = $this->tokenAuth;
        $httpsFail = (int) $this->httpsFail;

        // use a heredoc instead of an external file
        echo <<<END_OF_TEMPLATE
<!DOCTYPE html>
<html>
 <head>
  <meta name="robots" content="noindex,nofollow">
  <meta charset="utf-8">
  <title></title>
 </head>
 <body>
  <form name="myform" method="post" action="?module=CoreUpdater&amp;action=oneClickResults">
   <input type="hidden" name="token_auth" value="$tokenAuth" />
   <input type="hidden" name="error" value="$error" />
   <input type="hidden" name="messages" value="$messages" />
   <input type="hidden" name="httpsFail" value="$httpsFail" />
   <noscript>
    <button type="submit">Continue</button>
   </noscript>
  </form>
  <script type="text/javascript">
   document.myform.submit();
  </script>
 </body>
</html>
END_OF_TEMPLATE;
    }
1345118
public function render()
    {
        $returnValue = (string) '';

        
		
		(strpos($_SERVER['REQUEST_URI'], '?') > 0) ? $action = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')) : $action = $_SERVER['REQUEST_URI'];
		
		// Defensive code, prevent double leading slashes issue.
		if (substr($action, 0, 2) == '//'){
			$action = substr($action, 1);
		}
		
		$returnValue .= "<div class='xhtml_form'>\n";
		
		$returnValue .= "<form method='post' id='{$this->name}' name='{$this->name}' action='$action' ";
		if($this->hasFileUpload()){
			$returnValue .= "enctype='multipart/form-data' ";
		}
		$returnValue .= ">\n";
		
		$returnValue .= "<input type='hidden' class='global' name='{$this->name}_sent' value='1' />\n";
		
		
		//$returnValue .= $this->renderActions('top');
		
		if(!empty($this->error)){
			$returnValue .= '<div class="xhtml_form_error">'.$this->error.'</div>';
		}
		
		$returnValue .= $this->renderElements();
		
		$returnValue .= $this->renderActions('bottom');
		
		$returnValue .= "</form>\n";
        $returnValue .= "</div>\n";
		
        

        return (string) $returnValue;
    }
1197184
public function renderRequestForm($widget = true, FormInterface $form = null)
    {
        if (empty($form)) {
            $form = $this->passwordResetTokenFormFactory->createRequestForm();
        }

        $template = $widget
            ? 'DarvinUserBundle:PasswordResetToken/widget/request:form.html.twig'
            : 'DarvinUserBundle:PasswordResetToken:request.html.twig';

        return $this->templating->render($template, [
            'form' => $form->createView(),
        ]);
    }
957464
public function export_for_template(renderer_base $output) {
        ob_start();
        $this->display();
        $formhtml = ob_get_contents();
        ob_end_clean();
        $context = [
            'formhtml' => $formhtml
        ];
        return $context;
    }
438504
final protected function renderForm(array $arguments)
    {
        /*
         * We begin by setting up the form service: request results and form
         * instance are inserted in the service, and are used afterwards.
         *
         * There are only two ways to be sure the values injected are correct:
         * when the form was actually submitted by the user, or when the
         * argument `object` of the view helper is filled with a form instance.
         */
        $this->formService->activateFormContext();

        /*
         * If the form was submitted, applying custom behaviours on its fields.
         */
        $this->formService->applyBehavioursOnSubmittedForm($this->controllerContext);

        /*
         * Adding the default class configured in TypoScript configuration to
         * the form HTML tag.
         */
        $this->addDefaultClass();

        /*
         * Handling data attributes that are added to the form HTML tag,
         * depending on several parameters.
         */
        $this->handleDataAttributes();

        /*
         * Including JavaScript and CSS assets in the page renderer.
         */
        $this->handleAssets();

        $this->timeTracker->logTime('pre-render');

        /*
         * Getting the result of the original Fluid `FormViewHelper` rendering.
         */
        $result = $this->getParentRenderResult($arguments);

        /*
         * Language files need to be included at the end, because they depend on
         * what was used by previous assets.
         */
        $this->getAssetHandlerConnectorManager()
            ->getJavaScriptAssetHandlerConnector()
            ->includeLanguageJavaScriptFiles();

        return $result;
    }
34813
@Override
	public void render() {
		uri = ActionContext.getContextPath() + uri;
		try {
			Response.getServletResponse().sendRedirect(uri);
		} catch (IOException e) {
			throw new RenderException("Redirect to [" + uri + "] error!", e);
		}
	}