MediaWiki REL1_34
GadgetRepo.php
Go to the documentation of this file.
1<?php
2
4
5abstract class GadgetRepo {
6
10 private static $instance;
11
20 abstract public function getGadgetIds();
21
29 abstract public function getGadget( $id );
30
39 public function handlePageUpdate( LinkTarget $target ) {
40 }
41
50 public function handlePageCreation( LinkTarget $target ) {
51 }
52
61 public function handlePageDeletion( LinkTarget $target ) {
62 }
63
69 public function getStructuredList() {
70 $list = [];
71 foreach ( $this->getGadgetIds() as $id ) {
72 try {
73 $gadget = $this->getGadget( $id );
74 } catch ( InvalidArgumentException $e ) {
75 continue;
76 }
77 $list[$gadget->getCategory()][$gadget->getName()] = $gadget;
78 }
79
80 return $list;
81 }
82
88 public static function singleton() {
89 if ( self::$instance === null ) {
90 global $wgGadgetsRepoClass; // @todo use Config here
91 self::$instance = new $wgGadgetsRepoClass();
92 }
93 return self::$instance;
94 }
95
101 public static function setSingleton( $repo = null ) {
102 self::$instance = $repo;
103 }
104}
static GadgetRepo null $instance
getGadget( $id)
Get the Gadget object for a given gadget id.
getGadgetIds()
Get the ids of the gadgets provided by this repository.
handlePageUpdate(LinkTarget $target)
Given that the provided page was updated, invalidate caches if necessary.
static singleton()
Get the configured default GadgetRepo.
handlePageDeletion(LinkTarget $target)
Given that the provided page was updated, invalidate caches if necessary.
handlePageCreation(LinkTarget $target)
Given that the provided page was created, invalidate caches if necessary.
getStructuredList()
Get a list of gadgets sorted by category.
static setSingleton( $repo=null)
Should only be used by unit tests.