MinervaNeue/includes/ResourceLoaderLessVarFileModule.php
Timo Tijhof ba0419fcbf Convert custom LESS var from global to local
Avoid the 'ResourceLoaderGetLessVars' hook, which registers a
global LESS variable exposed to all modules (inc. core/extensions).

Instead, use a FileModule subclass to provide the variable only
to the modules that need it.

Using this approach, also has the benefit of being tracked by
the version hasher, so that changes to the configuration actually
result in timely invalidation of module caches.

Bug: T171367
Change-Id: I7c7d13c83004edfc852a9b7dbfc4169617ab9f64
2018-04-02 23:28:58 +00:00

20 lines
466 B
PHP

<?php
namespace MediaWiki\Minerva;
/**
* Subclass with extra LESS variables for Minerva configuration.
*/
class ResourceLoaderLessVarFileModule extends \ResourceLoaderFileModule {
/**
* @param \ResourceLoaderContext $context
* @return array LESS variables
*/
protected function getLessVars( \ResourceLoaderContext $context ) {
return [
'wgMinervaApplyKnownTemplateHacks' =>
$this->getConfig()->get( 'MinervaApplyKnownTemplateHacks' ),
];
}
}