NEW Add updateRules extension point to Director::handleRequest

This commit is contained in:
Robbie Averill 2017-07-21 14:58:44 +12:00
parent 43620129c0
commit 392cda15f6

View File

@ -6,6 +6,7 @@ use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Middleware\HTTPMiddlewareAware;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Kernel;
@ -32,6 +33,7 @@ use SilverStripe\View\TemplateGlobalProvider;
class Director implements TemplateGlobalProvider
{
use Configurable;
use Extensible;
use Injectable;
use HTTPMiddlewareAware;
@ -104,6 +106,11 @@ class Director implements TemplateGlobalProvider
*/
protected static $environment_type;
public function __construct()
{
$this->constructExtensions();
}
/**
* Test a URL request, returning a response object. This method is a wrapper around
* Director::handleRequest() to assist with functional testing. It will execute the URL given, and
@ -313,6 +320,8 @@ class Director implements TemplateGlobalProvider
$rules = Director::config()->uninherited('rules');
$this->extend('updateRules', $rules);
// Default handler - mo URL rules matched, so return a 404 error.
$handler = function () {
return new HTTPResponse('No URL rule was matched', 404);