MediaWiki REL1_31
GadgetResourceLoaderModule.php
Go to the documentation of this file.
1<?php
2
11 private $id;
12
16 private $gadget;
17
21 public function __construct( array $options ) {
22 $this->id = $options['id'];
23 }
24
28 private function getGadget() {
29 if ( !$this->gadget ) {
30 try {
31 $this->gadget = GadgetRepo::singleton()->getGadget( $this->id );
32 } catch ( InvalidArgumentException $e ) {
33 // Fallback to a placeholder object...
34 $this->gadget = Gadget::newEmptyGadget( $this->id );
35 }
36 }
37
38 return $this->gadget;
39 }
40
46 protected function getPages( ResourceLoaderContext $context ) {
47 $gadget = $this->getGadget();
48 $pages = [];
49
50 foreach ( $gadget->getStyles() as $style ) {
51 $pages[$style] = [ 'type' => 'style' ];
52 }
53
55 foreach ( $gadget->getScripts() as $script ) {
56 $pages[$script] = [ 'type' => 'script' ];
57 }
58 }
59
60 return $pages;
61 }
62
69 return $this->getGadget()->getDependencies();
70 }
71
76 public function getType() {
77 return $this->getGadget()->getType() === 'styles'
80 }
81
82 public function getMessages() {
83 return $this->getGadget()->getMessages();
84 }
85
86 public function getTargets() {
87 return $this->getGadget()->getTargets();
88 }
89
90 public function getGroup() {
91 return 'site';
92 }
93}
static singleton()
Get the configured default GadgetRepo.
Class representing a list of resources for one gadget, basically a wrapper around the Gadget class.
getTargets()
Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'].
getDependencies(ResourceLoaderContext $context=null)
Overrides ResourceLoaderModule::getDependencies()
getPages(ResourceLoaderContext $context)
Overrides the function from ResourceLoaderWikiModule class.
getMessages()
Get the messages needed for this module.
getType()
Overrides ResourceLoaderWikiModule::getType()
Wrapper for one gadget.
Definition Gadget.php:17
supportsResourceLoader()
Definition Gadget.php:197
getStyles()
Definition Gadget.php:227
static newEmptyGadget( $id)
Get a placeholder object to use if a gadget doesn't exist.
Definition Gadget.php:104
getScripts()
Definition Gadget.php:220
Object passed around to modules which contains information about the state of a specific loader reque...
Abstraction for ResourceLoader modules which pull from wiki pages.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:2001
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2811
returning false will NOT prevent logging $e
Definition hooks.txt:2176