Symfony events: kernel.controller_arguments reference
20 November 2022 (Updated 20 November 2022)
On this page
When is it dispatched?
Dispatched just before a controller is called.
Use cases
- Configure the arguments passed to the controller (e.g., map URL route params to the corresponding named arguments or pass the current request object when the
Request
type-hint is used).
Example
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
public function onKernelControllerArguments(ControllerArgumentsEvent $event)
{
// ...
// get controller and request arguments
$namedArguments = $event->getRequest()->attributes->all();
$controllerArguments = $event->getArguments();
// set the controller arguments to modify the original arguments or add new ones
$event->setArguments($newArguments);
}
List event listeners
php bin/console debug:event-dispatcher kernel.controller_arguments
Sources
- Built-in Symfony Events – Symfony docs
- 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