silverstripe-cms/code/Controllers/ErrorPageFileExtension.php

26 lines
608 B
PHP
Raw Normal View History

<?php
2016-07-22 01:32:32 +02:00
namespace SilverStripe\CMS\Controllers;
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\DataObject;
2016-07-22 01:32:32 +02:00
use SilverStripe\CMS\Model\ErrorPage;
/**
* Decorates {@see File} with ErrorPage support
*/
2017-01-25 21:59:25 +01:00
class ErrorPageFileExtension extends DataExtension
{
2017-01-25 21:59:25 +01: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();
}
}