Handle submit triggered button.

If the button save and back triggered.
Clear the data from session and redirect to list view.

@param Action               $action      The action.
@param EnvironmentInterface $environment The environment.

@return void
487200
protected function handleSubmit(Action $action, EnvironmentInterface $environment)
    {
        $inputProvider   = $environment->getInputProvider();
        $sessionStorage  = $environment->getSessionStorage();
        $eventDispatcher = $environment->getEventDispatcher();

        if (('auto' === $inputProvider->getValue('SUBMIT_TYPE'))
            || !$inputProvider->hasValue($this->getMode($action) . '_saveNback')) {
            return;
        }

        $sessionStorage->remove($environment->getDataDefinition()->getName() . '.' . $this->getMode($action));

        $urlEvent = new GetReferrerEvent(false, $environment->getDataDefinition()->getName());

        $eventDispatcher->dispatch(ContaoEvents::SYSTEM_GET_REFERRER, $urlEvent);
        $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent($urlEvent->getReferrerUrl()));
    }
362890
public function load(Action $action)
    {
        if ($action instanceof LoggerAwareInterface) {
            $action->setLogger(
                $this->getServiceLocator()->get(LoggerService::SERVICE_ID)
                    ->addLogger(
                        $this->hideColors
                            ? new VerboseLogger($this->getMinimumLogLevel())
                            : new ColoredVerboseLogger($this->getMinimumLogLevel())
                    )
            );
        }
    }
344054
public function handleAction($action, $actionParams)
    {
        $this->setView($action);
        $response = parent::handleAction($action, $actionParams);

        if ($response instanceof Response) {
            return $response;
        }

        if (is_string($response)) {
            $this->controllerView->content = $response;
        } elseif (isset($this->view)) {
            $this->controllerView->content = $this->view->render();
        }

        $this->response->setContent($this->controllerView->render());

        return $this->response;
    }
105141
protected function handleAction($request, $action)
    {
        foreach ($request->latestParams() as $k => $v) {
            if ($v || !isset($this->urlParams[$k])) {
                $this->urlParams[$k] = $v;
            }
        }

        $this->action = $action;
        $this->requestParams = $request->requestVars();

        if ($this->hasMethod($action)) {
            $result = parent::handleAction($request, $action);

            // If the action returns an array, customise with it before rendering the template.
            if (is_array($result)) {
                return $this->getViewer($action)->process($this->customise($result));
            } else {
                return $result;
            }
        }

        // Fall back to index action with before/after handlers
        $beforeResult = $this->extend('beforeCallActionHandler', $request, $action);
        if ($beforeResult) {
            return reset($beforeResult);
        }

        $result = $this->getViewer($action)->process($this);

        $afterResult = $this->extend('afterCallActionHandler', $request, $action, $result);
        if ($afterResult) {
            return reset($afterResult);
        }

        return $result;
    }
299271
private function checkPermission(ActionEvent $event)
    {
        $environment = $event->getEnvironment();

        if (true === $environment->getDataDefinition()->getBasicDefinition()->isEditable()) {
            return true;
        }

        $event->setResponse(
            \sprintf(
                '<div style="text-align:center; font-weight:bold; padding:40px;">
                    You have no permission for toggle %s.
                </div>',
                $this->getOperation($event->getAction(), $environment)->getToggleProperty()
            )
        );

        return false;
    }
230125
private function checkLanguageSubmit($environment, $languages)
    {
        $inputProvider = $environment->getInputProvider();

        if ('language_switch' !== $inputProvider->getValue('FORM_SUBMIT')) {
            return;
        }

        // Get/Check the new language.
        if ($inputProvider->hasValue('language')
            && \array_key_exists($inputProvider->getValue('language'), $languages)
        ) {
            $session['ml_support'][$environment->getDataDefinition()->getName()] = $inputProvider->getValue('language');
            $environment->getSessionStorage()->set('dc_general', $session);
        }

        $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_RELOAD, new ReloadEvent());
    }
