Airship\Engine\AutoPilot::serveFallback PHP Method

serveFallback() protected method

The fallback route handles: - Custom pages (if any exist), or - Redirects
protected serveFallback ( ) : mixed
return mixed
    protected function serveFallback()
    {
        // If we're still here, let's try the fallback handler
        if (isset($this->cabin['data']['route_fallback'])) {
            \preg_match('#^/?' . self::$patternPrefix . '/(.*)$#', $_SERVER['REQUEST_URI'], $args);
            try {
                return $this->serve($this->cabin['data']['route_fallback'], \explode('/', $args[1] ?? ''));
            } catch (FallbackLoop $e) {
                $state = State::instance();
                $state->logger->error('Missing route definition', ['exception' => \Airship\throwableToArray($e)]);
                // We only catch this one
            }
        }
        // If we don't have a fallback handler defined, just give a 404 status and kill the script.
        \http_response_code(404);
        exit(255);
    }