silverstripe-cms/code/Controllers/ErrorPageControllerExtension.php
Damian Mooyman a87a857a6e
Upgrade code for framework namespaces
Remove @package / @subpackage
Fix inifinite loop in VirtualPage_Controller
2016-09-07 16:29:26 +12:00

33 lines
794 B
PHP

<?php
namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\ErrorPage;
use SilverStripe\Control\Director;
use SilverStripe\Control\SS_HTTPRequest;
use SilverStripe\Control\SS_HTTPResponse_Exception;
use SilverStripe\Core\Extension;
/**
* Enhances error handling for a controller with ErrorPage generated output
*/
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);
}
}
}