Adrian Lang has uploaded a new change for review.
https://gerrit.wikimedia.org/r/176237
Change subject: Inject siteLinkGroups into ItemView
......................................................................
Inject siteLinkGroups into ItemView
Change-Id: Icd9af0daf0353245eeb73c225dd9121a762d5e98
---
M repo/includes/View/EntityView.php
M repo/includes/View/EntityViewFactory.php
M repo/includes/View/ItemView.php
M repo/includes/WikibaseRepo.php
M repo/tests/phpunit/includes/View/EntityViewFactoryTest.php
5 files changed, 48 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/37/176237/1
diff --git a/repo/includes/View/EntityView.php
b/repo/includes/View/EntityView.php
index ee53a3b..59731f1 100644
--- a/repo/includes/View/EntityView.php
+++ b/repo/includes/View/EntityView.php
@@ -45,6 +45,11 @@
*/
protected $textInjector;
+ /**
+ * @param FingerprintView $fingerprintView
+ * @param ClaimsView $claimsView
+ * @param Language $language
+ */
public function __construct(
FingerprintView $fingerprintView,
ClaimsView $claimsView,
diff --git a/repo/includes/View/EntityViewFactory.php
b/repo/includes/View/EntityViewFactory.php
index 95cd0f5..de04594 100644
--- a/repo/includes/View/EntityViewFactory.php
+++ b/repo/includes/View/EntityViewFactory.php
@@ -41,15 +41,22 @@
*/
private $sectionEditLinkGenerator;
+ /**
+ * @var string[]
+ */
+ private $siteLinkGroups;
+
public function __construct(
EntityTitleLookup $entityTitleLookup,
EntityLookup $entityLookup,
- OutputFormatSnakFormatterFactory $snakFormatterFactory
+ OutputFormatSnakFormatterFactory $snakFormatterFactory,
+ array $siteLinkGroups
) {
$this->entityTitleLookup = $entityTitleLookup;
$this->entityLookup = $entityLookup;
$this->snakFormatterFactory = $snakFormatterFactory;
$this->sectionEditLinkGenerator = new
SectionEditLinkGenerator();
+ $this->siteLinkGroups = $siteLinkGroups;
}
/**
diff --git a/repo/includes/View/ItemView.php b/repo/includes/View/ItemView.php
index a3946ef..8b7087f 100644
--- a/repo/includes/View/ItemView.php
+++ b/repo/includes/View/ItemView.php
@@ -20,6 +20,30 @@
class ItemView extends EntityView {
/**
+ * @var string[]
+ */
+ private $siteLinkGroups;
+
+ /**
+ * @see EntityView::__construct
+ *
+ * @param FingerprintView $fingerprintView
+ * @param ClaimsView $claimsView
+ * @param Language $language
+ * @param string[] $siteLinkGroups
+ */
+ public function __construct(
+ FingerprintView $fingerprintView,
+ ClaimsView $claimsView,
+ Language $language,
+ array $siteLinkGroups
+ ) {
+ parent::__construct( $fingerprintView, $claimsView, $language );
+
+ $this->siteLinkGroups = $siteLinkGroups;
+ }
+
+ /**
* @see EntityView::getMainHtml
*/
protected function getMainHtml( EntityRevision $entityRevision, array
$entityInfo,
@@ -55,8 +79,7 @@
protected function getTocSections() {
$array = parent::getTocSections();
$array['claims'] = 'wikibase-statements';
- $groups =
WikibaseRepo::getDefaultInstance()->getSettings()->getSetting( 'siteLinkGroups'
);
- foreach ( $groups as $group ) {
+ foreach ( $this->siteLinkGroups as $group ) {
$id = htmlspecialchars( 'sitelinks-' . $group,
ENT_QUOTES );
$array[$id] = 'wikibase-sitelinks-' . $group;
}
@@ -75,7 +98,6 @@
*/
protected function getHtmlForSiteLinks( Item $item, $editable = true ) {
$wikibaseRepo = WikibaseRepo::getDefaultInstance();
- $groups = $wikibaseRepo->getSettings()->getSetting(
'siteLinkGroups' );
// FIXME: Inject this
$siteLinksView = new SiteLinksView(
@@ -87,7 +109,12 @@
$itemId = $item->getId();
- return $siteLinksView->getHtml( $item->getSiteLinks(), $itemId,
$groups, $editable );
+ return $siteLinksView->getHtml(
+ $item->getSiteLinks(),
+ $itemId,
+ $this->siteLinkGroups,
+ $editable
+ );
}
}
diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php
index d4f19b9..2b89aa0 100644
--- a/repo/includes/WikibaseRepo.php
+++ b/repo/includes/WikibaseRepo.php
@@ -972,7 +972,8 @@
$entityViewFactory = new EntityViewFactory(
$entityTitleLookup,
$this->getEntityLookup(),
- $this->getSnakFormatterFactory()
+ $this->getSnakFormatterFactory(),
+ $this->getSettings()->getSetting( 'siteLinkGroups' )
);
return new EntityParserOutputGeneratorFactory(
diff --git a/repo/tests/phpunit/includes/View/EntityViewFactoryTest.php
b/repo/tests/phpunit/includes/View/EntityViewFactoryTest.php
index 979cdb4..de720a0 100644
--- a/repo/tests/phpunit/includes/View/EntityViewFactoryTest.php
+++ b/repo/tests/phpunit/includes/View/EntityViewFactoryTest.php
@@ -58,7 +58,8 @@
return new EntityViewFactory(
$this->getEntityTitleLookup(),
new MockRepository(),
- $this->getSnakFormatterFactory()
+ $this->getSnakFormatterFactory(),
+ array()
);
}
--
To view, visit https://gerrit.wikimedia.org/r/176237
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd9af0daf0353245eeb73c225dd9121a762d5e98
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits