MediaWiki REL1_33
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}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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.
returning false will NOT prevent logging $e
Definition hooks.txt:2175