Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
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 $entityTypes)
 
 getRankedSearchResults ( $text, $languageCode, $entityType, $limit, $strictLanguage, ?string $profileContext)
 Gets exact matches.
 

Private Member Functions

 getEntityIdMatchingSearchTerm ( $term, $entityType)
 Returns EntityId matching the search term.
 
 getEntityIdCandidatesForSearchTerm ( $term)
 Returns a generator for candidates of entity ID serializations from a search term.
 
 getMatchingId (EntityId $entityId)
 Returns an entity ID matching the pattern defined by $entityId: existing entity of type of $entityId, and serialized id equal to $entityId.
 
 getDisplayTerms (EntityId $entityId)
 

Private Attributes

 $idParser
 
 $labelDescriptionLookup
 
 $entityLookup
 
 $entityTypes
 

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 $entityTypes )
Parameters
EntityLookup$entityLookup
EntityIdParser$idParser
LabelDescriptionLookup$labelDescriptionLookup
string[]$entityTypeslist of "names" of known entity types

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 EntityId matching the search term.

Parameters
string$term
string$entityType
Returns
EntityId|null

◆ getMatchingId()

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

Returns an entity ID matching the pattern defined by $entityId: existing entity of type of $entityId, and serialized id equal to $entityId.

Parameters
EntityId$entityId
Returns
EntityId|null

◆ getRankedSearchResults()

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

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
string | null$profileContext
Returns
TermSearchResult[] Key: string Serialized EntityId

Implements Wikibase\Repo\Api\EntitySearchHelper.

Member Data Documentation

◆ $entityLookup

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

◆ $entityTypes

Wikibase\Repo\Api\EntityIdSearchHelper::$entityTypes
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: