13
13
14
14
use Symfony \Bundle \FrameworkBundle \Controller \ControllerNameParser ;
15
15
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
16
- use Symfony \Component \HttpKernel \Event \GetResponseEvent ;
16
+ use Symfony \Component \HttpKernel \Event \RequestEvent ;
17
17
use Symfony \Component \HttpKernel \KernelEvents ;
18
18
19
19
/**
20
20
* Guarantees that the _controller key is parsed into its final format.
21
21
*
22
22
* @author Ryan Weaver <[email protected] >
23
23
*
24
+ * @method onKernelRequest(RequestEvent $event)
25
+ *
24
26
* @deprecated since Symfony 4.1
25
27
*/
26
28
class ResolveControllerNameSubscriber implements EventSubscriberInterface
@@ -36,8 +38,22 @@ public function __construct(ControllerNameParser $parser, bool $triggerDeprecati
36
38
$ this ->parser = $ parser ;
37
39
}
38
40
39
- public function onKernelRequest (GetResponseEvent $ event )
41
+ /**
42
+ * @internal
43
+ */
44
+ public function resolveControllerName (...$ args )
45
+ {
46
+ $ this ->onKernelRequest (...$ args );
47
+ }
48
+
49
+ public function __call (string $ method , array $ args )
40
50
{
51
+ if ('onKernelRequest ' !== $ method && 'onKernelRequest ' !== strtolower ($ method )) {
52
+ throw new \Error (sprintf ('Error: Call to undefined method %s::%s() ' , \get_class ($ this ), $ method ));
53
+ }
54
+
55
+ $ event = $ args [0 ];
56
+
41
57
$ controller = $ event ->getRequest ()->attributes ->get ('_controller ' );
42
58
if (\is_string ($ controller ) && false === strpos ($ controller , ':: ' ) && 2 === substr_count ($ controller , ': ' )) {
43
59
// controller in the a:b:c notation then
@@ -50,7 +66,7 @@ public function onKernelRequest(GetResponseEvent $event)
50
66
public static function getSubscribedEvents ()
51
67
{
52
68
return [
53
- KernelEvents::REQUEST => ['onKernelRequest ' , 24 ],
69
+ KernelEvents::REQUEST => ['resolveControllerName ' , 24 ],
54
70
];
55
71
}
56
72
}
0 commit comments