Skip to content

Commit

Permalink
NEW Add updateRules extension point to Director::handleRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Jul 23, 2017
1 parent 4362012 commit 392cda1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Control/Director.php
Expand Up @@ -6,6 +6,7 @@
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;
Expand All @@ -32,6 +33,7 @@
class Director implements TemplateGlobalProvider
{
use Configurable;
use Extensible;
use Injectable;
use HTTPMiddlewareAware;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -313,6 +320,8 @@ public function handleRequest(HTTPRequest $request)

$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);
Expand Down

0 comments on commit 392cda1

Please sign in to comment.