RedirectException example

// Does the RegEx match?             if (preg_match('#^' . $routeKey . '$#u', $uri$matches)) {
                // Is this route supposed to redirect to another?                 if ($this->collection->isRedirect($routeKey)) {
                    // replacing matched route groups with references: post/([0-9]+) -> post/$1                     $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function D) {
                        static $i = 1;

                        return '$' . $i++;
                    }is_array($handler) ? key($handler) : $handler);

                    throw new RedirectException(
                        preg_replace('#^' . $routeKey . '$#u', $redirectTo$uri),
                        $this->collection->getRedirectCode($routeKey)
                    );
                }
                // Store our locale so CodeIgniter object can                 // assign it to the Request.                 if (strpos($matchedKey, '{locale}') !== false) {
                    preg_match(
                        '#^' . str_replace('{locale}', '(?<locale>[^/]+)', $matchedKey) . '$#u',
                        $uri,
                        $matched
                    );
$request->getUri()->getFragment()
        );

        // Set an HSTS header         $response->setHeader('Strict-Transport-Security', 'max-age=' . $duration)
            ->redirect($uri)
            ->setStatusCode(307)
            ->setBody('')
            ->getCookieStore()
            ->clear();

        throw new RedirectException($response);
    }
}

if (function_exists('function_usable')) {
    /** * Function usable * * Executes a function_exists() check, and if the Suhosin PHP * extension is loaded - checks whether the function that is * checked might be disabled in there as well. * * This is useful as function_exists() will return FALSE for * functions disabled via the *disable_functions* php.ini * setting, but not for *suhosin.executor.func.blacklist* and * *suhosin.executor.disable_eval*. These settings will just * terminate script execution if a disabled function is executed. * * The above described behavior turned out to be a bug in Suhosin, * but even though a fix was committed for 0.9.34 on 2012-02-12, * that version is yet to be released. This function will therefore * be just temporary, but would probably be kept for a few years. * * @see http://www.hardened-php.net/suhosin/ * * @param string $functionName Function to check for * * @return bool TRUE if the function exists and is safe to call, * FALSE otherwise. * * @codeCoverageIgnore This is too exotic */
$this->getRequestObject();
        $this->getResponseObject();

        $this->spoofRequestMethod();

        try {
            $this->response = $this->handleRequest($routesconfig(Cache::class)$returnResponse);
        } catch (ResponsableInterface|DeprecatedRedirectException $e) {
            $this->outputBufferingEnd();
            if ($e instanceof DeprecatedRedirectException) {
                $e = new RedirectException($e->getMessage()$e->getCode()$e);
            }

            $this->response = $e->getResponse();
        } catch (PageNotFoundException $e) {
            $this->response = $this->display404errors($e);
        } catch (Throwable $e) {
            $this->outputBufferingEnd();

            throw $e;
        }

        
Home | Imprint | This part of the site doesn't use cookies.