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