2014-05-02 02:52:18 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enhances error handling for a controller with ErrorPage generated output
|
2015-09-29 06:18:03 +02:00
|
|
|
*
|
2014-05-02 02:52:18 +02:00
|
|
|
* @package cms
|
|
|
|
* @subpackage controller
|
|
|
|
*/
|
|
|
|
class ErrorPageControllerExtension extends Extension {
|
2015-09-29 06:18:03 +02:00
|
|
|
|
2016-01-26 06:38:42 +01:00
|
|
|
/**
|
|
|
|
* Used by {@see RequestHandler::httpError}
|
|
|
|
*
|
|
|
|
* @param int $statusCode
|
|
|
|
* @param SS_HTTPRequest $request
|
|
|
|
* @throws SS_HTTPResponse_Exception
|
|
|
|
*/
|
2014-05-02 02:52:18 +02:00
|
|
|
public function onBeforeHTTPError($statusCode, $request) {
|
|
|
|
$response = ErrorPage::response_for($statusCode);
|
|
|
|
if($response) {
|
|
|
|
throw new SS_HTTPResponse_Exception($response, $statusCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|