Merge pull request #7197 from robbieaverill/pulls/4.0/add-updaterules-extension

NEW Add updateRules extension point to Director::handleRequest
This commit is contained in:
Damian Mooyman 2017-07-24 10:18:48 +12:00 committed by GitHub
commit 43f5a1fd7e

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);