Merge "resourceloader: Remove support for `state(name, state)` signature"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 14 Aug 2018 18:41:06 +0000 (18:41 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 14 Aug 2018 18:41:06 +0000 (18:41 +0000)
1  2 
includes/resourceloader/ResourceLoader.php

@@@ -1095,7 -1095,7 +1095,7 @@@ MESSAGE
                                                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'] ) : '';
        }
  
        /**
-        * Returns a JS call to mw.loader.state, which sets the state of a
-        * module or modules to a given value. Has two calling conventions:
+        * Returns a JS call to mw.loader.state, which sets the state of one
+        * ore more modules to a given value. Has two calling conventions:
         *
         *    - ResourceLoader::makeLoaderStateScript( $name, $state ):
         *         Set the state of a single module called $name to $state
         *    - ResourceLoader::makeLoaderStateScript( [ $name => $state, ... ] ):
         *         Set the state of modules with the given names to the given states
         *
-        * @param string $name
+        * @param array|string $states
         * @param string|null $state
         * @return string JavaScript code
         */
-       public static function makeLoaderStateScript( $name, $state = null ) {
-               if ( is_array( $name ) ) {
-                       return Xml::encodeJsCall(
-                               'mw.loader.state',
-                               [ $name ],
-                               self::inDebugMode()
-                       );
-               } else {
-                       return Xml::encodeJsCall(
-                               'mw.loader.state',
-                               [ $name, $state ],
-                               self::inDebugMode()
-                       );
+       public static function makeLoaderStateScript( $states, $state = null ) {
+               if ( !is_array( $states ) ) {
+                       $states = [ $states => $state ];
                }
+               return Xml::encodeJsCall(
+                       'mw.loader.state',
+                       [ $states ],
+                       self::inDebugMode()
+               );
        }
  
        /**