From: jenkins-bot Date: Thu, 1 May 2014 06:21:27 +0000 (+0000) Subject: Merge "ResourceLoaderLanguageDataModule: Clean up useless methods and fragile state" X-Git-Tag: 1.31.0-rc.0~15937 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=fb00a295a1d28e07fa5ade8ca07a0713e343406c;hp=63dbc0aba243c7dcaa820220c2cb1aa2cc91eca1;p=lhc%2Fweb%2Fwiklou.git Merge "ResourceLoaderLanguageDataModule: Clean up useless methods and fragile state" --- diff --git a/includes/resourceloader/ResourceLoaderLanguageDataModule.php b/includes/resourceloader/ResourceLoaderLanguageDataModule.php index 77dcdf9e03..a1c8ac9dd5 100644 --- a/includes/resourceloader/ResourceLoaderLanguageDataModule.php +++ b/includes/resourceloader/ResourceLoaderLanguageDataModule.php @@ -27,68 +27,22 @@ */ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule { - protected $language; protected $targets = array( 'desktop', 'mobile' ); - /** - * Get the grammar forms for the site content language. - * - * @return array - */ - protected function getSiteLangGrammarForms() { - return $this->language->getGrammarForms(); - } - - /** - * Get the plural forms for the site content language. - * - * @return array - */ - protected function getPluralRules() { - return $this->language->getPluralRules(); - } - - /** - * Get the digit groupin Pattern for the site content language. - * - * @return array - */ - protected function getDigitGroupingPattern() { - return $this->language->digitGroupingPattern(); - } - - /** - * Get the digit transform table for the content language - * - * @return array - */ - protected function getDigitTransformTable() { - return $this->language->digitTransformTable(); - } - - /** - * Get seperator transform table required for converting - * the . and , sign to appropriate forms in site content language. - * - * @return array - */ - protected function getSeparatorTransformTable() { - return $this->language->separatorTransformTable(); - } /** * Get all the dynamic data for the content language to an array. * - * NOTE: Before calling this you HAVE to make sure $this->language is set. - * + * @param ResourceLoaderContext $context * @return array */ - protected function getData() { + protected function getData( ResourceLoaderContext $context ) { + $language = Language::factory( $context->getLanguage() ); return array( - 'digitTransformTable' => $this->getDigitTransformTable(), - 'separatorTransformTable' => $this->getSeparatorTransformTable(), - 'grammarForms' => $this->getSiteLangGrammarForms(), - 'pluralRules' => $this->getPluralRules(), - 'digitGroupingPattern' => $this->getDigitGroupingPattern(), + 'digitTransformTable' => $language->digitTransformTable(), + 'separatorTransformTable' => $language->separatorTransformTable(), + 'grammarForms' => $language->getGrammarForms(), + 'pluralRules' => $language->getPluralRules(), + 'digitGroupingPattern' => $language->digitGroupingPattern(), ); } @@ -97,10 +51,9 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule { * @return string JavaScript code */ public function getScript( ResourceLoaderContext $context ) { - $this->language = Language::factory( $context->getLanguage() ); return Xml::encodeJsCall( 'mw.language.setData', array( - $this->language->getCode(), - $this->getData() + $context->getLanguage(), + $this->getData( $context ) ) ); } @@ -117,9 +70,7 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule { * @return string Hash */ public function getModifiedHash( ResourceLoaderContext $context ) { - $this->language = Language::factory( $context->getLanguage() ); - - return md5( serialize( $this->getData() ) ); + return md5( serialize( $this->getData( $context ) ) ); } /**