When working on rSMINd94103f62fef: Provide a code structure for menus handling we noticed that the Main Menu building is achieved by calling different functions. Each function is responsible for building a single menu element. That approach has led to the situation where we have many functions in the following structure:
$group->insert( 'settings' ) ->addComponent( $this->context->msg( MENU_LABEL )->escaped(), SpecialPage::getTitleFor( SPECIAL_PAGE )->getLocalURL(), MinervaUI::iconClass( ICON_NAME , 'before' ), [ 'data-event-name' => EVENT_NAME ] );
To remove duplicated code, and significantly reduce the Definitions.php size, please provide a generic buildMenuEntry() function, and use this function in concrete Menu Builder classes.
To make code even more readable, buildMenuEntry() should not add menuEntry to the $group object - it should return it instead, and then the concrete Menu Builder implementation should build Menu groups.