diff options
author | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2016-04-03 16:04:59 +0200 |
---|---|---|
committer | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2016-04-03 16:04:59 +0200 |
commit | e8762ce3cb25faddfb1797377208876e1e65c785 (patch) | |
tree | 42a2d35a310dcba88927bb46715f432377f585f3 /phpBB/phpbb/controller | |
parent | 8769e765a2e3cb4fb78d4f9d66e6e72bff9a0649 (diff) | |
parent | 01d56673889cb12a11fca24b62f6e93e1c9f8dd8 (diff) | |
download | forums-e8762ce3cb25faddfb1797377208876e1e65c785.tar forums-e8762ce3cb25faddfb1797377208876e1e65c785.tar.gz forums-e8762ce3cb25faddfb1797377208876e1e65c785.tar.bz2 forums-e8762ce3cb25faddfb1797377208876e1e65c785.tar.xz forums-e8762ce3cb25faddfb1797377208876e1e65c785.zip |
Merge pull request #4266 from marc1706/ticket/13502
[ticket/13502] Handle callable functions/objects in controller resolver
* marc1706/ticket/13502:
[ticket/13502] Also cover passing object to resolver in tests
[ticket/13502] Test getArguments() method of controller resolver
[ticket/13502] Fix coding style
[ticket/13502] Controller resolver should handle callable functions and objects
Diffstat (limited to 'phpBB/phpbb/controller')
-rw-r--r-- | phpBB/phpbb/controller/resolver.php | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/phpBB/phpbb/controller/resolver.php b/phpBB/phpbb/controller/resolver.php index 4f432c3323..f8dffc12de 100644 --- a/phpBB/phpbb/controller/resolver.php +++ b/phpBB/phpbb/controller/resolver.php @@ -126,9 +126,21 @@ class resolver implements ControllerResolverInterface */ public function getArguments(Request $request, $controller) { - // At this point, $controller contains the object and method name - list($object, $method) = $controller; - $mirror = new \ReflectionMethod($object, $method); + // At this point, $controller should be a callable + if (is_array($controller)) + { + list($object, $method) = $controller; + $mirror = new \ReflectionMethod($object, $method); + } + else if (is_object($controller) && !$controller instanceof \Closure) + { + $mirror = new \ReflectionObject($controller); + $mirror = $mirror->getMethod('__invoke'); + } + else + { + $mirror = new \ReflectionFunction($controller); + } $arguments = array(); $parameters = $mirror->getParameters(); |