Merge "Set consistent min value options for RC and Watchlist filters"
[lhc/web/wiklou.git] / includes / MagicWordFactory.php
index 11ed0a7..e62716d 100644 (file)
@@ -192,8 +192,22 @@ class MagicWordFactory {
        /** @var MagicWordArray */
        private $mDoubleUnderscoreArray = null;
 
+       /** @var Language */
+       private $contLang;
+
        /**#@-*/
 
+       /**
+        * @param Language $contLang Content language
+        */
+       public function __construct( Language $contLang ) {
+               $this->contLang = $contLang;
+       }
+
+       public function getContentLanguage() {
+               return $this->contLang;
+       }
+
        /**
         * Factory: creates an object representing an ID
         *
@@ -203,7 +217,7 @@ class MagicWordFactory {
         */
        public function get( $id ) {
                if ( !isset( $this->mObjects[$id] ) ) {
-                       $mw = new MagicWord();
+                       $mw = new MagicWord( null, [], false, $this->contLang );
                        $mw->load( $id );
                        $this->mObjects[$id] = $mw;
                }
@@ -254,8 +268,18 @@ class MagicWordFactory {
        public function getDoubleUnderscoreArray() {
                if ( is_null( $this->mDoubleUnderscoreArray ) ) {
                        Hooks::run( 'GetDoubleUnderscoreIDs', [ &$this->mDoubleUnderscoreIDs ] );
-                       $this->mDoubleUnderscoreArray = new MagicWordArray( $this->mDoubleUnderscoreIDs );
+                       $this->mDoubleUnderscoreArray = $this->newArray( $this->mDoubleUnderscoreIDs );
                }
                return $this->mDoubleUnderscoreArray;
        }
+
+       /**
+        * Get a new MagicWordArray with provided $names
+        *
+        * @param array $names
+        * @return MagicWordArray
+        */
+       public function newArray( array $names = [] ) : MagicWordArray {
+               return new MagicWordArray( $names, $this );
+       }
 }