`[ 'category' => [ 'name' => $gadget ] ]` */ public function getStructuredList() { $list = []; foreach ( $this->getGadgetIds() as $id ) { try { $gadget = $this->getGadget( $id ); } catch ( InvalidArgumentException $e ) { continue; } $list[$gadget->getCategory()][$gadget->getName()] = $gadget; } return $list; } /** * Get the script file name without the "MediaWiki:Gadget-" or "Gadget:" prefix. * This name is used by the client-side require() so that require("Data.json") resolves * to either "MediaWiki:Gadget-Data.json" or "Gadget:Data.json" depending on the * $wgGadgetsRepoClass configuration, enabling easy migration between the configuration modes. * * @param string $titleText * @return string */ public function titleWithoutPrefix( string $titleText ): string { $numReplaces = 1; // there will only one occurrence of the prefix return str_replace( $this->titlePrefix, '', $titleText, $numReplaces ); } /** * Get the configured default GadgetRepo. * * @return GadgetRepo */ public static function singleton() { if ( self::$instance === null ) { // @todo use Config here global $wgGadgetsRepoClass; // @phan-suppress-next-line PhanPossiblyUndeclaredVariable self::$instance = new $wgGadgetsRepoClass(); } return self::$instance; } /** * Should only be used by unit tests * * @param GadgetRepo|null $repo */ public static function setSingleton( $repo = null ) { self::$instance = $repo; } }