Avoid wfMessage in special page

Use self::msg instead to avoid global state

Change-Id: I78f914facee4174e76bbc77716b99d4aebd26c67
This commit is contained in:
Umherirrender 2020-12-19 12:16:51 +01:00
parent 60714e7a81
commit 69ef3c1bcb
2 changed files with 13 additions and 14 deletions

View file

@ -3,7 +3,6 @@
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage" />
</rule>
<file>.</file>
<arg name="encoding" value="UTF-8" />

View file

@ -153,17 +153,17 @@ class OATHManage extends SpecialPage {
}
private function addEnabledHTML() {
$this->addHeading( wfMessage( 'oathauth-ui-enabled-module' ) );
$this->addHeading( $this->msg( 'oathauth-ui-enabled-module' ) );
$this->addModuleHTML( $this->getEnabled() );
}
private function addAlternativesHTML() {
$this->addHeading( wfMessage( 'oathauth-ui-not-enabled-modules' ) );
$this->addHeading( $this->msg( 'oathauth-ui-not-enabled-modules' ) );
$this->addInactiveHTML();
}
private function nothingEnabled() {
$this->addHeading( wfMessage( 'oathauth-ui-available-modules' ) );
$this->addHeading( $this->msg( 'oathauth-ui-available-modules' ) );
$this->addInactiveHTML();
}
@ -177,7 +177,7 @@ class OATHManage extends SpecialPage {
}
private function addGeneralHelp() {
$this->getOutput()->addHTML( wfMessage(
$this->getOutput()->addHTML( $this->msg(
'oathauth-ui-general-help'
)->parseAsBlock() );
}
@ -215,8 +215,8 @@ class OATHManage extends SpecialPage {
if ( $this->shouldShowGenericButtons() ) {
$button = new ButtonWidget( [
'label' => $this->isModuleEnabled( $module ) ?
wfMessage( 'oathauth-disable-generic' )->text() :
wfMessage( 'oathauth-enable-generic' )->text(),
$this->msg( 'oathauth-disable-generic' )->text() :
$this->msg( 'oathauth-enable-generic' )->text(),
'href' => $this->getOutput()->getTitle()->getLocalURL( [
'action' => $this->isModuleEnabled( $module ) ?
static::ACTION_DISABLE : static::ACTION_ENABLE,
@ -321,8 +321,8 @@ class OATHManage extends SpecialPage {
if ( $this->isGenericAction() ) {
$displayName = $this->requestedModule->getDisplayName();
$pageTitle = $this->isModuleEnabled( $this->requestedModule ) ?
wfMessage( 'oathauth-disable-page-title', $displayName )->text() :
wfMessage( 'oathauth-enable-page-title', $displayName )->text();
$this->msg( 'oathauth-disable-page-title', $displayName )->text() :
$this->msg( 'oathauth-enable-page-title', $displayName )->text();
$this->getOutput()->setPageTitle( $pageTitle );
}
@ -361,15 +361,15 @@ class OATHManage extends SpecialPage {
'expanded' => false
] );
$headerMessage = $this->isSwitch() ?
wfMessage( 'oathauth-switch-method-warning-header' ) :
wfMessage( 'oathauth-disable-method-warning-header' );
$this->msg( 'oathauth-switch-method-warning-header' ) :
$this->msg( 'oathauth-disable-method-warning-header' );
$genericMessage = $this->isSwitch() ?
wfMessage(
$this->msg(
'oathauth-switch-method-warning',
$this->getEnabled()->getDisplayName(),
$this->requestedModule->getDisplayName()
) :
wfMessage( 'oathauth-disable-method-warning', $this->getEnabled()->getDisplayName() );
$this->msg( 'oathauth-disable-method-warning', $this->getEnabled()->getDisplayName() );
$panel->appendContent( new HtmlSnippet(
$genericMessage->parseAsBlock()
@ -383,7 +383,7 @@ class OATHManage extends SpecialPage {
}
$button = new ButtonWidget( [
'label' => wfMessage( 'oathauth-disable-method-warning-button-label' )->plain(),
'label' => $this->msg( 'oathauth-disable-method-warning-button-label' )->plain(),
'href' => $this->getOutput()->getTitle()->getLocalURL( [
'action' => $this->action,
'module' => $this->requestedModule->getName()