[EventDispatcher] Register listener for security.interactive_login omitting the event name

Symfony version(s) affected: 4.4.5

Description
If the kernel.event_listener tag doesn’t define event, the method whose name is on + CamelCased event name should be executed. Tried it with security.interactive_login but it doesnt work.

How to reproduce

  1. Register all event listeners at once with:
services:
    App\EventListener\:
        resource: ../src/EventListener/*
        tags: [kernel.event_listener]
  1. Create new listener class
  2. If method __invoke is used – listener is executed correctly:
public function __invoke(InteractiveLoginEvent $event): void
{
   // code to execute
}
  1. Should be working the same with onSecurityInteractiveLogin method name too.

Additional context
Related to pull request: 33851

1 possible answer(s) on “[EventDispatcher] Register listener for security.interactive_login omitting the event name

  1. No, there are two separate situations here. The full tag definition is:

    { name: kernel.event_listener, event: security.interactive_login, method: onLogin }

    You can omit the method BUT NOT the event attribute if:

    • The listener has an __invoke() method
    • The listener has a camel-cased event name method: onSecurityInteractiveLogin()

    You can omit the method and event attribute if:

    • The listener has an __invoke() method with a correct typehint (InteractiveLoginEvent $event)