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 (RevisionLookup $revisionLookup, TitleFactory $titleFactory, EntityIdParser $idParser, EntityRevisionLookup $entityRevisionLookup, EntityTitleStoreLookup $entityTitleStoreLookup, 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 (array $requestParams, 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

 $revisionLookup
 
 $titleFactory
 
 $entityRevisionLookup
 
 $entityTitleStoreLookup
 
 $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)
 
 revisionIdMatchesEntityId (int $revId, EntityId $entityId)
 Whether the specified revision could theoretically contain the specified entity.
 

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 ( RevisionLookup $revisionLookup,
TitleFactory $titleFactory,
EntityIdParser $idParser,
EntityRevisionLookup $entityRevisionLookup,
EntityTitleStoreLookup $entityTitleStoreLookup,
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 ( array $requestParams,
EntityId $entityId = null )
Parameters
array$requestParamsthe output of ApiBase::extractRequestParams()
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

◆ revisionIdMatchesEntityId()

Wikibase\Repo\Api\EntityLoadingHelper::revisionIdMatchesEntityId ( int $revId,
EntityId $entityId )
private

Whether the specified revision could theoretically contain the specified entity.

This method is used when the EntityRevisionLookup has already reported that the revision does not actually contain that entity, to decide whether that should be reported as a “bad revision” error (e.g. no such revision, belongs to a non-entity page, etc.) or a “no such entity” condition (e.g. entity type stored in non-main slot and revision happens to contain no such slot).

Parameters
int$revId
EntityId$entityId
Returns
bool

◆ 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

◆ $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

◆ $entityTitleStoreLookup

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

◆ $errorReporter

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

◆ $idParser

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

◆ $revisionLookup

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

◆ $titleFactory

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

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