/**
* Register core modules and runs registration hooks.
- * @param Config $config [optional]
- * @param LoggerInterface $logger [optional]
+ * @param Config|null $config [optional]
+ * @param LoggerInterface|null $logger [optional]
*/
public function __construct( Config $config = null, LoggerInterface $logger = null ) {
global $IP;
* Register a module with the ResourceLoader system.
*
* @param mixed $name Name of module as a string or List of name/object pairs as an array
- * @param array $info Module info array. For backwards compatibility with 1.17alpha,
+ * @param array|null $info Module info array. For backwards compatibility with 1.17alpha,
* this may also be a ResourceLoaderModule object. Optional when using
* multiple-registration calling style.
* @throws MWException If a duplicate module registration is attempted
* Source IDs are typically the same as the Wiki ID or database name (e.g. lowercase a-z).
*
* @param array|string $id Source ID (string), or [ id1 => loadUrl, id2 => loadUrl, ... ]
- * @param string|array $loadUrl load.php url (string), or array with loadUrl key for
+ * @param string|array|null $loadUrl load.php url (string), or array with loadUrl key for
* backwards-compatibility.
* @throws MWException
*/
break;
case 'styles':
$styles = $content['styles'];
- // We no longer seperate into media, they are all combined now with
+ // We no longer separate into media, they are all combined now with
// custom media type groups into @media .. {} sections as part of the css string.
// Module returns either an empty array or a numerical array with css strings.
$strContent = isset( $styles['css'] ) ? implode( '', $styles['css'] ) : '';
* Set the state of modules with the given names to the given states
*
* @param string $name
- * @param string $state
+ * @param string|null $state
* @return string JavaScript code
*/
public static function makeLoaderStateScript( $name, $state = null ) {
* Registers modules with the given names and parameters.
*
* @param string $name Module name
- * @param string $version Module version hash
- * @param array $dependencies List of module names on which this module depends
- * @param string $group Group which the module is in
- * @param string $source Source of the module, or 'local' if not foreign
- * @param string $skip Script body of the skip function
+ * @param string|null $version Module version hash
+ * @param array|null $dependencies List of module names on which this module depends
+ * @param string|null $group Group which the module is in
+ * @param string|null $source Source of the module, or 'local' if not foreign
+ * @param string|null $skip Script body of the skip function
* @return string JavaScript code
*/
public static function makeLoaderRegisterScript( $name, $version = null,
* Register sources with the given IDs and properties.
*
* @param string $id Source ID
- * @param string $loadUrl load.php url
+ * @param string|null $loadUrl load.php url
* @return string JavaScript code
*/
public static function makeLoaderSourcesScript( $id, $loadUrl = null ) {
}
/**
- * Wraps JavaScript code to run after startup and base modules.
+ * Wraps JavaScript code to run after the startup module.
*
* @param string $script JavaScript code
* @return string JavaScript code
*/
public static function makeLoaderConditionalScript( $script ) {
+ // Adds a function to lazy-created RLQ
return '(window.RLQ=window.RLQ||[]).push(function(){' .
trim( $script ) . '});';
}
+ /**
+ * Wraps JavaScript code to run after a required module.
+ *
+ * @since 1.32
+ * @param string|string[] $modules Module name(s)
+ * @param string $script JavaScript code
+ * @return string JavaScript code
+ */
+ public static function makeInlineCodeWithModule( $modules, $script ) {
+ // Adds an array to lazy-created RLQ
+ return '(window.RLQ=window.RLQ||[]).push(['
+ . json_encode( $modules ) . ','
+ . 'function(){' . trim( $script ) . '}'
+ . ']);';
+ }
+
/**
* Returns an HTML script tag that runs given JS code after startup and base modules.
*
* startup module if the client has adequate support for MediaWiki JavaScript code.
*
* @param string $script JavaScript code
- * @param string $nonce [optional] Content-Security-Policy nonce (from OutputPage::getCSPNonce)
+ * @param string|null $nonce [optional] Content-Security-Policy nonce
+ * (from OutputPage::getCSPNonce)
* @return string|WrappedString HTML
*/
public static function makeInlineScript( $script, $nonce = null ) {
* @param array $modules
* @param string $lang
* @param string $skin
- * @param string $user
- * @param string $version
+ * @param string|null $user
+ * @param string|null $version
* @param bool $debug
- * @param string $only
+ * @param string|null $only
* @param bool $printable
* @param bool $handheld
* @param array $extraQuery