Airship\Engine\Landing::stasis PHP Method

stasis() protected method

Render lens content, cache it, then display it.
protected stasis ( string $name, variadic $cArgs ) : boolean
$name string
$cArgs variadic Constructor arguments
return boolean
    protected function stasis(string $name, ...$cArgs) : bool
    {
        // We don't want to cache anything tied to a session.
        $oldSession = $_SESSION;
        $_SESSION = [];
        $data = $this->airship_lens_object->render($name, ...$cArgs);
        $_SESSION = $oldSession;
        $port = $_SERVER['HTTP_PORT'] ?? '';
        $cacheKey = $_SERVER['HTTP_HOST'] . ':' . $port . '/' . $_SERVER['REQUEST_URI'];
        if (!$this->airship_filecache_object->set($cacheKey, $data)) {
            return false;
        }
        $state = State::instance();
        if (!\headers_sent()) {
            \header('Content-Type: text/html;charset=UTF-8');
            \header('Content-Language: ' . $state->lang);
            \header('X-Content-Type-Options: nosniff');
            \header('X-Frame-Options: SAMEORIGIN');
            // Maybe make this configurable down the line?
            \header('X-XSS-Protection: 1; mode=block');
            $hpkp = $state->HPKP;
            if ($hpkp instanceof HPKPBuilder) {
                $hpkp->sendHPKPHeader();
            }
            $csp = $state->CSP;
            if ($csp instanceof CSPBuilder) {
                $csp->sendCSPHeader();
                $this->airship_cspcache_object->set($_SERVER['REQUEST_URI'], \json_encode($csp->getHeaderArray()));
            }
        }
        die($data);
    }