Wikibase
MediaWiki Wikibase extension
Wikibase\DataModel\Services\EntityId\PrefixMappingEntityIdParser Class Reference

EntityIdParser that maps a prefix of id serialization to a local prefix according to the prefix mapping, or adds a fixed prefix to the id serialization not containing a mapped prefix, and parses resulting string as an EntityId. More...

+ Inheritance diagram for Wikibase\DataModel\Services\EntityId\PrefixMappingEntityIdParser:
+ Collaboration diagram for Wikibase\DataModel\Services\EntityId\PrefixMappingEntityIdParser:

Public Member Functions

 __construct (array $prefixMapping, EntityIdParser $idParser)
 
 parse ( $idSerialization)
 Maps prefix(es) of the id serialization according to the prefix mapping definition, or adds a fixed prefix to the id serialization if there is no relevant prefix mapping, Resulting id serialization is parsed as an EntityId. More...
 

Private Attributes

 $prefixMapping
 
 $idParser
 

Detailed Description

EntityIdParser that maps a prefix of id serialization to a local prefix according to the prefix mapping, or adds a fixed prefix to the id serialization not containing a mapped prefix, and parses resulting string as an EntityId.

This can be used to prefix IDs of entities coming from a foreign repository with the repository name to avoid clashes with IDs of local entities.

See also
docs/foreign-entity-ids.wiki in the DataModel module
Since
3.7

Constructor & Destructor Documentation

◆ __construct()

Wikibase\DataModel\Services\EntityId\PrefixMappingEntityIdParser::__construct ( array  $prefixMapping,
EntityIdParser  $idParser 
)
Since
3.7
Parameters
string[]$prefixMappingMust contain an empty-string key defining prefix added to id serializations that do not contain any of prefixed defined in $prefixMapping. Values should not contain colons, in particular at the end of the string
EntityIdParser$idParser
Exceptions
ParameterAssertionException

Member Function Documentation

◆ parse()

Wikibase\DataModel\Services\EntityId\PrefixMappingEntityIdParser::parse (   $idSerialization)

Maps prefix(es) of the id serialization according to the prefix mapping definition, or adds a fixed prefix to the id serialization if there is no relevant prefix mapping, Resulting id serialization is parsed as an EntityId.

Since
3.7
See also
docs/foreign-entity-ids.wiki in the DataModel module
Parameters
string$idSerialization
Returns
EntityId
Exceptions
EntityIdParsingException

Implements Wikibase\DataModel\Entity\EntityIdParser.

Member Data Documentation

◆ $idParser

Wikibase\DataModel\Services\EntityId\PrefixMappingEntityIdParser::$idParser
private

◆ $prefixMapping

Wikibase\DataModel\Services\EntityId\PrefixMappingEntityIdParser::$prefixMapping
private

The documentation for this class was generated from the following file: