// Group of module
protected $group;
- // Whether to enable variable expansion (e.g. "{skin}")
- protected $allowVariables = false;
-
/**
* @param array $options For back-compat, this can be omitted in favour of overwriting getPages.
*/
case 'scripts':
case 'group':
case 'targets':
- case 'allowVariables':
$this->{$member} = $option;
break;
}
// Filter out pages from origins not allowed by the current wiki configuration.
if ( $config->get( 'UseSiteJs' ) ) {
foreach ( $this->scripts as $script ) {
- $page = $this->expandVariables( $context, $script );
- $pages[$page] = [ 'type' => 'script' ];
+ $pages[$script] = [ 'type' => 'script' ];
}
}
if ( $config->get( 'UseSiteCss' ) ) {
foreach ( $this->styles as $style ) {
- $page = $this->expandVariables( $context, $style );
- $pages[$page] = [ 'type' => 'style' ];
+ $pages[$style] = [ 'type' => 'style' ];
}
}
return $pages;
}
- private function expandVariables( ResourceLoaderContext $context, $pageName ) {
- if ( !$this->allowVariables ) {
- return $pageName;
- }
- return strtr( $pageName, [
- '{skin}' => $context->getSkin()
- ] );
- }
-
/**
* Get group name
*
return $this->titleInfo[$key];
}
+ /**
+ * @return string
+ */
public function getPosition() {
return $this->position;
}
+
+ /**
+ * @since 1.28
+ * @return string
+ */
+ public function getType() {
+ // Check both because subclasses don't always pass pages via the constructor,
+ // they may also override getPages() instead, in which case we should keep
+ // defaulting to LOAD_GENERAL and allow them to override getType() separately.
+ return ( $this->styles && !$this->scripts ) ? self::LOAD_STYLES : self::LOAD_GENERAL;
+ }
}