mediawiki-skins-Vector/includes/ResourceLoader/VectorResourceLoaderUserModule.php
thiemowmde f9d9ddcbec Make use of named MainConfigNames::… constants
And while we are here:
* Split long lines.
* Use isRegistered from the more narrow UserIdentity interface.
* Sort conditions from (probably) least to most expensive.

Change-Id: Ia6e4018a22cfc2fb450bb53f6d63a4a106394b87
2023-03-03 10:45:53 +01:00

26 lines
651 B
PHP

<?php
namespace MediaWiki\Skins\Vector\ResourceLoader;
use MediaWiki\MainConfigNames;
use MediaWiki\ResourceLoader as RL;
use MediaWiki\Skins\Vector\Constants;
class VectorResourceLoaderUserModule extends RL\UserModule {
/**
* @inheritDoc
*/
protected function getPages( RL\Context $context ) {
$user = $context->getUserObj();
$pages = [];
if ( $context->getSkin() === Constants::SKIN_NAME_MODERN &&
$this->getConfig()->get( MainConfigNames::AllowUserCss ) &&
$user->isRegistered()
) {
$userPage = $user->getUserPage()->getPrefixedDBkey();
$pages["$userPage/vector.js"] = [ 'type' => 'script' ];
}
return $pages;
}
}