Total Complexity | 5 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | final class ControllerSubscriber implements EventSubscriberInterface |
||
14 | { |
||
15 | private VerifyCsrfToken $middleware; |
||
16 | |||
17 | public function __construct(VerifyCsrfToken $middleware) |
||
18 | { |
||
19 | $this->middleware = $middleware; |
||
20 | } |
||
21 | |||
22 | public function onKernelController(ControllerEvent $event): void |
||
23 | { |
||
24 | $controller = $event->getController(); |
||
25 | if (\is_array($controller)) { |
||
26 | $controller = $controller[0]; |
||
27 | } |
||
28 | |||
29 | if ($controller instanceof AjaxController) { |
||
30 | $this->middleware->handle($event->getRequest()); |
||
31 | } |
||
32 | } |
||
33 | |||
34 | public static function getSubscribedEvents(): array |
||
38 | ]; |
||
39 | } |
||
40 | } |
||
41 |