Merge "Make use of named MainConfigNames::… constants"

This commit is contained in:
jenkins-bot 2023-03-06 22:57:10 +00:00 committed by Gerrit Code Review
commit 6a52ec3b58
2 changed files with 10 additions and 6 deletions

View file

@ -2,6 +2,7 @@
namespace MediaWiki\Skins\Vector\ResourceLoader;
use MediaWiki\MainConfigNames;
use MediaWiki\ResourceLoader as RL;
use MediaWiki\Skins\Vector\Constants;
@ -10,11 +11,12 @@ class VectorResourceLoaderUserModule extends RL\UserModule {
* @inheritDoc
*/
protected function getPages( RL\Context $context ) {
$skin = $context->getSkin();
$config = $this->getConfig();
$user = $context->getUserObj();
$pages = [];
if ( $config->get( 'AllowUserCss' ) && !$user->isAnon() && ( $skin === Constants::SKIN_NAME_MODERN ) ) {
if ( $context->getSkin() === Constants::SKIN_NAME_MODERN &&
$this->getConfig()->get( MainConfigNames::AllowUserCss ) &&
$user->isRegistered()
) {
$userPage = $user->getUserPage()->getPrefixedDBkey();
$pages["$userPage/vector.js"] = [ 'type' => 'script' ];
}

View file

@ -2,6 +2,7 @@
namespace MediaWiki\Skins\Vector\ResourceLoader;
use MediaWiki\MainConfigNames;
use MediaWiki\ResourceLoader as RL;
use MediaWiki\Skins\Vector\Constants;
@ -10,11 +11,12 @@ class VectorResourceLoaderUserStylesModule extends RL\UserStylesModule {
* @inheritDoc
*/
protected function getPages( RL\Context $context ) {
$skin = $context->getSkin();
$config = $this->getConfig();
$user = $context->getUserObj();
$pages = [];
if ( $config->get( 'AllowUserCss' ) && !$user->isAnon() && ( $skin === Constants::SKIN_NAME_MODERN ) ) {
if ( $context->getSkin() === Constants::SKIN_NAME_MODERN &&
$this->getConfig()->get( MainConfigNames::AllowUserCss ) &&
$user->isRegistered()
) {
$userPage = $user->getUserPage()->getPrefixedDBkey();
$pages["$userPage/vector.css"] = [ 'type' => 'style' ];
}