/** @var bool */
private $mFound = false;
+ /** @var Language */
+ private $contLang;
+
/**#@-*/
/**
* @param string|null $id The internal name of the magic word
* @param string[]|string $syn synonyms for the magic word
* @param bool $cs If magic word is case sensitive
+ * @param Language|null $contLang Content language
*/
- public function __construct( $id = null, $syn = [], $cs = false ) {
+ public function __construct( $id = null, $syn = [], $cs = false, Language $contLang = null ) {
$this->mId = $id;
$this->mSynonyms = (array)$syn;
$this->mCaseSensitive = $cs;
+ $this->contLang = $contLang;
+
+ if ( !$contLang ) {
+ $this->contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ }
}
/**
* @deprecated since 1.32, use MagicWordFactory::get
*/
public static function get( $id ) {
+ wfDeprecated( __METHOD__, '1.32' );
return MediaWikiServices::getInstance()->getMagicWordFactory()->get( $id );
}
* @deprecated since 1.32, use MagicWordFactory::getVariableIDs
*/
public static function getVariableIDs() {
+ wfDeprecated( __METHOD__, '1.32' );
return MediaWikiServices::getInstance()->getMagicWordFactory()->getVariableIDs();
}
* @deprecated since 1.32, use MagicWordFactory::getSubstIDs
*/
public static function getSubstIDs() {
+ wfDeprecated( __METHOD__, '1.32' );
return MediaWikiServices::getInstance()->getMagicWordFactory()->getSubstIDs();
}
* @deprecated since 1.32, use MagicWordFactory::getCacheTTL
*/
public static function getCacheTTL( $id ) {
+ wfDeprecated( __METHOD__, '1.32' );
return MediaWikiServices::getInstance()->getMagicWordFactory()->getCacheTTL( $id );
}
* @deprecated since 1.32, use MagicWordFactory::getDoubleUnderscoreArray
*/
public static function getDoubleUnderscoreArray() {
+ wfDeprecated( __METHOD__, '1.32' );
return MediaWikiServices::getInstance()->getMagicWordFactory()->getDoubleUnderscoreArray();
}
* @throws MWException
*/
public function load( $id ) {
- global $wgContLang;
$this->mId = $id;
- $wgContLang->getMagic( $this );
+ $this->contLang->getMagic( $this );
if ( !$this->mSynonyms ) {
$this->mSynonyms = [ 'brionmademeputthishere' ];
throw new MWException( "Error: invalid magic word '$id'" );
* @param string $value
*/
public function addToArray( &$array, $value ) {
- global $wgContLang;
foreach ( $this->mSynonyms as $syn ) {
- $array[$wgContLang->lc( $syn )] = $value;
+ $array[$this->contLang->lc( $syn )] = $value;
}
}