Jeroen De Dauw has uploaded a new change for review.

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


Change subject: Remove OPT_PREFIX_MAP from EntityIdFormatter
......................................................................

Remove OPT_PREFIX_MAP from EntityIdFormatter

Change-Id: I9ecfc59e72840b06dc2d6abc699d073baf3388be
---
M lib/includes/TypedValueFormatter.php
M lib/includes/formatters/EntityIdFormatter.php
M repo/includes/EntityView.php
M repo/includes/WikibaseRepo.php
M repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
M repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php
M repo/tests/phpunit/includes/LinkedData/EntityDataUriManagerTest.php
M repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
M repo/tests/phpunit/includes/rdf/RdfSerializerTest.php
9 files changed, 10 insertions(+), 82 deletions(-)


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

diff --git a/lib/includes/TypedValueFormatter.php 
b/lib/includes/TypedValueFormatter.php
index c4f7fe0..9365046 100644
--- a/lib/includes/TypedValueFormatter.php
+++ b/lib/includes/TypedValueFormatter.php
@@ -70,17 +70,7 @@
        private function evilGetEntityIdFormatter( $language ) {
                $entityLookup = new CachingEntityLoader( new 
WikiPageEntityLookup( Settings::get( 'repoDatabase' ) ) );
 
-               $prefixMap = array();
-
-               foreach ( Settings::get( 'entityPrefixes' ) as $prefix => 
$entityType ) {
-                       $prefixMap[$entityType] = $prefix;
-               }
-
-               $options = new FormatterOptions( array(
-                       EntityIdFormatter::OPT_PREFIX_MAP => $prefixMap
-               ) );
-
-               $idFormatter = new EntityIdFormatter( $options );
+               $idFormatter = new EntityIdFormatter( new FormatterOptions() );
 
                $options = new FormatterOptions();
                $options->setOption( EntityIdLabelFormatter::OPT_LANG, 
$language );
diff --git a/lib/includes/formatters/EntityIdFormatter.php 
b/lib/includes/formatters/EntityIdFormatter.php
index 8f516be..a369afc 100644
--- a/lib/includes/formatters/EntityIdFormatter.php
+++ b/lib/includes/formatters/EntityIdFormatter.php
@@ -20,11 +20,6 @@
 class EntityIdFormatter extends ValueFormatterBase {
 
        /**
-        * @deprecated
-        */
-       const OPT_PREFIX_MAP = 'prefixmap';
-
-       /**
         * Format an EntityId data value
         *
         * @since 0.4
diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index 5557d30..ef2d88d 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -627,13 +627,8 @@
 
                $languageCode = isset( $lang ) ? $lang->getCode() : 
$wgLang->getCode();
 
-               $entitiesPrefixMap = array();
-               foreach ( Settings::get( 'entityPrefixes' ) as $prefix => 
$entityType ) {
-                       $entitiesPrefixMap[ $entityType ] = $prefix;
-               }
                $valueFormatterOptions = new FormatterOptions( array(
                        ValueFormatter::OPT_LANG => $languageCode,
-                       Lib\EntityIdFormatter::OPT_PREFIX_MAP => 
$entitiesPrefixMap,
                        TimeFormatter::OPT_TIME_ISO_FORMATTER => new 
MwTimeIsoFormatter(
                                new FormatterOptions( array( 
ValueFormatter::OPT_LANG => $languageCode ) )
                        ),
diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php
index a479af3..d8ea89e 100644
--- a/repo/includes/WikibaseRepo.php
+++ b/repo/includes/WikibaseRepo.php
@@ -167,17 +167,7 @@
         */
        public function getIdFormatter() {
                if ( $this->idFormatter === null ) {
-                       $prefixMap = array();
-
-                       foreach ( $this->settings->getSetting( 'entityPrefixes' 
) as $prefix => $entityType ) {
-                               $prefixMap[$entityType] = $prefix;
-                       }
-
-                       $options = new FormatterOptions( array(
-                               EntityIdFormatter::OPT_PREFIX_MAP => $prefixMap
-                       ) );
-
-                       $this->idFormatter = new EntityIdFormatter( $options );
+                       $this->idFormatter = new EntityIdFormatter( new 
FormatterOptions() );
                }
 
                return $this->idFormatter;
@@ -275,17 +265,7 @@
         * @return EntityIdFormatter
         */
        public function getEntityIdFormatter() {
-               $prefixMap = array();
-
-               foreach ( $this->settings->getSetting( 'entityPrefixes' ) as 
$prefix => $entityType ) {
-                       $prefixMap[$entityType] = $prefix;
-               }
-
-               $options = new FormatterOptions( array(
-                       EntityIdFormatter::OPT_PREFIX_MAP => $prefixMap
-               ) );
-
-               return new EntityIdFormatter( $options );
+               return $this->getIdFormatter();
        }
 
        /**
diff --git 
a/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php 
b/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
index 67f1263..ee744f9 100644
--- a/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
+++ b/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
@@ -104,16 +104,8 @@
                $entityLookup = new MockRepository();
                $dataTypeFactory = new DataTypeFactory( 
EntityDataSerializationServiceTest::$dataTypes );
 
-               $prefixes = array(
-                       Item::ENTITY_TYPE => 'q',
-                       Property::ENTITY_TYPE => 'p',
-               );
-               $idFormatter = new EntityIdFormatter( new FormatterOptions( 
array(
-                       EntityIdFormatter::OPT_PREFIX_MAP => $prefixes
-               ) ) );
-               $idParser = new EntityIdParser( new ParserOptions( array(
-                       EntityIdFormatter::OPT_PREFIX_MAP => array_flip( 
$prefixes )
-               ) ) );
+               $idFormatter = new EntityIdFormatter( new FormatterOptions() );
+               $idParser = new EntityIdParser( new ParserOptions() );
 
                $contentFactory = new EntityContentFactory(
                        $idFormatter,
diff --git 
a/repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php 
b/repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php
index 248edd3..ec792aa 100644
--- 
a/repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php
+++ 
b/repo/tests/phpunit/includes/LinkedData/EntityDataSerializationServiceTest.php
@@ -75,12 +75,7 @@
        protected function newService() {
                $entityLookup = new MockRepository();
                $dataTypeFactory = new DataTypeFactory( self::$dataTypes );
-               $idFormatter = new EntityIdFormatter( new FormatterOptions( 
array(
-                       EntityIdFormatter::OPT_PREFIX_MAP => array(
-                               Item::ENTITY_TYPE => 'Q',
-                               Property::ENTITY_TYPE => 'P',
-                       )
-               ) ) );
+               $idFormatter = new EntityIdFormatter( new FormatterOptions() );
 
                $service = new EntityDataSerializationService(
                        self::URI_BASE,
diff --git 
a/repo/tests/phpunit/includes/LinkedData/EntityDataUriManagerTest.php 
b/repo/tests/phpunit/includes/LinkedData/EntityDataUriManagerTest.php
index c19623b..eac437e 100644
--- a/repo/tests/phpunit/includes/LinkedData/EntityDataUriManagerTest.php
+++ b/repo/tests/phpunit/includes/LinkedData/EntityDataUriManagerTest.php
@@ -62,18 +62,9 @@
        public function setUp() {
                parent::setUp();
 
-               $prefixes = array(
-                       Item::ENTITY_TYPE => 'q',
-                       Property::ENTITY_TYPE => 'p',
-               );
+               $this->idFormatter = new EntityIdFormatter( new 
FormatterOptions() );
 
-               $this->idFormatter = new EntityIdFormatter( new 
FormatterOptions( array(
-                       EntityIdFormatter::OPT_PREFIX_MAP => $prefixes
-               ) ) );
-
-               $this->idParser = new EntityIdParser( new ParserOptions( array(
-                       EntityIdFormatter::OPT_PREFIX_MAP => array_flip( 
$prefixes )
-               ) ) );
+               $this->idParser = new EntityIdParser( new ParserOptions() );
 
 }
 
diff --git a/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php 
b/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
index 838645d..bc5fa1b 100644
--- a/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
+++ b/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
@@ -213,12 +213,7 @@
         * @return RdfBuilder
         */
        protected static function newRdfBuilder() {
-               $idFormatter = new EntityIdFormatter( new FormatterOptions( 
array(
-                       EntityIdFormatter::OPT_PREFIX_MAP => array(
-                               Item::ENTITY_TYPE => 'Q',
-                               Property::ENTITY_TYPE => 'P',
-                       )
-               ) ) );
+               $idFormatter = new EntityIdFormatter( new FormatterOptions() );
 
                return new RdfBuilder(
                        self::URI_BASE,
diff --git a/repo/tests/phpunit/includes/rdf/RdfSerializerTest.php 
b/repo/tests/phpunit/includes/rdf/RdfSerializerTest.php
index f184614..aed6fb0 100644
--- a/repo/tests/phpunit/includes/rdf/RdfSerializerTest.php
+++ b/repo/tests/phpunit/includes/rdf/RdfSerializerTest.php
@@ -144,12 +144,7 @@
                $format = RdfSerializer::getFormat( $formatName );
 
                $dataTypes = new DataTypeFactory( self::$dataTypes );
-               $idSerializer = new EntityIdFormatter( new FormatterOptions( 
array(
-                       EntityIdFormatter::OPT_PREFIX_MAP => array(
-                               Item::ENTITY_TYPE => 'Q',
-                               Property::ENTITY_TYPE => 'P',
-                       )
-               ) ) );
+               $idSerializer = new EntityIdFormatter( new FormatterOptions() );
 
                $mockRepo = new MockRepository();
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ecfc59e72840b06dc2d6abc699d073baf3388be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to