[HttpKernel] allowed any callable to be returned by ControllerResolver::createController
This commit is contained in:
parent
1552a16420
commit
8c447680b9
@ -76,13 +76,13 @@ class ControllerResolver implements ControllerResolverInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list($controller, $method) = $this->createController($controller);
|
$callable = $this->createController($controller);
|
||||||
|
|
||||||
if (!method_exists($controller, $method)) {
|
if (!is_callable($callable)) {
|
||||||
throw new \InvalidArgumentException(sprintf('Method "%s::%s" does not exist.', get_class($controller), $method));
|
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable.', $request->getPathInfo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($controller, $method);
|
return $callable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,6 +150,16 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(array($request), $resolver->getArguments($request, $controller), '->getArguments() injects the request');
|
$this->assertEquals(array($request), $resolver->getArguments($request, $controller), '->getArguments() injects the request');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCreateControllerCanReturnAnyCallable()
|
||||||
|
{
|
||||||
|
$mock = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolver', array('createController'));
|
||||||
|
$mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\some_controller_function'));
|
||||||
|
|
||||||
|
$request = Request::create('/');
|
||||||
|
$request->attributes->set('_controller', 'foobar');
|
||||||
|
$mock->getController($request);
|
||||||
|
}
|
||||||
|
|
||||||
public function __invoke($foo, $bar = null)
|
public function __invoke($foo, $bar = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user