MediaWiki REL1_30
GadgetRepo.php
Go to the documentation of this file.
1<?php
2
3abstract class GadgetRepo {
4
8 private static $instance;
9
18 abstract public function getGadgetIds();
19
27 abstract public function getGadget( $id );
28
34 public function getStructuredList() {
35 $list = [];
36 foreach ( $this->getGadgetIds() as $id ) {
37 try {
38 $gadget = $this->getGadget( $id );
39 } catch ( InvalidArgumentException $e ) {
40 continue;
41 }
42 $list[$gadget->getCategory()][$gadget->getName()] = $gadget;
43 }
44
45 return $list;
46 }
47
53 public static function singleton() {
54 if ( self::$instance === null ) {
55 global $wgGadgetsRepoClass; // @todo use Config here
56 self::$instance = new $wgGadgetsRepoClass();
57 }
58 return self::$instance;
59 }
60
66 public static function setSingleton( $repo = null ) {
67 self::$instance = $repo;
68 }
69}
static GadgetRepo null $instance
Definition GadgetRepo.php:8
getGadget( $id)
Get the Gadget object for a given gadget id.
getGadgetIds()
Get the ids of the gadgets provided by this repository.
static singleton()
Get the configured default GadgetRepo.
getStructuredList()
Get a list of gadgets sorted by category.
static setSingleton( $repo=null)
Should only be used by unit tests.
returning false will NOT prevent logging $e
Definition hooks.txt:2146