tokenStorage = $tokenStorage; $this->translator = $translator; } public function onUserMenuConfigure(UserMenuEvent $event) { $menu = $event->getItem(); /** @var User $user */ $user = $this->tokenStorage->getToken()->getUser(); $dropdown = $menu->addChild( $this->translator->trans('Hello %username%', ['%username%' => 'Noname'], 'usermenu'), ['dropdown' => true] ); $dropdown->addChild( $this->translator->trans('Login', [], 'usermenu'), ['route' => 'user_login'] ); } public static function getSubscribedEvents(): array { return [ UserMenuEvent::EVENT => 'onUserMenuConfigure', ]; } }