Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\Api\EntityIdSearchHelper Class Reference

Helper class to search for entities by ID. More...

+ Inheritance diagram for Wikibase\Repo\Api\EntityIdSearchHelper:
+ Collaboration diagram for Wikibase\Repo\Api\EntityIdSearchHelper:

Public Member Functions

 __construct (EntityLookup $entityLookup, EntityIdParser $idParser, LabelDescriptionLookup $labelDescriptionLookup, array $entityTypeToRepositoryMapping)
 
 getRankedSearchResults ( $text, $languageCode, $entityType, $limit, $strictLanguage)
 Gets exact matches. More...
 

Private Member Functions

 getEntityIdMatchingSearchTerm ( $term, $entityType)
 Returns EntityIds matching the search term (possibly with some repository prefix). More...
 
 getEntityIdCandidatesForSearchTerm ( $term)
 Returns a generator for candidates of entity ID serializations from a search term. More...
 
 getMatchingId (EntityId $entityId)
 Returns a list of entity IDs matching the pattern defined by $entityId: existing entities of type of $entityId, and serialized id equal to $entityId, possibly including prefixes of configured repositories. More...
 
 getDisplayTerms (EntityId $entityId)
 

Private Attributes

 $idParser
 
 $labelDescriptionLookup
 
 $entityLookup
 
 $entityTypeToRepositoryMapping
 

Detailed Description

Helper class to search for entities by ID.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Api\EntityIdSearchHelper::__construct ( EntityLookup  $entityLookup,
EntityIdParser  $idParser,
LabelDescriptionLookup  $labelDescriptionLookup,
array  $entityTypeToRepositoryMapping 
)
Parameters
EntityLookup$entityLookup
EntityIdParser$idParser
LabelDescriptionLookup$labelDescriptionLookup
string[][]$entityTypeToRepositoryMappingAssociative array (string => string[][]) mapping entity types to a list of repository names which provide entities of the given type.

Member Function Documentation

◆ getDisplayTerms()

Wikibase\Repo\Api\EntityIdSearchHelper::getDisplayTerms ( EntityId  $entityId)
private
Parameters
EntityId$entityId
Returns
Term[] array with keys 'label' and 'description'

◆ getEntityIdCandidatesForSearchTerm()

Wikibase\Repo\Api\EntityIdSearchHelper::getEntityIdCandidatesForSearchTerm (   $term)
private

Returns a generator for candidates of entity ID serializations from a search term.

Callers should attempt to parse each candidate in turn and use the first one that does not result in an EntityIdParsingException.

Parameters
string$term
Returns
\Generator

◆ getEntityIdMatchingSearchTerm()

Wikibase\Repo\Api\EntityIdSearchHelper::getEntityIdMatchingSearchTerm (   $term,
  $entityType 
)
private

Returns EntityIds matching the search term (possibly with some repository prefix).

If search term is a serialized entity id of the requested type, and multiple repositories provide entities of the type, prefixes of each of repositories are added to the search term and those repositories are searched for the result entity ID. If such concatenated entity IDs are found in several respective repositories, this returns all relevant matches.

Parameters
string$term
string$entityType
Returns
EntityId|null

◆ getMatchingId()

Wikibase\Repo\Api\EntityIdSearchHelper::getMatchingId ( EntityId  $entityId)
private

Returns a list of entity IDs matching the pattern defined by $entityId: existing entities of type of $entityId, and serialized id equal to $entityId, possibly including prefixes of configured repositories.

Parameters
EntityId$entityId
Returns
EntityId|null

◆ getRankedSearchResults()

Wikibase\Repo\Api\EntityIdSearchHelper::getRankedSearchResults (   $text,
  $languageCode,
  $entityType,
  $limit,
  $strictLanguage 
)

Gets exact matches.

If there are not enough exact matches, it gets prefixed matches.

Parameters
string$text
string$languageCode
string$entityType
int$limit
bool$strictLanguage
Returns
TermSearchResult[] Key: string Serialized EntityId

Implements Wikibase\Repo\Api\EntitySearchHelper.

Member Data Documentation

◆ $entityLookup

Wikibase\Repo\Api\EntityIdSearchHelper::$entityLookup
private

◆ $entityTypeToRepositoryMapping

Wikibase\Repo\Api\EntityIdSearchHelper::$entityTypeToRepositoryMapping
private

◆ $idParser

Wikibase\Repo\Api\EntityIdSearchHelper::$idParser
private

◆ $labelDescriptionLookup

Wikibase\Repo\Api\EntityIdSearchHelper::$labelDescriptionLookup
private

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