Your code is subscribing to a kernel event KernelEvents::REQUEST dispatched on every request.
TryBut you want to subscribe to the custom event 'mymodule_user_login'
. The array value is the callback method, not the event name
static function getSubscribedEvents() {
$events['mymodule_user_login'][] = ['onUserLoginCallback', 1];
return $events;
}
which receives the custom event object, not a core event:
public function onUserLoginCallback(MyEvent $event) {
...
}
BTW the dispatching code is deprecated. In Drupal 9 or higher swap both arguments:
$event_dispatcher->dispatch($event, 'mymodule_user_login');
See https://symfony.com/blog/new-in-symfony-4-3-simpler-event-dispatching