Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: Stop EntityIdFormatter extending ValueFormatterBase
......................................................................

Stop EntityIdFormatter extending ValueFormatterBase

ValueFormatterBase is in data-values/interfaces. This should not be
a ValueFormatter.

Warning, I have not searched for places that type hint against
ValueFormatter or ValueFormatterBase but expect an EntityIdFormatter.
Our tests should cover this, shouldn't they?

Change-Id: I7653399247bbf31ec70defeb36f4e99de14fa788
---
M lib/includes/formatters/EntityIdFormatter.php
M lib/includes/formatters/EntityIdHtmlLinkFormatter.php
M lib/includes/formatters/EntityIdTitleFormatter.php
3 files changed, 40 insertions(+), 5 deletions(-)


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

diff --git a/lib/includes/formatters/EntityIdFormatter.php 
b/lib/includes/formatters/EntityIdFormatter.php
index 3571ee6..d1676cb 100644
--- a/lib/includes/formatters/EntityIdFormatter.php
+++ b/lib/includes/formatters/EntityIdFormatter.php
@@ -3,7 +3,7 @@
 namespace Wikibase\Lib;
 
 use InvalidArgumentException;
-use ValueFormatters\ValueFormatterBase;
+use ValueFormatters\FormatterOptions;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\EntityIdValue;
 
@@ -14,7 +14,42 @@
  * @author Jeroen De Dauw < jeroended...@gmail.com >
  * @author Thiemo Mättig
  */
-class EntityIdFormatter extends ValueFormatterBase {
+class EntityIdFormatter {
+
+       const OPT_LANG = 'lang';
+
+       /**
+        * @var FormatterOptions
+        */
+       private $options;
+
+       /**
+        * @param FormatterOptions $options
+        */
+       public function __construct( FormatterOptions $options ) {
+               $this->options = $options;
+
+               $this->options->defaultOption( self::OPT_LANG, 'en' );
+       }
+
+       /**
+        * Shortcut to $this->options->getOption.
+        *
+        * @param string $option
+        */
+       protected final function getOption( $option ) {
+               return $this->options->getOption( $option );
+       }
+
+       /**
+        * Shortcut to $this->options->defaultOption.
+        *
+        * @param string $option
+        * @param mixed $default
+        */
+       protected final function defaultOption( $option, $default ) {
+               $this->options->defaultOption( $option, $default );
+       }
 
        /**
         * Format an EntityId data value
@@ -32,7 +67,7 @@
                }
 
                if ( !( $value instanceof EntityId ) ) {
-                       throw new InvalidArgumentException( 'Data value type 
mismatch. Expected an EntityId or EntityIdValue.' );
+                       throw new InvalidArgumentException( '$value must be an 
EntityId or EntityIdValue' );
                }
 
                return $this->formatEntityId( $value );
diff --git a/lib/includes/formatters/EntityIdHtmlLinkFormatter.php 
b/lib/includes/formatters/EntityIdHtmlLinkFormatter.php
index c99cebc..3e26b3e 100644
--- a/lib/includes/formatters/EntityIdHtmlLinkFormatter.php
+++ b/lib/includes/formatters/EntityIdHtmlLinkFormatter.php
@@ -22,7 +22,7 @@
        /**
         * @var EntityTitleLookup
         */
-       protected $entityTitleLookup;
+       private $entityTitleLookup;
 
        public function __construct(
                FormatterOptions $options,
diff --git a/lib/includes/formatters/EntityIdTitleFormatter.php 
b/lib/includes/formatters/EntityIdTitleFormatter.php
index c18ddd7..0f625af 100644
--- a/lib/includes/formatters/EntityIdTitleFormatter.php
+++ b/lib/includes/formatters/EntityIdTitleFormatter.php
@@ -19,7 +19,7 @@
        /**
         * @var EntityTitleLookup
         */
-       protected $titleLookup;
+       private $titleLookup;
 
        /**
         * @param FormatterOptions $options

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7653399247bbf31ec70defeb36f4e99de14fa788
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

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

Reply via email to