[FOLLOWUP][TASK] Have eIDs with PSR-7 without ControllerInterface 81/43381/2
authorNicole Cordes <typo3@cordes.co>
Wed, 16 Sep 2015 19:29:37 +0000 (21:29 +0200)
committerBenni Mack <benni@typo3.org>
Wed, 16 Sep 2015 19:48:27 +0000 (21:48 +0200)
The patch throws an exception for invalid classes without
an implemented __invoke() method.

Related: #69846
Releases: master
Change-Id: I73bede961ec9d314b86849d0a6d031201c8bbe92
Reviewed-on: http://review.typo3.org/43381
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/Http/Dispatcher.php

index c48072e..68ed8d8 100644 (file)
@@ -59,10 +59,11 @@ class Dispatcher implements DispatcherInterface {
 
                // Only a class name is given
                if (is_string($target) && strpos($target, ':') === FALSE) {
-                       $target = GeneralUtility::makeInstance($target);
-                       if (method_exists($target, '__invoke')) {
-                               return $target;
+                       $targetObject = GeneralUtility::makeInstance($target);
+                       if (!method_exists($targetObject, '__invoke')) {
+                               throw new \InvalidArgumentException('Object "' . $target . '" doesn\'t implement an __invoke() method and cannot be used as target.', 1442431631);
                        }
+                       return $targetObject;
                }
 
                // Check if the target is a concatenated string of "className::actionMethod"