case 'debugScripts':
case 'styles':
case 'packageFiles':
- $this->{$member} = (array)$option;
+ $this->{$member} = is_array( $option ) ? $option : [ $option ];
break;
case 'templates':
$hasTemplates = true;
- $this->{$member} = (array)$option;
+ $this->{$member} = is_array( $option ) ? $option : [ $option ];
break;
// Collated lists of file paths
case 'languageScripts':
"'$key' given, string expected."
);
}
- $this->{$member}[$key] = (array)$value;
+ $this->{$member}[$key] = is_array( $value ) ? $value : [ $value ];
}
break;
case 'deprecated':
// Ensure relevant template compiler module gets loaded
foreach ( $this->templates as $alias => $templatePath ) {
if ( is_int( $alias ) ) {
- $alias = $templatePath;
+ $alias = $this->getPath( $templatePath );
}
$suffix = explode( '.', $alias );
$suffix = end( $suffix );
return $summary;
}
+ /**
+ * @param string|ResourceLoaderFilePath $path
+ * @return string
+ */
+ protected function getPath( $path ) {
+ if ( $path instanceof ResourceLoaderFilePath ) {
+ return $path->getPath();
+ }
+
+ return $path;
+ }
+
/**
* @param string|ResourceLoaderFilePath $path
* @return string
foreach ( $this->templates as $alias => $templatePath ) {
// Alias is optional
if ( is_int( $alias ) ) {
- $alias = $templatePath;
+ $alias = $this->getPath( $templatePath );
}
$localPath = $this->getLocalPath( $templatePath );
if ( file_exists( $localPath ) ) {
throw new MWException( __METHOD__ . ": invalid versionCallback for file" .
" \"{$fileInfo['name']}\" in module \"{$this->getName()}\"" );
}
- $expanded['definitionSummary'] = ( $fileInfo['versionCallback'] )( $context );
+ $expanded['definitionSummary'] =
+ ( $fileInfo['versionCallback'] )( $context, $this->getConfig() );
// Don't invoke 'callback' here as it may be expensive (T223260).
$expanded['callback'] = $fileInfo['callback'];
} else {
- $expanded['content'] = ( $fileInfo['callback'] )( $context );
+ $expanded['content'] = ( $fileInfo['callback'] )( $context, $this->getConfig() );
}
} elseif ( isset( $fileInfo['config'] ) ) {
if ( $type !== 'data' ) {
$fileInfo['content'] = $content;
unset( $fileInfo['filePath'] );
} elseif ( isset( $fileInfo['callback'] ) ) {
- $fileInfo['content'] = ( $fileInfo['callback'] )( $context );
+ $fileInfo['content'] = ( $fileInfo['callback'] )( $context, $this->getConfig() );
unset( $fileInfo['callback'] );
}