Router creates Dispatcher instance in overridable method

This commit is contained in:
PJ Dietz 2015-04-06 20:27:44 -04:00
parent 45b13691a2
commit d269970210
1 changed files with 10 additions and 1 deletions

View File

@ -67,11 +67,20 @@ class Router implements MiddlewareInterface
$statusCode = $response->getStatusCode(); $statusCode = $response->getStatusCode();
if (isset($this->statusHandlers[$statusCode])) { if (isset($this->statusHandlers[$statusCode])) {
$middleware = $this->statusHandlers[$statusCode]; $middleware = $this->statusHandlers[$statusCode];
$dispatcher = new Dispatcher(); $dispatcher = $this->getDispatcher();
$dispatcher->dispatch($middleware, $request, $response); $dispatcher->dispatch($middleware, $request, $response);
} }
} }
/**
* Return an instance that can dispatch middleware.
* Override to provide a custom class.
*/
protected function getDispatcher()
{
return new Dispatcher();
}
/** /**
* @return MethodMapInterface * @return MethodMapInterface
*/ */