dispatcher = $dispatcher; $this->factory = $factory; } public function userTopbar(RequestStack $request): ItemInterface { $menu = $this->factory->createItem('root', [ 'childrenAttributes' => [ 'class' => 'navbar-nav mr-auto', ], ]); $this->dispatcher->dispatch( UserMenuEvent::EVENT, new UserMenuEvent($this->factory, $menu, $request) ); return $menu; } }