Stash::not_found PHP Метод

not_found() публичный Метод

Output the 404 template with the correct header and exit
public not_found ( ) : string
Результат string
    public function not_found()
    {
        // try to prevent recursion
        if ($this->EE->output->out_type == "404") {
            return;
        }
        $url = FALSE;
        $template = explode('/', $this->EE->config->item('site_404'));
        if (isset($template[1])) {
            // build an absolute URL to the 404 template
            $url = $this->EE->functions->create_url($template[0] . '/' . $template[1]);
        }
        // We'll use cURL to grab the rendered 404 template
        // The template MUST be publicly accessible without being logged in
        if ($url && $this->EE->config->item('is_system_on') !== 'n' && is_callable('curl_init')) {
            // set header
            $this->EE->config->set_item('send_headers', FALSE);
            // trick EE into not sending a 200
            $this->EE->output->set_status_header('404');
            // grab the rendered 404 page
            $ch = curl_init();
            // set the url
            curl_setopt($ch, CURLOPT_URL, $url);
            // return it direct, don't print it out
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            // this connection will timeout in 10 seconds
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            $result = @curl_exec($ch);
            if (curl_errno($ch)) {
                log($ch);
                curl_close($ch);
            } else {
                die($result);
            }
        }
        // if cURL fails or system is off, fallback to a redirect
        if ($url) {
            $this->EE->functions->redirect($url, FALSE, '404');
        } else {
            $this->EE->TMPL->log_item('Stash: 404 template is not configured. Please select a 404 template in Design > Templates > Global Preferences.');
        }
    }