r90216 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90215‎ | r90216 | r90217 >
Date:17:14, 16 June 2011
Author:salvatoreingala
Status:deferred
Tags:
Comment:
Code simplification, as per comment in r90127.
Modified paths:
  • /branches/salvatoreingala/Gadgets/Gadgets_body.php (modified) (history)

Diff [purge]

Index: branches/salvatoreingala/Gadgets/Gadgets_body.php
@@ -660,7 +660,7 @@
661661 if ( !count( $pages ) ) {
662662 return null;
663663 }
664 - return new GadgetResourceLoaderModule( $pages, $this->dependencies );
 664+ return new GadgetResourceLoaderModule( $pages, $this->dependencies, $this );
665665 }
666666
667667 /**
@@ -1080,7 +1080,7 @@
10811081 * Class representing a list of resources for one gadget
10821082 */
10831083 class GadgetResourceLoaderModule extends ResourceLoaderWikiModule {
1084 - private $pages, $dependencies;
 1084+ private $pages, $dependencies, $gadget;
10851085
10861086 /**
10871087 * Creates an instance of this class
@@ -1092,9 +1092,10 @@
10931093 * )
10941094 * @param $dependencies Array: Names of resources this module depends on
10951095 */
1096 - public function __construct( $pages, $dependencies ) {
 1096+ public function __construct( $pages, $dependencies, $gadget ) {
10971097 $this->pages = $pages;
10981098 $this->dependencies = $dependencies;
 1099+ $this->gadget = $gadget;
10991100 }
11001101
11011102 /**
@@ -1114,12 +1115,8 @@
11151116 }
11161117
11171118 public function getScript( ResourceLoaderContext $context ) {
1118 - $moduleName = $this->getName();
1119 - $gadgetName = substr( $moduleName, strlen( 'ext.gadget.' ) );
1120 - $gadgets = Gadget::loadList();
1121 - $gadget = $gadgets[$gadgetName];
11221119
1123 - $prefs = $gadget->getPrefs();
 1120+ $prefs = $this->gadget->getPrefs();
11241121
11251122 //Enclose gadget's code in a closure, with "this" bound to the
11261123 //configuration object (or to "window" for non-configurable gadgets)

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90127Replaced static methods to get/set preferences and preference descriptions wi...salvatoreingala18:03, 15 June 2011

Status & tagging log