Okej, jest to jakieś wyjście, ale mnie chodzi trochę o coś innego. W kohanie nie ma (tak mi się wydaje, ponieważ nie znalazłem) plików odpowiedzialnych za stronę błędu, a korzysta z tych które są w apache. Przykładowo pokażę jak to wygląda w kohanie:
// Include the Controller file
require Router::$controller_path;
try
{
// Start validation of the controller
$class = new ReflectionClass
(ucfirst(Router
::$controller).'_Controller'); }
catch (ReflectionException $e)
{
// Controller does not exist
Event::run('system.404');
}
klasa Kohana_404_Exception:
/**
* Creates a Page Not Found exception.
*/
class Kohana_404_Exception extends Kohana_Exception {
protected $code = E_PAGE_NOT_FOUND;
/**
* Set internal properties.
*
* @param string URL of page
* @param string custom error template
*/
public function __construct($page = FALSE, $template = FALSE)
{
if ($page === FALSE)
{
// Construct the page URI using Router properties
$page = Router::$current_uri.Router::$url_suffix.Router::$query_string;
}
Exception::__construct(Kohana::lang('core.page_not_found', $page));
$this->template = $template;
}
/**
* Sends "File Not Found" headers, to emulate server behavior.
*
* @return void
*/
public function sendHeaders()
{
// Send the 404 header
header('HTTP/1.1 404 File Not Found'); }
} // End Kohana 404 Exception
I klasa Kohana_Exception:
/**
* Creates a generic i18n exception.
*/
class Kohana_Exception extends Exception {
// Template file
protected $template = 'kohana_error_page';
// Header
protected $header = FALSE;
// Error code
protected $code = E_KOHANA;
/**
* Set exception message.
*
* @param string i18n language key for the message
* @param array addition line parameters
*/
public function __construct($error)
{
// Fetch the error message
$message = Kohana::lang($error, $args);
if ($message === $error OR
empty($message)) {
// Unable to locate the message for the error
$message = 'Unknown Exception: '.$error;
}
// Sets $this->message the proper way
parent::__construct($message);
}
/**
* Magic method for converting an object to a string.
*
* @return string i18n message
*/
public function __toString()
{
return (string) $this->message;
}
/**
* Fetch the template name.
*
* @return string
*/
public function getTemplate()
{
return $this->template;
}
/**
* Sends an Internal Server Error header.
*
* @return void
*/
public function sendHeaders()
{
// Send the 500 header
header('HTTP/1.1 500 Internal Server Error'); }
} // End Kohana Exception
I z tych dwóch klas i tego kawałka kodu nie potrafię wywnioskować, w jaki sposób gdy router nie znajdzie kontrolera wywala 404 page not found :| ale okej, zrobię w taki sposób na który mnie naprowadziłeś, dzięki