Wikibase
MediaWiki Wikibase extension
|
Helper class for api modules to load entities. More...
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. More... | |
setEntityIdParam ( $entityIdParam) | |
Sets the name of the request parameter expected to contain the ID of the entity to load. More... | |
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. More... | |
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. More... | |
getEntityIdFromSiteTitleCombination ( $site, $title) | |
revisionIdMatchesEntityId (int $revId, EntityId $entityId) | |
Whether the specified revision could theoretically contain the specified entity. More... | |
Private Attributes | |
$idParser | |
$entityByLinkedTitleLookup = null | |
$entityIdParam = 'entity' | |
Helper class for api modules to load entities.
Wikibase\Repo\Api\EntityLoadingHelper::__construct | ( | RevisionLookup | $revisionLookup, |
TitleFactory | $titleFactory, | ||
EntityIdParser | $idParser, | ||
EntityRevisionLookup | $entityRevisionLookup, | ||
EntityTitleStoreLookup | $entityTitleStoreLookup, | ||
ApiErrorReporter | $errorReporter | ||
) |
Wikibase\Repo\Api\EntityLoadingHelper::getDefaultRetrievalMode | ( | ) |
Wikibase\Repo\Api\EntityLoadingHelper::getEntityIdFromParams | ( | array | $params | ) |
string[] | $params |
|
private |
string | $site | |
string | $title |
ApiUsageException | If no such entity is found. |
|
private |
Returns an EntityId object based on the given $id, or throws a usage exception if the ID is invalid.
string | $id |
ApiUsageException |
Wikibase\Repo\Api\EntityLoadingHelper::getEntityIdParam | ( | ) |
Returns the name of the request parameter expected to contain the ID of the entity to load.
Wikibase\Repo\Api\EntityLoadingHelper::loadEntity | ( | array | $requestParams, |
EntityId | $entityId = null |
||
) |
array | $requestParams | the output of ApiBase::extractRequestParams() |
EntityId | null | $entityId | ID 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. |
|
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.
EntityId | $entityId | EntityId of the page to load the revision for |
int | $revId | The desired revision id, or 0 for the latest revision. |
string | null | $mode | LATEST_FROM_REPLICA, LATEST_FROM_REPLICA_WITH_FALLBACK or LATEST_FROM_MASTER (from EntityRevisionLookup). Null for the default. |
ApiUsageException | |
LogicException |
|
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).
int | $revId | |
EntityId | $entityId |
Wikibase\Repo\Api\EntityLoadingHelper::setDefaultRetrievalMode | ( | $defaultRetrievalMode | ) |
string | $defaultRetrievalMode | Use the LATEST_XXX constants defined in EntityRevisionLookup |
Wikibase\Repo\Api\EntityLoadingHelper::setEntityByLinkedTitleLookup | ( | EntityByLinkedTitleLookup | $lookup | ) |
Wikibase\Repo\Api\EntityLoadingHelper::setEntityIdParam | ( | $entityIdParam | ) |
Sets the name of the request parameter expected to contain the ID of the entity to load.
string | $entityIdParam |
|
protected |
|
private |
|
private |
|
protected |
|
protected |
|
protected |
|
private |
|
protected |
|
protected |