resourceloader: Change 'packageFiles' format to be JSON-compatible
authorRoan Kattouw <roan.kattouw@gmail.com>
Fri, 22 Feb 2019 01:26:23 +0000 (17:26 -0800)
committerKrinkle <krinklemail@gmail.com>
Fri, 22 Feb 2019 19:06:39 +0000 (19:06 +0000)
commit9316f2e3c38cade1213aa9060f5bc26516d8fb77
tree4e7a18964ebdc12894b9220d7169798156d2d48e
parent7f6d2fa085c01ea61bbae97503fb9df97ecbe022
resourceloader: Change 'packageFiles' format to be JSON-compatible

The module definition format for 'packageFiles', as initially designed,
mixes sequential and associative arrays. This works in PHP, but not in
JSON. To make the format JSON compatible, use a 'name' key instead of
using the key in the main array.

Leave backwards compatibility in place so that extensions using the old
format can be migrated. This will be removed in the next commit.

Before:

'packageFiles' => [
'script.js',
'script2.js',
'config.json' => [ 'config' => [ 'Foo', 'Bar' ] ],
'data.json' => [ 'callback' => function () { ... } ],
],

After:

'packageFiles' => [
'script.js',
'script2.js',
[ 'name' => 'config.json', 'config' => [ 'Foo', 'Bar' ] ],
[ 'name' => 'data.json', 'callback' => function () { ... } ],
],

This can then be written in extension.json as:
"packageFiles": [
"script.js",
"script2.js",
[ "name": "config.json", "config": [ "Foo", "Bar" ] ],
[ "name": "data.json", "callback: [ "MyExtHooks", "getData" ] ]
]

Change-Id: Ic566a1cd7efd075c380bc50ba0cc2c329a2041d7
includes/resourceloader/ResourceLoaderFileModule.php
resources/Resources.php
tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php