1060909
public function setActionParameters($action, array $parameters): void
    {
        if ('submit_button' === $action) {
            $this->setSubmitButton(
                array_merge(
                    $this->getSubmitButton(),
                    [
                        'route_parameters' => $parameters,
                    ]
                )
            );

            return;
        }
        if ('reset_button' === $action) {
            $this->setResetButton(
                array_merge(
                    $this->getResetButton(),
                    [
                        'route_parameters' => $parameters,
                    ]
                )
            );

            return;
        }
        $this->setAction(
            $action,
            array_merge(
                $this->getAction($action),
                [
                    'route_parameters' => $parameters,
                ]
            )
        );
    }
304948
private function handleCutAllAction(EnvironmentInterface $environment, Action $action)
    {
        $inputProvider = $environment->getInputProvider();
        foreach ($this->getModelIds($environment, $action, $this->getSubmitAction($environment)) as $modelId) {
            $inputProvider->setParameter('source', $modelId->getSerialized());

            $this->callAction($environment, 'cut');

            $inputProvider->unsetParameter('source');
        }

        ViewHelpers::redirectHome($environment);

        return null;
    }
863483
protected function executePhpAction(Config\Action $action) : void
    {
        $this->beforeAction();
        $runner = new Action\PHP();
        $runner->execute($this->config, $this->io, $this->repository, $action);
        $this->afterAction();
    }
159769
protected function _event($action, $data = [])
    {
        $_event = new Event('Controller.PostTypes.' . $this->type['name'] . '.' . $action, $this, $data);
        $this->eventManager()->dispatch($_event);
    }
213519
public function beginForm(string $name, string $action): void
    {
        $this->formOptions = $this->getFormOptions($name);

        $form = "<form id=\"{$name}\" action=\"{$action}\" method=\"post\"";

        $usePjax = (isset($this->formOptions['use_pjax'])) ?
            filter_var($this->formOptions['use_pjax'], FILTER_VALIDATE_BOOLEAN)
            : true;

        $pjaxAttr = ($usePjax) ? 'data-pjax' : '';

        foreach ($this->formOptions as $attr => $value) {
            if (in_array($attr, ['use_pjax', 'use_csrf', 'fields'])) {
                continue;
            }

            $form .= " {$attr}=\"{$value}\"";
        }

        echo "$form $pjaxAttr>";
    }
135261
public function handleAction($request, $action)
    {
        $handles = parent::allowedActions(false);
        $defaultMapping = $this->stat('allowed_actions');
        $handles['index'] = 'handleIndex';
        $siteConfig = SiteConfig::current_site_config();
        foreach ($defaultMapping as $key) {
            $map = ucfirst($key . 'Action');
            if ($siteConfig->$map) {
                $handles[$siteConfig->$map] = $key;
            }
            if (!array_key_exists($key, $handles)) {
                $handles[$key] = $key;
            }
        }
        self::$url_handlers = $handles;
        $this->needsRedirect();

        return parent::handleAction($request, $handles[$action]);
    }
