jenkins-bot has submitted this change and it was merged.
Change subject: Rename formatter option RESOLVE_ID to LOOKUP_LABEL
......................................................................
Rename formatter option RESOLVE_ID to LOOKUP_LABEL
This is a follow-up to one of the comments in
Iec03211105a921669e140b0d3cbbabeec4caed97.
I'm going introduce an EntityTermLookup in a future patch. It will
be used to lookup labels, descriptions and if the Entity exists.
What the option does is turning this "label lookup" on/off.
It doesn't necesarry "resolve an ID".
Again, this patch alone may look a bit pointless. It's part of a
much bigger change.
Change-Id: If065f9fe39ccfd50c715f6d5a8a39bdf3189708d
---
M lib/includes/formatters/EntityIdHtmlLinkFormatter.php
M lib/includes/formatters/EntityIdLabelFormatter.php
M lib/tests/phpunit/formatters/EntityIdLabelFormatterTest.php
3 files changed, 10 insertions(+), 10 deletions(-)
Approvals:
WikidataJenkins: Verified
Daniel Kinzler: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/includes/formatters/EntityIdHtmlLinkFormatter.php
b/lib/includes/formatters/EntityIdHtmlLinkFormatter.php
index a7be129..12b97e4 100644
--- a/lib/includes/formatters/EntityIdHtmlLinkFormatter.php
+++ b/lib/includes/formatters/EntityIdHtmlLinkFormatter.php
@@ -39,7 +39,7 @@
$label = $value->getPrefixedId();
- if ( $this->getOption( self::OPT_RESOLVE_ID ) ) {
+ if ( $this->getOption( self::OPT_LOOKUP_LABEL ) ) {
try {
$itemLabel = $this->lookupItemLabel( $value );
if ( is_string( $itemLabel ) ) {
diff --git a/lib/includes/formatters/EntityIdLabelFormatter.php
b/lib/includes/formatters/EntityIdLabelFormatter.php
index b1cc162..83fc3a7 100644
--- a/lib/includes/formatters/EntityIdLabelFormatter.php
+++ b/lib/includes/formatters/EntityIdLabelFormatter.php
@@ -26,12 +26,12 @@
/**
* Whether we should try to find the label of the entity
*/
- const OPT_RESOLVE_ID = 'resolveEntityId';
+ const OPT_LOOKUP_LABEL = 'lookup';
/**
* What we should do if we can't find the label.
*/
- const OPT_LABEL_FALLBACK = 'labelFallback';
+ const OPT_LABEL_FALLBACK = 'fallback';
const FALLBACK_PREFIXED_ID = 0;
const FALLBACK_EMPTY_STRING = 1;
@@ -45,18 +45,18 @@
/**
* @since 0.4
*
- * @param FormatterOptions $options Supported options: OPT_RESOLVE_ID
(boolean),
+ * @param FormatterOptions $options Supported options: OPT_LOOKUP_LABEL
(boolean),
* OPT_LABEL_FALLBACK (FALLBACK_XXX)
* @param EntityLookup $entityLookup
*
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function __construct( FormatterOptions $options, EntityLookup
$entityLookup ) {
parent::__construct( $options );
$this->entityLookup = $entityLookup;
- $this->defaultOption( self::OPT_RESOLVE_ID, true );
+ $this->defaultOption( self::OPT_LOOKUP_LABEL, true );
$this->defaultOption( self::OPT_LABEL_FALLBACK,
self::FALLBACK_PREFIXED_ID );
$fallbackOptionIsValid = in_array(
@@ -72,8 +72,8 @@
throw new InvalidArgumentException( 'Bad value for
OPT_LABEL_FALLBACK option' );
}
- if ( !is_bool( $this->getOption( self::OPT_RESOLVE_ID ) ) ) {
- throw new InvalidArgumentException( 'Bad value for
OPT_RESOLVE_ID option: must be a boolean' );
+ if ( !is_bool( $this->getOption( self::OPT_LOOKUP_LABEL ) ) ) {
+ throw new InvalidArgumentException( 'Bad value for
OPT_LOOKUP_LABEL option: must be a boolean' );
}
}
@@ -94,7 +94,7 @@
$label = null;
- if ( $this->getOption( self::OPT_RESOLVE_ID ) ) {
+ if ( $this->getOption( self::OPT_LOOKUP_LABEL ) ) {
try {
$label = $this->lookupItemLabel( $value );
} catch ( OutOfBoundsException $ex ) {
diff --git a/lib/tests/phpunit/formatters/EntityIdLabelFormatterTest.php
b/lib/tests/phpunit/formatters/EntityIdLabelFormatterTest.php
index 9059d51..2ebec3c 100644
--- a/lib/tests/phpunit/formatters/EntityIdLabelFormatterTest.php
+++ b/lib/tests/phpunit/formatters/EntityIdLabelFormatterTest.php
@@ -125,7 +125,7 @@
$options = new FormatterOptions();
$options->setOption( EntityIdLabelFormatter::OPT_LANG, 'en' );
- $options->setOption( EntityIdLabelFormatter::OPT_RESOLVE_ID,
false );
+ $options->setOption( EntityIdLabelFormatter::OPT_LOOKUP_LABEL,
false );
$argLists[] = array( new EntityIdValue( new ItemId( 'Q42' ) ),
'Q42', $options );
--
To view, visit https://gerrit.wikimedia.org/r/126055
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If065f9fe39ccfd50c715f6d5a8a39bdf3189708d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: WikidataJenkins <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits