mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
36 lines
746 B
PHP
36 lines
746 B
PHP
<?php
|
|
|
|
namespace SilverStripe\CMS\Controllers;
|
|
|
|
use Extension;
|
|
use SS_HTTPRequest;
|
|
use SS_HTTPResponse_Exception;
|
|
use SilverStripe\CMS\Model\ErrorPage;
|
|
|
|
|
|
/**
|
|
* Enhances error handling for a controller with ErrorPage generated output
|
|
*
|
|
* @package cms
|
|
* @subpackage controller
|
|
*/
|
|
class ErrorPageControllerExtension extends Extension {
|
|
|
|
/**
|
|
* Used by {@see RequestHandler::httpError}
|
|
*
|
|
* @param int $statusCode
|
|
* @param SS_HTTPRequest $request
|
|
* @throws SS_HTTPResponse_Exception
|
|
*/
|
|
public function onBeforeHTTPError($statusCode, $request) {
|
|
if (\Director::is_ajax()) {
|
|
return;
|
|
}
|
|
$response = ErrorPage::response_for($statusCode);
|
|
if($response) {
|
|
throw new SS_HTTPResponse_Exception($response, $statusCode);
|
|
}
|
|
}
|
|
}
|