Reputation: 113
as far as I read the Symfony-Documentation i can't find anything about the response handling in the kernel.controller
event.
For the kernel.request
event the documentation says:
If a Response is returned at this stage, the process skips directly to the kernel.response event.
But what about the kernel.controller
event?
If I'm returning a response in the kernel.controller
event listener the response is sent to the client but the process isn't canceled and the requested controller action is called.
Is it possible to send a response within the kernel.controller
event without proceeding to the requested controller?
Upvotes: 2
Views: 1593
Reputation: 6012
Indirectly, you can by changing the controller in the FilterControllerEvent.
You can use any callable as a controller, given that it returns a Response object in the end. In your event listener, you could for example do the following:
$event->setController(function() {
return new Response();
});
Of course you can return any kind of response in your controller.
Upvotes: 3