Symfony events: kernel.finish_request reference
20 November 2022 (Updated 20 November 2022)
When is it dispatched?
Dispatched after the kernel.response
event. See here for the relevant source code.
Use cases
- Reset the global state of the app (e.g., the translator listener resets the translator’s locale to that of the parent request).
Example
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
public function onKernelFinishRequest(FinishRequestEvent $event)
{
if (null === $parentRequest = $this->requestStack->getParentRequest()) {
return;
}
// reset the locale of the subrequest to the locale of the parent request
$this->setLocale($parentRequest);
}
List event listeners
php bin/console debug:event-dispatcher kernel.finish_request
- Symfony kernel events reference
- Symfony events: kernel.request reference
- Symfony events: kernel.controller reference
- Symfony events: kernel.controller_arguments reference
- Symfony events: kernel.view reference
- Symfony events: kernel.response reference
- Symfony events: kernel.finish_request reference
- Symfony events: kernel.terminate reference
- Symfony events: kernel.exception reference
Tagged:
Symfony
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment