2015-10-13 07:01:52 +02:00
|
|
|
<?php
|
|
|
|
|
2016-07-22 01:32:32 +02:00
|
|
|
namespace SilverStripe\CMS\Logging;
|
|
|
|
|
|
|
|
use SilverStripe\CMS\Model\ErrorPage;
|
2016-08-23 04:36:06 +02:00
|
|
|
use SilverStripe\Control\Director;
|
|
|
|
use SilverStripe\Logging\DebugViewFriendlyErrorFormatter;
|
2016-07-22 01:32:32 +02:00
|
|
|
|
2015-10-13 07:01:52 +02:00
|
|
|
/**
|
|
|
|
* Provides {@see ErrorPage}-gnostic error handling
|
|
|
|
*/
|
|
|
|
class ErrorPageErrorFormatter extends DebugViewFriendlyErrorFormatter {
|
2016-03-08 21:50:55 +01:00
|
|
|
|
2015-10-13 07:01:52 +02:00
|
|
|
public function output($statusCode) {
|
|
|
|
// Ajax content is plain-text only
|
2016-08-23 04:36:06 +02:00
|
|
|
if(Director::is_ajax()) {
|
2015-10-13 07:01:52 +02:00
|
|
|
return $this->getTitle();
|
|
|
|
}
|
2016-03-08 21:50:55 +01:00
|
|
|
|
2015-10-13 07:01:52 +02:00
|
|
|
// Determine if cached ErrorPage content is available
|
|
|
|
$content = ErrorPage::get_content_for_errorcode($statusCode);
|
|
|
|
if($content) {
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fallback to default output
|
|
|
|
return parent::output($statusCode);
|
|
|
|
}
|
|
|
|
}
|