jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/331935 )

Change subject: Inject SpecialSetSiteLink dependencies
......................................................................


Inject SpecialSetSiteLink dependencies

Bug: T155205
Change-Id: I6eef4a15872606dd9d7ef4cec50bb04501669cbd
---
M repo/Wikibase.php
M repo/includes/Specials/SpecialSetSiteLink.php
M repo/tests/phpunit/includes/Specials/SpecialSetSiteLinkTest.php
3 files changed, 91 insertions(+), 50 deletions(-)

Approvals:
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, approved



diff --git a/repo/Wikibase.php b/repo/Wikibase.php
index 47039a3..a056e5d 100644
--- a/repo/Wikibase.php
+++ b/repo/Wikibase.php
@@ -274,7 +274,27 @@
        $wgSpecialPages['SetAliases'] = 
Wikibase\Repo\Specials\SpecialSetAliases::class;
        $wgSpecialPages['SetLabelDescriptionAliases']
                = 
Wikibase\Repo\Specials\SpecialSetLabelDescriptionAliases::class;
-       $wgSpecialPages['SetSiteLink'] = 
Wikibase\Repo\Specials\SpecialSetSiteLink::class;
+       $wgSpecialPages['SetSiteLink'] = function() {
+               $wikibaseRepo = 
\Wikibase\Repo\WikibaseRepo::getDefaultInstance();
+               $siteLookup = $wikibaseRepo->getSiteLookup();
+               $settings = $wikibaseRepo->getSettings();
+
+               $siteLinkChangeOpFactory = 
$wikibaseRepo->getChangeOpFactoryProvider()->getSiteLinkChangeOpFactory();
+               $siteLinkTargetProvider = new 
\Wikibase\Repo\SiteLinkTargetProvider(
+                       $siteLookup,
+                       $settings->getSetting( 'specialSiteLinkGroups' )
+               );
+
+               $labelDescriptionLookupFactory = 
$wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory();
+               return new Wikibase\Repo\Specials\SpecialSetSiteLink(
+                       $siteLookup,
+                       $siteLinkTargetProvider,
+                       $settings->getSetting( 'siteLinkGroups' ),
+                       $settings->getSetting( 'badgeItems' ),
+                       $labelDescriptionLookupFactory,
+                       $siteLinkChangeOpFactory
+               );
+       };
        $wgSpecialPages['EntitiesWithoutLabel'] = array(
                Wikibase\Repo\Specials\SpecialEntitiesWithoutPageFactory::class,
                'newSpecialEntitiesWithoutLabel'
diff --git a/repo/includes/Specials/SpecialSetSiteLink.php 
b/repo/includes/Specials/SpecialSetSiteLink.php
index 4c6d853..7b5dc32 100644
--- a/repo/includes/Specials/SpecialSetSiteLink.php
+++ b/repo/includes/Specials/SpecialSetSiteLink.php
@@ -14,7 +14,6 @@
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\Lib\Store\LanguageFallbackLabelDescriptionLookupFactory;
 use Wikibase\Repo\SiteLinkTargetProvider;
-use Wikibase\Repo\WikibaseRepo;
 use Wikibase\Summary;
 
 /**
@@ -26,6 +25,36 @@
  * @author Bene* < benestar.wikime...@googlemail.com >
  */
 class SpecialSetSiteLink extends SpecialModifyEntity {
+
+       /**
+        * @var SiteLookup
+        */
+       private $siteLookup;
+
+       /**
+        * @var SiteLinkTargetProvider
+        */
+       private $siteLinkTargetProvider;
+
+       /**
+        * @var string[]
+        */
+       private $siteLinkGroups;
+
+       /**
+        * @var string[]
+        */
+       private $badgeItems;
+
+       /**
+        * @var LanguageFallbackLabelDescriptionLookupFactory
+        */
+       private $labelDescriptionLookupFactory;
+
+       /**
+        * @var SiteLinkChangeOpFactory
+        */
+       private $siteLinkChangeOpFactory;
 
        /**
         * The site of the site link.
@@ -49,56 +78,29 @@
        private $badges;
 
        /**
-        * @var string[]
+        * @param SiteLookup $siteLookup
+        * @param SiteLinkTargetProvider $siteLinkTargetProvider
+        * @param string[] $siteLinkGroups
+        * @param string[] $badgeItems
+        * @param LanguageFallbackLabelDescriptionLookupFactory 
$labelDescriptionLookupFactory
+        * @param SiteLinkChangeOpFactory $siteLinkChangeOpFactory
         */
-       private $badgeItems;
-
-       /**
-        * @var string[]
-        */
-       private $siteLinkGroups;
-
-       /**
-        * @var SiteLinkChangeOpFactory
-        */
-       private $siteLinkChangeOpFactory;
-
-       /**
-        * @var SiteLinkTargetProvider
-        */
-       private $siteLinkTargetProvider;
-
-       /**
-        * @var LanguageFallbackLabelDescriptionLookupFactory
-        */
-       private $labelDescriptionLookupFactory;
-
-       /**
-        * @var SiteLookup
-        */
-       private $siteLookup;
-
-       /**
-        * @since 0.4
-        */
-       public function __construct() {
+       public function __construct(
+               SiteLookup $siteLookup,
+               SiteLinkTargetProvider $siteLinkTargetProvider,
+               array $siteLinkGroups,
+               array $badgeItems,
+               LanguageFallbackLabelDescriptionLookupFactory 
$labelDescriptionLookupFactory,
+               SiteLinkChangeOpFactory $siteLinkChangeOpFactory
+       ) {
                parent::__construct( 'SetSiteLink' );
 
-               $wikibaseRepo = WikibaseRepo::getDefaultInstance();
-               $settings = $wikibaseRepo->getSettings();
-
-               $this->siteLookup = $wikibaseRepo->getSiteLookup();
-
-               $this->badgeItems = $settings->getSetting( 'badgeItems' );
-               $this->siteLinkGroups = $settings->getSetting( 'siteLinkGroups' 
);
-
-               $this->siteLinkChangeOpFactory = 
$wikibaseRepo->getChangeOpFactoryProvider()->getSiteLinkChangeOpFactory();
-               $this->siteLinkTargetProvider = new SiteLinkTargetProvider(
-                       $this->siteLookup,
-                       $settings->getSetting( 'specialSiteLinkGroups' )
-               );
-
-               $this->labelDescriptionLookupFactory = 
$wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory();
+               $this->siteLookup = $siteLookup;
+               $this->siteLinkTargetProvider = $siteLinkTargetProvider;
+               $this->siteLinkGroups = $siteLinkGroups;
+               $this->badgeItems = $badgeItems;
+               $this->labelDescriptionLookupFactory = 
$labelDescriptionLookupFactory;
+               $this->siteLinkChangeOpFactory = $siteLinkChangeOpFactory;
        }
 
        public function doesWrites() {
diff --git a/repo/tests/phpunit/includes/Specials/SpecialSetSiteLinkTest.php 
b/repo/tests/phpunit/includes/Specials/SpecialSetSiteLinkTest.php
index 7538e6d..ce938d9 100644
--- a/repo/tests/phpunit/includes/Specials/SpecialSetSiteLinkTest.php
+++ b/repo/tests/phpunit/includes/Specials/SpecialSetSiteLinkTest.php
@@ -10,6 +10,7 @@
 use Wikibase\DataModel\Entity\EntityRedirect;
 use Wikibase\DataModel\Entity\Item;
 use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\Repo\SiteLinkTargetProvider;
 use Wikibase\Repo\Specials\SpecialSetSiteLink;
 use Wikibase\Repo\WikibaseRepo;
 
@@ -88,7 +89,25 @@
        private static $oldBadgeItemsSetting;
 
        protected function newSpecialPage() {
-               return new SpecialSetSiteLink();
+               $wikibaseRepo = WikibaseRepo::getDefaultInstance();
+               $siteLookup = $wikibaseRepo->getSiteLookup();
+               $settings = $wikibaseRepo->getSettings();
+
+               $siteLinkChangeOpFactory = 
$wikibaseRepo->getChangeOpFactoryProvider()->getSiteLinkChangeOpFactory();
+               $siteLinkTargetProvider = new SiteLinkTargetProvider(
+                       $siteLookup,
+                       $settings->getSetting( 'specialSiteLinkGroups' )
+               );
+
+               $labelDescriptionLookupFactory = 
$wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory();
+               return new SpecialSetSiteLink(
+                       $siteLookup,
+                       $siteLinkTargetProvider,
+                       $settings->getSetting( 'siteLinkGroups' ),
+                       $settings->getSetting( 'badgeItems' ),
+                       $labelDescriptionLookupFactory,
+                       $siteLinkChangeOpFactory
+               );
        }
 
        protected function setUp() {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6eef4a15872606dd9d7ef4cec50bb04501669cbd
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) <aleksey.bekh-iva...@wikimedia.de>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to