Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\Api\EntityLoadingHelper Class Reference

Helper class for api modules to load entities. More...

+ Inheritance diagram for Wikibase\Repo\Api\EntityLoadingHelper:

Public Member Functions

 __construct (ApiBase $apiModule, EntityIdParser $idParser, EntityRevisionLookup $entityRevisionLookup, ApiErrorReporter $errorReporter)
 
 getEntityIdParam ()
 Returns the name of the request parameter expected to contain the ID of the entity to load.
 
 setEntityIdParam ( $entityIdParam)
 Sets the name of the request parameter expected to contain the ID of the entity to load.
 
 setEntityByLinkedTitleLookup (EntityByLinkedTitleLookup $lookup)
 
 getDefaultRetrievalMode ()
 
 setDefaultRetrievalMode ( $defaultRetrievalMode)
 
 loadEntity (EntityId $entityId=null)
 
 getEntityIdFromParams (array $params)
 

Protected Member Functions

 loadEntityRevision (EntityId $entityId, $revId=0, $mode=null)
 Load the entity content of the given revision.
 

Protected Attributes

 $apiModule
 
 $entityRevisionLookup
 
 $errorReporter
 
 $defaultRetrievalMode = LookupConstants::LATEST_FROM_REPLICA
 

Private Member Functions

 getEntityIdFromString ( $id)
 Returns an EntityId object based on the given $id, or throws a usage exception if the ID is invalid.
 
 getEntityIdFromSiteTitleCombination ( $site, $title)
 

Private Attributes

 $idParser
 
 $entityByLinkedTitleLookup = null
 
 $entityIdParam = 'entity'
 

Detailed Description

Helper class for api modules to load entities.

Author
Addshore
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Api\EntityLoadingHelper::__construct ( ApiBase  $apiModule,
EntityIdParser  $idParser,
EntityRevisionLookup  $entityRevisionLookup,
ApiErrorReporter  $errorReporter 
)

Member Function Documentation

◆ getDefaultRetrievalMode()

Wikibase\Repo\Api\EntityLoadingHelper::getDefaultRetrievalMode ( )
Returns
string

◆ getEntityIdFromParams()

Wikibase\Repo\Api\EntityLoadingHelper::getEntityIdFromParams ( array  $params)
Parameters
string[]$params
Returns
EntityId|null

◆ getEntityIdFromSiteTitleCombination()

Wikibase\Repo\Api\EntityLoadingHelper::getEntityIdFromSiteTitleCombination (   $site,
  $title 
)
private
Parameters
string$site
string$title
Exceptions
ApiUsageExceptionIf no such entity is found.
Returns
EntityId The ID of the entity connected to $title on $site.

◆ getEntityIdFromString()

Wikibase\Repo\Api\EntityLoadingHelper::getEntityIdFromString (   $id)
private

Returns an EntityId object based on the given $id, or throws a usage exception if the ID is invalid.

Parameters
string$id
Exceptions
ApiUsageException
Returns
EntityId

◆ getEntityIdParam()

Wikibase\Repo\Api\EntityLoadingHelper::getEntityIdParam ( )

Returns the name of the request parameter expected to contain the ID of the entity to load.

Returns
string

◆ loadEntity()

Wikibase\Repo\Api\EntityLoadingHelper::loadEntity ( EntityId  $entityId = null)
Parameters
EntityId | null$entityIdID of the entity to load. If not given, the ID is taken from the request parameters. If $entityId is given, it must be consistent with the 'baserevid' parameter.
Returns
EntityDocument

◆ loadEntityRevision()

Wikibase\Repo\Api\EntityLoadingHelper::loadEntityRevision ( EntityId  $entityId,
  $revId = 0,
  $mode = null 
)
protected

Load the entity content of the given revision.

Will fail by calling dieException() $this->errorReporter if the revision cannot be found or cannot be loaded.

Parameters
EntityId$entityIdEntityId of the page to load the revision for
int$revIdThe desired revision id, or 0 for the latest revision.
string | null$modeLATEST_FROM_REPLICA, LATEST_FROM_REPLICA_WITH_FALLBACK or LATEST_FROM_MASTER (from EntityRevisionLookup). Null for the default.
Exceptions
ApiUsageException
LogicException
Returns
EntityRevision|null

◆ setDefaultRetrievalMode()

Wikibase\Repo\Api\EntityLoadingHelper::setDefaultRetrievalMode (   $defaultRetrievalMode)
Parameters
string$defaultRetrievalModeUse the LATEST_XXX constants defined in EntityRevisionLookup

◆ setEntityByLinkedTitleLookup()

Wikibase\Repo\Api\EntityLoadingHelper::setEntityByLinkedTitleLookup ( EntityByLinkedTitleLookup  $lookup)

◆ setEntityIdParam()

Wikibase\Repo\Api\EntityLoadingHelper::setEntityIdParam (   $entityIdParam)

Sets the name of the request parameter expected to contain the ID of the entity to load.

Parameters
string$entityIdParam

Member Data Documentation

◆ $apiModule

Wikibase\Repo\Api\EntityLoadingHelper::$apiModule
protected

◆ $defaultRetrievalMode

Wikibase\Repo\Api\EntityLoadingHelper::$defaultRetrievalMode = LookupConstants::LATEST_FROM_REPLICA
protected

◆ $entityByLinkedTitleLookup

Wikibase\Repo\Api\EntityLoadingHelper::$entityByLinkedTitleLookup = null
private

◆ $entityIdParam

Wikibase\Repo\Api\EntityLoadingHelper::$entityIdParam = 'entity'
private

◆ $entityRevisionLookup

Wikibase\Repo\Api\EntityLoadingHelper::$entityRevisionLookup
protected

◆ $errorReporter

Wikibase\Repo\Api\EntityLoadingHelper::$errorReporter
protected

◆ $idParser

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

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