From 627e2c9b16f2d424c26ddc8e4038172f4c4dc8e3 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Tue, 23 Oct 2018 17:48:31 +0200 Subject: [PATCH] WebInstallerOutput: Add getLanguage() Combine the functions getLanguageCode() and getDir() to the single function getLanguage(). Also mark the class WebInstallerOutput as @private. Change-Id: Ic7deea5f3040fe8f1211b96622bdae222ca9e072 --- RELEASE-NOTES-1.33 | 1 + includes/installer/WebInstallerOutput.php | 25 ++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/RELEASE-NOTES-1.33 b/RELEASE-NOTES-1.33 index 80e3bbd92e..fa9d47a8eb 100644 --- a/RELEASE-NOTES-1.33 +++ b/RELEASE-NOTES-1.33 @@ -212,6 +212,7 @@ because of Phabricator reports. Wikimedia\Services. The old name is still supported, but deprecated. * (T155582) Content::getNativeData has been deprecated. Please use model- specific getters, such as TextContent::getText(). +* The class WebInstallerOutput is now marked as @private. * … === Other changes in 1.33 === diff --git a/includes/installer/WebInstallerOutput.php b/includes/installer/WebInstallerOutput.php index 950aaf7827..ae07d0cbda 100644 --- a/includes/installer/WebInstallerOutput.php +++ b/includes/installer/WebInstallerOutput.php @@ -31,6 +31,7 @@ * * @ingroup Deployment * @since 1.17 + * @private */ class WebInstallerOutput { @@ -166,7 +167,7 @@ class WebInstallerOutput { $rlContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( [ 'debug' => 'true', - 'lang' => $this->getLanguageCode(), + 'lang' => $this->getLanguage()->getCode(), 'only' => 'styles', ] ) ); @@ -220,21 +221,13 @@ class WebInstallerOutput { } /** - * @return string - */ - public function getDir() { - global $wgLang; - - return is_object( $wgLang ) ? $wgLang->getDir() : 'ltr'; - } - - /** - * @return string + * @since 1.33 + * @return Language */ - public function getLanguageCode() { + private function getLanguage() { global $wgLang; - return is_object( $wgLang ) ? $wgLang->getCode() : 'en'; + return is_object( $wgLang ) ? $wgLang : Language::factory( 'en' ); } /** @@ -242,8 +235,8 @@ class WebInstallerOutput { */ public function getHeadAttribs() { return [ - 'dir' => $this->getDir(), - 'lang' => LanguageCode::bcp47( $this->getLanguageCode() ), + 'dir' => $this->getLanguage()->getDir(), + 'lang' => $this->getLanguage()->getHtmlCode(), ]; } @@ -287,7 +280,7 @@ class WebInstallerOutput { - $this->getDir() ] ) . "\n"; ?> + $this->getLanguage()->getDir() ] ) . "\n"; ?>
-- 2.20.1