silverstripe-cms/code/controllers/ErrorPageFileExtension.php
2016-06-24 11:00:21 +12:00

22 lines
496 B
PHP

<?php
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
/**
* Decorates {@see File} with ErrorPage support
*/
class ErrorPageFileExtension extends DataExtension {
/**
* 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();
}
}