Wikibase
MediaWiki Wikibase extension
Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup Class Reference

EntityLookup that uses an in memory array to retrieve the requested information. More...

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

Public Member Functions

 __construct (... $entities)
 
 addEntity (EntityDocument $entity)
 
 addException (EntityLookupException $exception)
 Registers an exception that will be thrown when a entity with the id in the exception is requested. More...
 
 getEntity (EntityId $entityId)
 
 hasEntity (EntityId $entityId)
 
 getItemForId (ItemId $itemId)
 
 getPropertyForId (PropertyId $propertyId)
 

Private Member Functions

 throwExceptionIfNeeded (EntityId $entityId)
 

Private Attributes

 $entities = []
 
 $exceptions = []
 

Detailed Description

EntityLookup that uses an in memory array to retrieve the requested information.

One can also specify exceptions that should be thrown when an entity with their associated ID is requested.

This class can be used as a fake in tests.

Since
2.0
Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >

Constructor & Destructor Documentation

◆ __construct()

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::__construct (   $entities)
Parameters
EntityDocument...$entities

Member Function Documentation

◆ addEntity()

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::addEntity ( EntityDocument  $entity)
Parameters
EntityDocument$entity
Exceptions
InvalidArgumentException

◆ addException()

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::addException ( EntityLookupException  $exception)

Registers an exception that will be thrown when a entity with the id in the exception is requested.

If an exception with the same EntityId was already present it will be replaced by the new one.

Since
3.1
Parameters
EntityLookupException$exception

◆ getEntity()

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::getEntity ( EntityId  $entityId)
See also
EntityLookup::getEntity
Parameters
EntityId$entityId
Exceptions
EntityLookupException
Returns
EntityDocument

Implements Wikibase\DataModel\Services\Lookup\EntityLookup.

◆ getItemForId()

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::getItemForId ( ItemId  $itemId)
Since
2.0
Parameters
ItemId$itemId
Returns
Item|null
Exceptions
ItemLookupException

Implements Wikibase\DataModel\Services\Lookup\ItemLookup.

◆ getPropertyForId()

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::getPropertyForId ( PropertyId  $propertyId)
Since
2.0
Parameters
PropertyId$propertyId
Returns
Property|null
Exceptions
PropertyLookupException

Implements Wikibase\DataModel\Services\Lookup\PropertyLookup.

◆ hasEntity()

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::hasEntity ( EntityId  $entityId)
See also
EntityLookup::hasEntity
Parameters
EntityId$entityId
Exceptions
EntityLookupException
Returns
bool

Implements Wikibase\DataModel\Services\Lookup\EntityLookup.

◆ throwExceptionIfNeeded()

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::throwExceptionIfNeeded ( EntityId  $entityId)
private

Member Data Documentation

◆ $entities

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::$entities = []
private

◆ $exceptions

Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup::$exceptions = []
private

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