src/Publisher.php
public function generatePageResponse($url)
    {
        if (Director::is_relative_url($url)) {
            $url = Director::absoluteURL($url);
        }
        $urlParts = parse_url($url);
        if (!empty($urlParts['query'])) {
            parse_str($urlParts['query'], $getVars);
        } else {
            $getVars = [];
        }
        // back up requirements backend
        $origRequirements = Requirements::backend();
        Requirements::set_backend(Requirements_Backend::create());

        $origThemes = SSViewer::get_themes();
        $staticThemes = self::config()->get('static_publisher_themes');
        if ($staticThemes) {
            SSViewer::set_themes($staticThemes);
        } else {
            // get the themes raw from config to prevent the "running from the CMS" problem where no themes are live
            $rawThemes = SSViewer::config()->uninherited('themes');
            SSViewer::set_themes($rawThemes);
        }
        try {
            // try to add all the server vars that would be needed to create a static cache
            $request = HTTPRequestBuilder::createFromVariables(
                [
                    '_SERVER' => [
                        'REQUEST_URI' => isset($urlParts['path']) ? $urlParts['path'] : '',
                        'REQUEST_METHOD' => 'GET',
                        'REMOTE_ADDR' => '127.0.0.1',
                        'HTTPS' => $urlParts['scheme'] == 'https' ? 'on' : 'off',
                        'QUERY_STRING' => isset($urlParts['query']) ? $urlParts['query'] : '',
                        'REQUEST_TIME' => DBDatetime::now()->getTimestamp(),
                        'REQUEST_TIME_FLOAT' => (float)DBDatetime::now()->getTimestamp(),
                        'HTTP_HOST' => $urlParts['host'],
                        'HTTP_USER_AGENT' => 'silverstripe/staticpublishqueue',
                    ],
                    '_GET' => $getVars,
                    '_POST' => [],
                ],
                ''
            );
            $app = $this->getHTTPApplication();
            $response = $app->handle($request);

            if ($this->config()->get('add_timestamp') === true) {
                $response->setBody(
                    str_replace(
                        '</html>',
                        "<!-- " . DBDateTime::now()->Full() . " -->\n</html>",
                        $response->getBody()
                    )
                );
            }
        } catch (HTTPResponse_Exception $e) {
            $response = $e->getResponse();
        } finally {
            // restore backends
            SSViewer::set_themes($origThemes);
            Requirements::set_backend($origRequirements);
            DataObject::singleton()->flushCache();
        }
        return $response;
    }
public function generatePageResponse($url)
    {
        if (Director::is_relative_url($url)) {
            $url = Director::absoluteURL($url);
        }
        $urlParts = parse_url($url);
        if (!empty($urlParts['query'])) {
            parse_str($urlParts['query'], $getVars);
        } else {
            $getVars = [];
        }
        // back up requirements backend
        $origRequirements = Requirements::backend();
        Requirements::set_backend(Requirements_Backend::create());

        $origThemes = SSViewer::get_themes();
        $staticThemes = self::config()->get('static_publisher_themes');
        if ($staticThemes) {
            SSViewer::set_themes($staticThemes);
        } else {
            // get the themes raw from config to prevent the "running from the CMS" problem where no themes are live
            $rawThemes = SSViewer::config()->uninherited('themes');
            SSViewer::set_themes($rawThemes);
        }
        try {
            // try to add all the server vars that would be needed to create a static cache
            $request = HTTPRequestBuilder::createFromVariables(
                [
                    '_SERVER' => [
                        'REQUEST_URI' => isset($urlParts['path']) ? $urlParts['path'] : '',
                        'REQUEST_METHOD' => 'GET',
                        'REMOTE_ADDR' => '127.0.0.1',
                        'HTTPS' => $urlParts['scheme'] == 'https' ? 'on' : 'off',
                        'QUERY_STRING' => isset($urlParts['query']) ? $urlParts['query'] : '',
                        'REQUEST_TIME' => DBDatetime::now()->getTimestamp(),
                        'REQUEST_TIME_FLOAT' => (float)DBDatetime::now()->getTimestamp(),
                        'HTTP_HOST' => $urlParts['host'],
                        'HTTP_USER_AGENT' => 'silverstripe/staticpublishqueue',
                    ],
                    '_GET' => $getVars,
                    '_POST' => [],
                ],
                ''
            );
            $app = $this->getHTTPApplication();
            $response = $app->handle($request);

            if ($this->config()->get('add_timestamp') === true) {
                $response->setBody(
                    str_replace(
                        '</html>',
                        "<!-- " . DBDateTime::now()->Full() . " -->\n</html>",
                        $response->getBody()
                    )
                );
            }
        } catch (HTTPResponse_Exception $e) {
            $response = $e->getResponse();
        } finally {
            // restore backends
            SSViewer::set_themes($origThemes);
            Requirements::set_backend($origRequirements);
            DataObject::singleton()->flushCache();
        }
        return $response;
    }
@param string $url

@return HTTPResponse