Make "ControllerResolver" implements "RouterAwareInterface"

This commit is contained in:
Dmitriy Simushev 2014-07-04 12:25:57 +00:00
parent 42c1d4e340
commit 184e6ccdc3
2 changed files with 23 additions and 2 deletions

View File

@ -153,6 +153,11 @@ class Application implements RouterAwareInterface
public function setRouter(RouterInterface $router)
{
$this->router = $router;
// Update router in internal objects
if (!is_null($this->controllerResolver)) {
$this->controllerResolver->setRouter($router);
}
}
/**

View File

@ -23,7 +23,7 @@ use Mibew\Routing\RouterAwareInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\HttpFoundation\Request;
class ControllerResolver
class ControllerResolver implements RouterAwareInterface
{
/**
* @var RouterInterface|null
@ -48,6 +48,22 @@ class ControllerResolver
$this->authenticationManager = $manager;
}
/**
* {@inheritdoc}
*/
public function getRouter()
{
return $this->router;
}
/**
* {@inheritdoc}
*/
public function setRouter(RouterInterface $router)
{
$this->router = $router;
}
/**
* Resolves controller by request.
*
@ -102,7 +118,7 @@ class ControllerResolver
$object = new $class();
if ($object instanceof RouterAwareInterface) {
$object->setRouter($this->router);
$object->setRouter($this->getRouter());
}
if ($object instanceof AuthenticationManagerAwareInterface) {