MediaWiki REL1_30
GadgetResourceLoaderModule.php
Go to the documentation of this file.
1<?php
2
11 private $id;
12
16 private $gadget;
17
23 public function __construct( array $options ) {
24 $this->id = $options['id'];
25 }
26
30 private function getGadget() {
31 if ( !$this->gadget ) {
32 try {
33 $this->gadget = GadgetRepo::singleton()->getGadget( $this->id );
34 } catch ( InvalidArgumentException $e ) {
35 // Fallback to a placeholder object...
36 $this->gadget = Gadget::newEmptyGadget( $this->id );
37 }
38 }
39
40 return $this->gadget;
41 }
42
48 protected function getPages( ResourceLoaderContext $context ) {
49 $gadget = $this->getGadget();
50 $pages = [];
51
52 foreach ( $gadget->getStyles() as $style ) {
53 $pages[$style] = [ 'type' => 'style' ];
54 }
55
57 foreach ( $gadget->getScripts() as $script ) {
58 $pages[$script] = [ 'type' => 'script' ];
59 }
60 }
61
62 return $pages;
63 }
64
71 return $this->getGadget()->getDependencies();
72 }
73
78 public function getType() {
79 return $this->getGadget()->getType() === 'styles'
82 }
83
84 public function getMessages() {
85 return $this->getGadget()->getMessages();
86 }
87
88 public function getTargets() {
89 return $this->getGadget()->getTargets();
90 }
91
92 public function getGroup() {
93 return 'site';
94 }
95}
static singleton()
Get the configured default GadgetRepo.
Class representing a list of resources for one gadget, basically a wrapper around the Gadget class.
__construct(array $options)
Creates an instance of this 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.
supportsResourceLoader()
static newEmptyGadget( $id)
Get a placeholder object to use if a gadget doesn't exist.
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:1971
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:2780
returning false will NOT prevent logging $e
Definition hooks.txt:2146