2016-01-26 18:38:42 +13:00
|
|
|
<?php
|
|
|
|
|
2016-07-22 11:32:32 +12:00
|
|
|
namespace SilverStripe\CMS\Controllers;
|
|
|
|
|
2016-06-16 16:57:19 +12:00
|
|
|
use SilverStripe\ORM\DataExtension;
|
|
|
|
use SilverStripe\ORM\DataObject;
|
2016-07-22 11:32:32 +12:00
|
|
|
use SilverStripe\CMS\Model\ErrorPage;
|
|
|
|
|
2016-01-26 18:38:42 +13:00
|
|
|
/**
|
|
|
|
* Decorates {@see File} with ErrorPage support
|
|
|
|
*/
|
2017-01-26 09:59:25 +13:00
|
|
|
class ErrorPageFileExtension extends DataExtension
|
|
|
|
{
|
2016-01-26 18:38:42 +13:00
|
|
|
|
2017-01-26 09:59:25 +13:00
|
|
|
/**
|
|
|
|
* Used by {@see File::handle_shortcode}
|
|
|
|
*
|
|
|
|
* @param int $statusCode HTTP Error code
|
|
|
|
* @return DataObject Substitute object suitable for handling the given error code
|
|
|
|
*/
|
|
|
|
public function getErrorRecordFor($statusCode)
|
|
|
|
{
|
|
|
|
return ErrorPage::get()->filter("ErrorCode", $statusCode)->first();
|
|
|
|
}
|
2016-01-26 18:38:42 +13:00
|
|
|
}
|