Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/88064


Change subject: Get rid of some misplaced dependency management behaviour
......................................................................

Get rid of some misplaced dependency management behaviour

Change-Id: Ia5f7c47f80330542f0b48935796f722d5f2bcccb
---
M repo/includes/WikibaseRepo.php
M repo/tests/phpunit/includes/store/sql/EntityPerPageBuilderTest.php
2 files changed, 35 insertions(+), 83 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/64/88064/1

diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php
index 2db3712..01a89d6 100644
--- a/repo/includes/WikibaseRepo.php
+++ b/repo/includes/WikibaseRepo.php
@@ -34,24 +34,6 @@
 /**
  * Top level factory for the WikibaseRepo extension.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @since 0.4
- * @ingroup WikibaseRepo
- *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  * @author Daniel Kinzler
@@ -73,11 +55,6 @@
         * @var EntityIdFormatter|null
         */
        private $idFormatter = null;
-
-       /**
-        * @var Store
-        */
-       private $store;
 
        /**
         * @var SnakConstructionService|null
@@ -105,26 +82,40 @@
        private $stringNormalizer;
 
        /**
-        * @var Language
-        */
-       private $contentLanguage;
-
-       /**
         * @var OutputFormatSnakFormatterFactory
         */
        private $snakFormatterFactory;
 
        /**
+        * @var EntityLookup
+        */
+       private $entityLookup;
+
+       /**
+        * Returns the default instance constructed using newInstance().
+        * IMPORTANT: Use only when it is not feasible to inject an instance 
properly.
+        *
+        * @since 0.4
+        *
+        * @return WikibaseRepo
+        */
+       public static function getDefaultInstance() {
+               static $instance = null;
+
+               if ( $instance === null ) {
+                       $instance = new self( Settings::singleton() );
+               }
+
+               return $instance;
+       }
+
+       /**
         * @since 0.4
         *
         * @param SettingsArray $settings
-        * @param Store         $store
-        * @param Language      $contentLanguage
         */
-       public function __construct( SettingsArray $settings, Store $store, 
Language $contentLanguage ) {
+       public function __construct( SettingsArray $settings ) {
                $this->settings = $settings;
-               $this->store = $store;
-               $this->contentLanguage = $contentLanguage;
        }
 
        /**
@@ -225,7 +216,11 @@
         * @return EntityLookup
         */
        public function getEntityLookup() {
-               return $this->store->getEntityLookup();
+               if ( $this->entityLookup === null ) {
+                       $this->entityLookup = 
StoreFactory::getStore()->getEntityLookup();
+               }
+
+               return $this->entityLookup;
        }
 
        /**
@@ -339,41 +334,6 @@
        }
 
        /**
-        * Returns a new instance constructed from global settings.
-        * IMPORTANT: Use only when it is not feasible to inject an instance 
properly.
-        *
-        * @since 0.4
-        *
-        * @return WikibaseRepo
-        */
-       protected static function newInstance() {
-               global $wgContLang;
-               return new self(
-                       Settings::singleton(),
-                       StoreFactory::getStore(),
-                       $wgContLang
-               );
-       }
-
-       /**
-        * Returns the default instance constructed using newInstance().
-        * IMPORTANT: Use only when it is not feasible to inject an instance 
properly.
-        *
-        * @since 0.4
-        *
-        * @return WikibaseRepo
-        */
-       public static function getDefaultInstance() {
-               static $instance = null;
-
-               if ( $instance === null ) {
-                       $instance = self::newInstance();
-               }
-
-               return $instance;
-       }
-
-       /**
         * @since 0.4
         *
         * @return Store
@@ -402,13 +362,16 @@
         * @return OutputFormatSnakFormatterFactory
         */
        protected function newSnakFormatterFactory() {
+               global $wgContLang;
+
                $builders = new WikibaseSnakFormatterBuilders(
                        $this->getEntityLookup(),
                        $this->getPropertyDataTypeLookup(),
-                       $this->contentLanguage
+                       $wgContLang
                );
 
                $factory = new OutputFormatSnakFormatterFactory( 
$builders->getSnakFormatterBuildersForFormats() );
                return $factory;
        }
+
 }
diff --git a/repo/tests/phpunit/includes/store/sql/EntityPerPageBuilderTest.php 
b/repo/tests/phpunit/includes/store/sql/EntityPerPageBuilderTest.php
index ca73640..b096bce 100644
--- a/repo/tests/phpunit/includes/store/sql/EntityPerPageBuilderTest.php
+++ b/repo/tests/phpunit/includes/store/sql/EntityPerPageBuilderTest.php
@@ -11,9 +11,6 @@
 /**
  * @covers Wikibase\EntityPerPageBuilder
  *
- * @file
- * @since 0.4
- *
  * @ingroup WikibaseRepoTest
  * @ingroup Test
  *
@@ -41,17 +38,9 @@
        public function setUp() {
                parent::setUp();
 
-               $settings = $this->getTestSettings();
-               $store = StoreFactory::getStore( 'sqlstore' );
-               $lang = Language::factory( 'en' );
+               $this->wikibaseRepo = new WikibaseRepo( 
$this->getTestSettings() );
 
-               $this->wikibaseRepo = new WikibaseRepo(
-                       $settings,
-                       $store,
-                       $lang
-               );
-
-               $this->entityPerPageTable = $store->newEntityPerPage();
+               $this->entityPerPageTable = 
$this->wikibaseRepo->getStore()->newEntityPerPage();
 
                $this->clearTables();
                $this->addItems();

-- 
To view, visit https://gerrit.wikimedia.org/r/88064
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia5f7c47f80330542f0b48935796f722d5f2bcccb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to