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

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

Change subject: Split entity-id-builder-pair config into pattern and builder
......................................................................

Split entity-id-builder-pair config into pattern and builder

Accessing this stuff via [0] and [1] indexes is a bit odd, even if I
understand the intention. I believe these should be separate, making it
possible to reuse one or the other without having to know about both.

Change-Id: I8f0b050ca0eb558016af74b8560515354792b6a7
---
M docs/entitytypes.wiki
M lib/WikibaseLib.entitytypes.php
M lib/includes/EntityTypeDefinitions.php
3 files changed, 14 insertions(+), 17 deletions(-)


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

diff --git a/docs/entitytypes.wiki b/docs/entitytypes.wiki
index 3a7bc85..8cc5727 100644
--- a/docs/entitytypes.wiki
+++ b/docs/entitytypes.wiki
@@ -45,9 +45,10 @@
 ; deserializer-factory-callback (repo and client)
 : a callable that returns a DispatchableDeserializer instance, with the first 
and only argument
   being a DeserializerFactory
-; entity-id-builder-pair (repo and client)
-: an array with two elements: First a regular expression that matches 
serialized entity ids,
-  second a callable that returns an EntityId instance for a given entity id 
serialization
+; entity-id-pattern (repo and client)
+: a regular expression that matches serialized entity ids
+; entity-id-builder (repo and client)
+: a callable that returns an EntityId instance for a given entity id 
serialization
 ; view-factory-callback (repo only)
 : a callable that returns an EntityView instance, with the arguments being a 
language code, a
   LabelDescriptionLookup, a LanguageFallbackChain and an EditSectionGenerator
diff --git a/lib/WikibaseLib.entitytypes.php b/lib/WikibaseLib.entitytypes.php
index 94fd72b..8e891f8 100644
--- a/lib/WikibaseLib.entitytypes.php
+++ b/lib/WikibaseLib.entitytypes.php
@@ -34,12 +34,10 @@
                'deserializer-factory-callback' => function( 
DeserializerFactory $deserializerFactory ) {
                        return $deserializerFactory->newItemDeserializer();
                },
-               'entity-id-builder-pair' => [
-                       ItemId::PATTERN,
-                       function( $serialization ) {
-                               return new ItemId( $serialization );
-                       }
-               ],
+               'entity-id-pattern' => ItemId::PATTERN,
+               'entity-id-builder' => function( $serialization ) {
+                       return new ItemId( $serialization );
+               },
                'entity-differ-strategy-builder' => function() {
                        return new ItemDiffer();
                },
@@ -54,12 +52,10 @@
                'deserializer-factory-callback' => function( 
DeserializerFactory $deserializerFactory ) {
                        return $deserializerFactory->newPropertyDeserializer();
                },
-               'entity-id-builder-pair' => [
-                       PropertyId::PATTERN,
-                       function( $serialization ) {
-                               return new PropertyId( $serialization );
-                       }
-               ],
+               'entity-id-pattern' => PropertyId::PATTERN,
+               'entity-id-builder' => function( $serialization ) {
+                       return new PropertyId( $serialization );
+               },
                'entity-differ-strategy-builder' => function() {
                        return new PropertyDiffer();
                },
diff --git a/lib/includes/EntityTypeDefinitions.php 
b/lib/includes/EntityTypeDefinitions.php
index 1fcc2f1..6c540ea 100644
--- a/lib/includes/EntityTypeDefinitions.php
+++ b/lib/includes/EntityTypeDefinitions.php
@@ -134,8 +134,8 @@
                $result = [];
 
                foreach ( $this->entityTypeDefinitions as $def ) {
-                       if ( isset( $def['entity-id-builder-pair'] ) ) {
-                               $result[ $def['entity-id-builder-pair'][0] ] = 
$def['entity-id-builder-pair'][1];
+                       if ( isset( $def['entity-id-pattern'] ) && isset( 
$def['entity-id-builder'] ) ) {
+                               $result[$def['entity-id-pattern']] = 
$def['entity-id-builder'];
                        }
                }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f0b050ca0eb558016af74b8560515354792b6a7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

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

Reply via email to