showMobileOptions = $showMobileOptions; $this->user = $user; $this->definitions = $definitions; } /** * @return Group[] * @throws FatalError * @throws MWException */ public function getGroups(): array { return [ $this->getDiscoveryTools(), $this->getPersonalTools(), $this->getConfigurationTools(), ]; } /** * Prepares a list of links that have the purpose of discovery in the main navigation menu * @return Group * @throws FatalError * @throws MWException */ protected function getDiscoveryTools(): Group { $group = new Group(); $this->definitions->insertHomeItem( $group ); $this->definitions->insertRandomItem( $group ); $this->definitions->insertNearbyIfSupported( $group ); // Allow other extensions to add or override tools Hooks::run( 'MobileMenu', [ 'discovery', &$group ] ); return $group; } /** * Builds the personal tools menu item group. * * ... by adding the Watchlist, Settings, and Log{in,out} menu items in the given order. * * @return Group * @throws FatalError * @throws MWException */ protected function getPersonalTools(): Group { $group = new Group(); $this->definitions->insertLogInOutMenuItem( $group ); if ( $this->user->isLoggedIn() ) { $this->definitions->insertWatchlistMenuItem( $group ); $this->definitions->insertContributionsMenuItem( $group ); } // Allow other extensions to add or override tools Hooks::run( 'MobileMenu', [ 'personal', &$group ] ); return $group; } /** * Like SkinMinerva#getDiscoveryTools and #getPersonalTools, create * a group of configuration-related menu items. Currently, only the Settings menu item is in the * group. * * @return Group * @throws MWException */ protected function getConfigurationTools(): Group { $group = new Group(); $this->showMobileOptions ? $this->definitions->insertMobileOptionsItem( $group ) : $this->definitions->insertPreferencesItem( $group ); return $group; } /** * Returns an array of sitelinks to add into the main menu footer. * @return Group Collection of site links * @throws MWException */ public function getSiteLinks(): Group { $group = new Group(); $this->definitions->insertAboutItem( $group ); $this->definitions->insertDisclaimersItem( $group ); // Allow other extensions to add or override tools Hooks::run( 'MobileMenu', [ 'sitelinks', &$group ] ); return $group; } }