sajad torkamani

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).


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

List event listeners

php bin/console debug:event-dispatcher kernel.controller_arguments


Tagged: Symfony