Get parameters from config instead of global variable in getDataForJs()

Change-Id: Ie01fa1181f6c0878686f056e0a70f89766c090e6
This commit is contained in:
Fomafix 2023-10-05 09:51:58 +00:00
parent 75c2c5580a
commit 292f21fc38

View file

@ -36,6 +36,7 @@ use MediaWiki\Html\Html;
use MediaWiki\Linker\LinkTarget; use MediaWiki\Linker\LinkTarget;
use MediaWiki\Output\OutputPage; use MediaWiki\Output\OutputPage;
use MediaWiki\Parser\Sanitizer; use MediaWiki\Parser\Sanitizer;
use MediaWiki\ResourceLoader as RL;
use MediaWiki\SpecialPage\SpecialPage; use MediaWiki\SpecialPage\SpecialPage;
use MediaWiki\Title\Title; use MediaWiki\Title\Title;
use Parser; use Parser;
@ -236,13 +237,13 @@ class Hooks implements
* Get exported data for the "ext.categoryTree" ResourceLoader module. * Get exported data for the "ext.categoryTree" ResourceLoader module.
* *
* @internal For use in extension.json only. * @internal For use in extension.json only.
* @param RL\Context $context
* @param Config $config
* @return array Data to be serialised as data.json * @return array Data to be serialised as data.json
*/ */
public static function getDataForJs() { public static function getDataForJs( RL\Context $context, Config $config ) {
global $wgCategoryTreeCategoryPageOptions;
// Look, this is pretty bad but CategoryTree is just whacky, it needs to be rewritten // Look, this is pretty bad but CategoryTree is just whacky, it needs to be rewritten
$ct = new CategoryTree( $wgCategoryTreeCategoryPageOptions ); $ct = new CategoryTree( $config->get( 'CategoryTreeCategoryPageOptions' ) );
return [ return [
'defaultCtOptions' => $ct->getOptionsAsJsStructure(), 'defaultCtOptions' => $ct->getOptionsAsJsStructure(),