extension.schema.v2: Fix schemas for 'packageFiles'

The PHP code handling 'packageFiles' looks like it only expects
numeric arrays, and not associative arrays. Therefore in JSON the
value for the 'packageFiles' key should be arrays and not objects.
(And a special case of a string, handled the same as single-element
array, is also accepted.)

Individual items in the array can be not only strings, but also
objects, describing data which is pulled from other sources than a
file.

* ResourceLoaderFileModule: Remove unused variable and tweak docs.

Change-Id: I6c3d186de1877f73d4a4e3fec7d6d632a5d5fa83
This commit is contained in:
Bartosz Dziewoński 2019-10-24 17:12:20 +02:00
parent cc2cb95ec6
commit d50c7f5b56
3 changed files with 15 additions and 9 deletions

View file

@ -302,8 +302,11 @@
"description": "Whether to skip CSSJanus LTR-to-RTL flipping for this module. Recommended for styles imported from libraries that already properly handle their RTL styles. Default is false, meaning CSSJanus will be applied on RTL-mode output."
},
"packageFiles": {
"type": ["object", "array"],
"description": "Package files that can be require()d"
"type": ["string", "array"],
"description": "Package files that can be require()d",
"items": {
"type": ["string", "object"]
}
}
}
},

View file

@ -309,8 +309,11 @@
"description": "Whether to skip CSSJanus LTR-to-RTL flipping for this module. Recommended for styles imported from libraries that already properly handle their RTL styles. Default is false, meaning CSSJanus will be applied on RTL-mode output."
},
"packageFiles": {
"type": ["object", "array"],
"description": "Package files that can be require()d"
"type": ["string", "array"],
"description": "Package files that can be require()d",
"items": {
"type": ["string", "object"]
}
}
}
},
@ -455,10 +458,10 @@
}
},
"packageFiles": {
"type": ["array"],
"description": "Scripts to include (array of file paths)",
"type": ["string", "array"],
"description": "Package files that can be require()d",
"items": {
"type": "string"
"type": ["string", "object"]
}
},
"dependencies": {

View file

@ -101,7 +101,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
* @var array List of packaged files to make available through require()
* @par Usage:
* @code
* [ [file-path], [file-path], ... ]
* [ [file-path-or-object], [file-path-or-object], ... ]
* @endcode
*/
protected $packageFiles = null;
@ -1117,7 +1117,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
$expandedFiles = [];
$mainFile = null;
foreach ( $this->packageFiles as $alias => $fileInfo ) {
foreach ( $this->packageFiles as $fileInfo ) {
if ( is_string( $fileInfo ) ) {
$fileInfo = [ 'name' => $fileInfo, 'file' => $fileInfo ];
} elseif ( !isset( $fileInfo['name'] ) ) {