Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup Class Reference

Service for getting the closest entity (out of a specified set), from a given starting entity. More...

+ Inheritance diagram for Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup:
+ Collaboration diagram for Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup:

Public Member Functions

 __construct (EntityLookup $entityLookup, EntityPrefetcher $entityPrefetcher, $maxDepth, $maxEntityVisits)
 
 getReferencedEntityId (EntityId $fromId, PropertyId $propertyId, array $toIds)
 Get the closest entity (out of $toIds), from a given entity.
 

Private Member Functions

 processEntityById (EntityId $id, EntityId $fromId, PropertyId $propertyId, array $toIds, array &$toVisit)
 Find out whether an entity (directly) references one of the target ids.
 
 getEntity (EntityId $id, EntityId $fromId, PropertyId $propertyId, array $toIds)
 
 processSnak (Snak $snak, array &$toVisit, array $toIds)
 Decide whether a single Snak is pointing to one of the target ids.
 
 getMainSnaks (StatementListProvider $statementListProvider, PropertyId $propertyId)
 

Private Attributes

 $entityLookup
 
 $entityPrefetcher
 
 $maxDepth
 
 $maxEntityVisits
 
 $alreadyVisited = []
 

Detailed Description

Service for getting the closest entity (out of a specified set), from a given starting entity.

The starting entity, and the target entities are (potentially indirectly, via intermediate entities) linked by statements with a given property ID, pointing from the starting entity to one of the target entities.

Since
3.10
Author
Marius Hoch

Constructor & Destructor Documentation

◆ __construct()

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::__construct ( EntityLookup $entityLookup,
EntityPrefetcher $entityPrefetcher,
$maxDepth,
$maxEntityVisits )
Parameters
EntityLookup$entityLookup
EntityPrefetcher$entityPrefetcher
int$maxDepthMaximum search depth: Maximum number of intermediate entities to search through. For example if 0 is given, only the entities immediately referenced will be found. If this limit gets exhausted, a MaxReferenceDepthExhaustedException is thrown.
int$maxEntityVisitsMaximum number of entities to retrieve during a lookup. If this limit gets exhausted, a MaxReferencedEntityVisitsExhaustedException is thrown.

Member Function Documentation

◆ getEntity()

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::getEntity ( EntityId $id,
EntityId $fromId,
PropertyId $propertyId,
array $toIds )
private
Parameters
EntityId$idId of the entity to get
EntityId$fromIdId this lookup started from
PropertyId$propertyId
EntityId[]$toIds
Returns
StatementListProvider|null Null if not applicable.

◆ getMainSnaks()

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::getMainSnaks ( StatementListProvider $statementListProvider,
PropertyId $propertyId )
private
Parameters
StatementListProvider$statementListProvider
PropertyId$propertyId
Returns
Snak[]

◆ getReferencedEntityId()

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::getReferencedEntityId ( EntityId $fromId,
PropertyId $propertyId,
array $toIds )

Get the closest entity (out of $toIds), from a given entity.

The starting entity, and the target entities are (potentially indirectly, via intermediate entities) linked by statements with the given property ID, pointing from the starting entity to one of the target entities.

Since
3.10
Parameters
EntityId$fromId
PropertyId$propertyId
EntityId[]$toIds
Returns
EntityId|null Returns null in case none of the target entities are referenced.
Exceptions
ReferencedEntityIdLookupException

Implements Wikibase\DataModel\Services\Lookup\ReferencedEntityIdLookup.

◆ processEntityById()

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::processEntityById ( EntityId $id,
EntityId $fromId,
PropertyId $propertyId,
array $toIds,
array & $toVisit )
private

Find out whether an entity (directly) references one of the target ids.

Parameters
EntityId$idId of the entity to process
EntityId$fromIdId this lookup started from
PropertyId$propertyId
EntityId[]$toIds
EntityId[]&$toVisitList of entities that still need to be checked
Returns
EntityId|null Target id the entity refers to, null if none.

◆ processSnak()

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::processSnak ( Snak $snak,
array & $toVisit,
array $toIds )
private

Decide whether a single Snak is pointing to one of the target ids.

Parameters
Snak$snak
EntityId[]&$toVisitList of entities that still need to be checked
EntityId[]$toIds
Returns
EntityId|null Target id the Snak refers to, null if none.

Member Data Documentation

◆ $alreadyVisited

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::$alreadyVisited = []
private

◆ $entityLookup

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::$entityLookup
private

◆ $entityPrefetcher

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::$entityPrefetcher
private

◆ $maxDepth

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::$maxDepth
private

◆ $maxEntityVisits

Wikibase\DataModel\Services\Lookup\EntityRetrievingClosestReferencedEntityIdLookup::$maxEntityVisits
private

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