jenkins-bot has submitted this change and it was merged.
Change subject: Inject id formatter into ClaimDifferenceVisualizer
......................................................................
Inject id formatter into ClaimDifferenceVisualizer
Change-Id: I8d072f10d237ec0de997f4f0abdf5732de238d88
---
M lib/includes/ClaimDifferenceVisualizer.php
M repo/includes/EntityContentDiffView.php
M repo/includes/actions/EditEntityAction.php
3 files changed, 32 insertions(+), 7 deletions(-)
Approvals:
Tobias Gritschacher: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/includes/ClaimDifferenceVisualizer.php
b/lib/includes/ClaimDifferenceVisualizer.php
index 2609984..226829b 100644
--- a/lib/includes/ClaimDifferenceVisualizer.php
+++ b/lib/includes/ClaimDifferenceVisualizer.php
@@ -3,6 +3,7 @@
use Html;
use Diff\Diff;
+use Wikibase\Lib\EntityIdFormatter;
/**
* Class for generating HTML for Claim Diffs.
@@ -43,16 +44,32 @@
private $entityLookup;
/**
+ * @since 0.4
+ *
+ * @var string
+ */
+ private $langCode;
+
+ /**
+ * @since 0.4
+ *
+ * @var EntityIdFormatter
+ */
+ private $idFormatter;
+
+ /**
* Constructor.
*
* @since 0.4
*
* @param EntityLookup $entityLookup
* @param string $langCode
+ * @param EntityIdFormatter $idFormatter
*/
- public function __construct( $entityLookup, $langCode ) {
+ public function __construct( $entityLookup, $langCode,
EntityIdFormatter $idFormatter ) {
$this->entityLookup = $entityLookup;
$this->langCode = $langCode;
+ $this->idFormatter = $idFormatter;
}
/**
@@ -296,19 +313,17 @@
* @return string
*/
protected function getEntityLabel( EntityId $entityId ) {
- $label = $entityId->getPrefixedId();
-
$entity = $this->entityLookup->getEntity( $entityId );
if ( $entity instanceof Entity ) {
$lookedUpLabel = $this->entityLookup->getEntity(
$entityId )->getLabel( $this->langCode );
if ( $lookedUpLabel !== false ) {
- $label = $lookedUpLabel;
+ return $lookedUpLabel;
}
}
- return $label;
+ return $this->idFormatter->format( $entityId );
}
/**
diff --git a/repo/includes/EntityContentDiffView.php
b/repo/includes/EntityContentDiffView.php
index cf58ddd..9db84f3 100644
--- a/repo/includes/EntityContentDiffView.php
+++ b/repo/includes/EntityContentDiffView.php
@@ -4,6 +4,7 @@
use Diff\ListDiffer;
use Content, Html;
+use Wikibase\Repo\WikibaseRepo;
/**
* Difference view for Wikibase entities.
@@ -138,7 +139,11 @@
$diffVisualizer = new EntityDiffVisualizer(
$this->getContext(),
new ClaimDiffer( new ListDiffer() ),
- new ClaimDifferenceVisualizer( new
WikiPageEntityLookup(), $langCode )
+ new ClaimDifferenceVisualizer(
+ new WikiPageEntityLookup(),
+ $langCode,
+ WikibaseRepo::newInstance()->getIdFormatter()
+ )
);
return $diffVisualizer->visualizeDiff( $diff );
diff --git a/repo/includes/actions/EditEntityAction.php
b/repo/includes/actions/EditEntityAction.php
index 802d706..7c1e667 100644
--- a/repo/includes/actions/EditEntityAction.php
+++ b/repo/includes/actions/EditEntityAction.php
@@ -2,6 +2,7 @@
namespace Wikibase;
use Html, Linker, Skin, Status, Revision;
+use Wikibase\Repo\WikibaseRepo;
/**
* @file
@@ -434,7 +435,11 @@
$diffVisualizer = new EntityDiffVisualizer(
$this->getContext(),
new ClaimDiffer( new \Diff\ListDiffer() ),
- new ClaimDifferenceVisualizer( new
WikiPageEntityLookup(), $langCode )
+ new ClaimDifferenceVisualizer(
+ new WikiPageEntityLookup(),
+ $langCode,
+ WikibaseRepo::newInstance()->getIdFormatter()
+ )
);
$this->getOutput()->addHTML( $diffVisualizer->visualizeDiff(
$diff ) );
--
To view, visit https://gerrit.wikimedia.org/r/64488
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8d072f10d237ec0de997f4f0abdf5732de238d88
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Anja Jentzsch <[email protected]>
Gerrit-Reviewer: Ataherivand <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Jens Ohlig <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: John Erling Blad <[email protected]>
Gerrit-Reviewer: Lydia Pintscher <[email protected]>
Gerrit-Reviewer: Markus Kroetzsch <[email protected]>
Gerrit-Reviewer: Nikola Smolenski <[email protected]>
Gerrit-Reviewer: Silke Meyer <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits