registration: Support ResourceModuleSkinStyles
authorKunal Mehta <legoktm@gmail.com>
Thu, 2 Apr 2015 17:12:52 +0000 (10:12 -0700)
committerKunal Mehta <legoktm@gmail.com>
Tue, 7 Apr 2015 15:43:16 +0000 (08:43 -0700)
Structurally, it's set up exactly the same as ResourceModules, so we can
re-use the same code.

Bug: T91566
Change-Id: I7cd1330edc3e97b4658c81aac67071a90ac61fb6

docs/extension.schema.json
includes/registration/ExtensionProcessor.php
maintenance/convertExtensionToRegistration.php
tests/phpunit/includes/registration/ExtensionProcessorTest.php

index dd35d05..1d891d2 100644 (file)
                                }
                        }
                },
+               "ResourceModuleSkinStyles": {
+                       "type": "object",
+                       "description": "ResourceLoader modules for custom skin styles"
+               },
                "ResourceLoaderSources": {
                        "type": "object",
                        "description": "ResourceLoader sources to register"
index f85b878..4945958 100644 (file)
@@ -193,15 +193,17 @@ class ExtensionProcessor implements Processor {
                        $defaultPaths['localBasePath'] = "$dir/{$defaultPaths['localBasePath']}";
                }
 
-               if ( isset( $info['ResourceModules'] ) ) {
-                       foreach ( $info['ResourceModules'] as $name => $data ) {
-                               if ( isset( $data['localBasePath'] ) ) {
-                                       $data['localBasePath'] = "$dir/{$data['localBasePath']}";
+               foreach ( array( 'ResourceModules', 'ResourceModuleSkinStyles' ) as $setting ) {
+                       if ( isset( $info[$setting] ) ) {
+                               foreach ( $info[$setting] as $name => $data ) {
+                                       if ( isset( $data['localBasePath'] ) ) {
+                                               $data['localBasePath'] = "$dir/{$data['localBasePath']}";
+                                       }
+                                       if ( $defaultPaths ) {
+                                               $data += $defaultPaths;
+                                       }
+                                       $this->globals["wg$setting"][$name] = $data;
                                }
-                               if ( $defaultPaths ) {
-                                       $data += $defaultPaths;
-                               }
-                               $this->globals['wgResourceModules'][$name] = $data;
                        }
                }
        }
index 76bc982..a83529c 100644 (file)
@@ -10,6 +10,7 @@ class ConvertExtensionToRegistration extends Maintenance {
                'AutoloadClasses' => 'removeAbsolutePath',
                'ExtensionCredits' => 'handleCredits',
                'ResourceModules' => 'handleResourceModules',
+               'ResourceModuleSkinStyles' => 'handleResourceModules',
                'Hooks' => 'handleHooks',
                'ExtensionFunctions' => 'handleExtensionFunctions',
        );
index b4c225c..b95316c 100644 (file)
@@ -261,6 +261,57 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
                                        ),
                                ),
                        ),
+                       // ResourceModuleSkinStyles with file module paths
+                       array(
+                               // Input
+                               array(
+                                       'ResourceFileModulePaths' => array(
+                                               'localBasePath' => '',
+                                               'remoteSkinPath' => 'FooBar',
+                                       ),
+                                       'ResourceModuleSkinStyles' => array(
+                                               'foobar' => array(
+                                                       'test.foo' => 'foo.css',
+                                               )
+                                       ),
+                               ),
+                               // Expected
+                               array(
+                                       'wgResourceModuleSkinStyles' => array(
+                                               'foobar' => array(
+                                                       'test.foo' => 'foo.css',
+                                                       'localBasePath' => $dir,
+                                                       'remoteSkinPath' => 'FooBar',
+                                               ),
+                                       ),
+                               ),
+                       ),
+                       // ResourceModuleSkinStyles with file module paths and an override
+                       array(
+                               // Input
+                               array(
+                                       'ResourceFileModulePaths' => array(
+                                               'localBasePath' => '',
+                                               'remoteSkinPath' => 'FooBar',
+                                       ),
+                                       'ResourceModuleSkinStyles' => array(
+                                               'foobar' => array(
+                                                       'test.foo' => 'foo.css',
+                                                       'remoteSkinPath' => 'BarFoo'
+                                               ),
+                                       ),
+                               ),
+                               // Expected
+                               array(
+                                       'wgResourceModuleSkinStyles' => array(
+                                               'foobar' => array(
+                                                       'test.foo' => 'foo.css',
+                                                       'localBasePath' => $dir,
+                                                       'remoteSkinPath' => 'BarFoo',
+                                               ),
+                                       ),
+                               ),
+                       ),
                );
        }