1256553
public function handleAction($request, $action)
    {
        // if we submitted a form, let that pass
        if (!$request->isGET() && !$request->isHEAD()) {
            return parent::handleAction($request, $action);
        }

        $url = $request->getURL();

        //
        // If the current request has an extension attached to it, strip that
        // off and redirect the user to the page without an extension.
        //
        if (DocumentationHelper::get_extension($url)) {
            $this->response = new SS_HTTPResponse();
            $this->response->redirect(
                Director::absoluteURL(DocumentationHelper::trim_extension_off($url)) .'/',
                301
            );

            $request->shift();
            $request->shift();

            return $this->response;
        }

        //
        // Strip off the base url
        //
        $base = ltrim(
            Config::inst()->get('DocumentationViewer', 'link_base'),
            '/'
        );

        if ($base && strpos($url, $base) !== false) {
            $url = substr(
                ltrim($url, '/'),
                strlen($base)
            );
        }

        //
        // Handle any permanent redirections that the developer has defined.
        //
        if ($link = DocumentationPermalinks::map($url)) {
            // the first param is a shortcode for a page so redirect the user to
            // the short code.
            $this->response = new SS_HTTPResponse();
            $this->response->redirect($link, 301);

            $request->shift();
            $request->shift();

            return $this->response;
        }

        //
        // Validate the language provided. Language is a required URL parameter.
        // as we use it for generic interfaces and language selection. If
        // language is not set, redirects to 'en'
        //
        $languages = i18n::get_common_languages();

        if (!$lang = $request->param('Lang')) {
            $lang = $request->param('Action');
            $action = $request->param('ID');
        } else {
            $action = $request->param('Action');
        }

        if (!$lang) {
            return $this->redirect($this->Link('en'));
        } elseif (!isset($languages[$lang])) {
            return $this->httpError(404);
        }

        $request->shift(10);

        $allowed = $this->config()->allowed_actions;

        if (in_array($action, $allowed)) {
            //
            // if it's one of the allowed actions such as search or all then the
            // URL must be prefixed with one of the allowed languages and versions
            //
            return parent::handleAction($request, $action);
        } else {
            //
            // look up the manifest to see find the nearest match against the
            // list of the URL. If the URL exists then set that as the current
            // page to match against.

            // strip off any extensions.


            // if($cleaned !== $url) {
            // 	$redirect = new SS_HTTPResponse();

            // 	return $redirect->redirect($cleaned, 302);
            // }
            if ($record = $this->getManifest()->getPage($url)) {
                // In SS 3 offsetSet() isn't implemented for some reason... this is a workaround
                $routeParams = $this->request->routeParams();
                $routeParams['Lang'] = $lang;
                $this->request->setRouteParams($routeParams);

                $this->record = $record;
                $this->init();

                $type = get_class($this->record);
                $body = $this->renderWith(
                    array(
                        "DocumentationViewer_{$type}",
                        'DocumentationViewer'
                    )
                );

                return new SS_HTTPResponse($body, 200);
            } elseif ($redirect = $this->getManifest()->getRedirect($url)) {
                $response = new SS_HTTPResponse();
                $to = Controller::join_links(Director::baseURL(), $base, $redirect);
                return $response->redirect($to, 301);
            } elseif (!$url || $url == $lang) {
                $body = $this->renderWith(
                    array(
                        'DocumentationViewer_DocumentationFolder',
                        'DocumentationViewer'
                    )
                );

                return new SS_HTTPResponse($body, 200);
            }
        }

        return $this->httpError(404);
    }
289070
public void add(final AtomicAction action) {
        if (action instanceof Action) {
            Action a = (Action)action;
            peforms.addAll(a.peforms);
            backouts.addAll(a.backouts);
            cleanUps.addAll(a.cleanUps);
        } else {
            add(new ActionBlock() {
                @Override
                public void execute() throws ActionException {
                    action.perform();
                }
            }, new ActionBlock() {
                @Override
                public void execute() throws ActionException {
                    action.backout();
                }
            }, new ActionBlock() {
                @Override
                public void execute() throws ActionException {
                    action.cleanup();
                }
            });
        }
    }
210450
protected function handleAction($request, $action)
	{
		$module = $this->findModule();
		
		if(!$module) {
			return parent::handleAction($request, $action);
		}
		
		$data = [];
		
		if($this->isGreenPage()) {
			$data = $this->data()->toViewableData();
		}
		elseif($module->getDataSource()) {
			$data = $module->getDataSource()->toDBObject();
		}

		$module->loadRequirements();
		$viewer = $this->getViewer($action);					
		$viewer->setTemplateFile('Layout', $module->getLayoutTemplateFile());

		$main = $module->getMainTemplateFile();
		if($main) {
			$viewer->setTemplateFile('main', $main);
		}
		
		return $viewer->process($this->customise($data));
	}
70135
public function doAction($action,$params){
        if(method_exists($this,$action)){
            $this->$action($params);
        }
        else{
            $this->ActionNotFound($action,$params);
        }
    }
1340701
public static function handleFilter($action = '')
    {
        if (!$action) {
            return true;
        }

        if (self::hasFilter($action)) {
            $callback = self::$filters[$action];
            return $callback();
        }

        return false;
    }