Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\Api\ModifyEntity Class Reference

Base class for API modules modifying a single entity identified based on id xor a combination of site and page title. More...

+ Inheritance diagram for Wikibase\Repo\Api\ModifyEntity:
+ Collaboration diagram for Wikibase\Repo\Api\ModifyEntity:

Public Member Functions

 __construct (ApiMain $mainModule, string $moduleName, bool $federatedPropertiesEnabled, string $modulePrefix='')
 
 setServices (SiteLinkGlobalIdentifiersProvider $siteLinkGlobalIdentifiersProvider)
 
 execute ()
 
 isFreshIdAssigned ()
 Return whether a fresh id is assigned or not. More...
 

Protected Member Functions

 getTitleLookup ()
 
 getResultBuilder ()
 
 createSummary (array $params)
 Create a new Summary instance suitable for representing the action performed by this module. More...
 
 modifyEntity (EntityDocument $entity, ChangeOp $changeOp, array $preparedParameters)
 Actually modify the entity. More...
 
 applyChangeOp (ChangeOp $changeOp, EntityDocument $entity, Summary $summary=null)
 Applies the given ChangeOp to the given Entity. More...
 
 prepareParameters (array $params)
 
 validateEntitySpecificParameters (array $preparedParameters, EntityDocument $entity, int $baseRevId)
 
 validateParameters (array $params)
 Make sure the required parameters are provided and that they are valid. More...
 
 getChangeOp (array $preparedParameters, EntityDocument $entity)
 
 getAllowedParams ()
 

Protected Attributes

 $stringNormalizer
 
 $siteLinkGlobalIdentifiersProvider
 
 $siteLinkGroups
 
 $badgeItems
 
 $errorReporter
 
 $enabledEntityTypes
 

Private Member Functions

 loadEntityFromSavingHelper (?EntityId $entityId)
 Try to find the entity or fail and create it, or die in the process. More...
 
 checkPermissions (EntityDocument $entity, User $user, ChangeOp $changeOp)
 Check the rights for the user accessing the module. More...
 
 addToOutput (EntityDocument $entity, Status $status, int $oldRevId)
 
 getAllowedParamsForId ()
 Get allowed params for the identification of the entity Lookup through an id is common for all entities. More...
 
 getAllowedParamsForSiteLink ()
 Get allowed params for the identification by a sitelink pair Lookup through the sitelink object is not used in every subclasses. More...
 
 getAllowedParamsForEntity ()
 Get allowed params for the entity in general. More...
 

Private Attributes

 $titleLookup
 
 $permissionChecker
 
 $revisionLookup
 
 $resultBuilder
 
 $entitySavingHelper
 
 $isFreshIdAssigned
 

Detailed Description

Base class for API modules modifying a single entity identified based on id xor a combination of site and page title.

Author
John Erling Blad < jebla.nosp@m.d@gm.nosp@m.ail.c.nosp@m.om >
Daniel Kinzler
Michał Łazowik

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Api\ModifyEntity::__construct ( ApiMain  $mainModule,
string  $moduleName,
bool  $federatedPropertiesEnabled,
string  $modulePrefix = '' 
)
Parameters
ApiMain$mainModule
string$moduleName
bool$federatedPropertiesEnabled
string$modulePrefix
See also
ApiBase::__construct

Member Function Documentation

◆ addToOutput()

Wikibase\Repo\Api\ModifyEntity::addToOutput ( EntityDocument  $entity,
Status  $status,
int  $oldRevId 
)
private

◆ applyChangeOp()

Wikibase\Repo\Api\ModifyEntity::applyChangeOp ( ChangeOp  $changeOp,
EntityDocument  $entity,
Summary  $summary = null 
)
protected

Applies the given ChangeOp to the given Entity.

Any ChangeOpException is converted into an ApiUsageException with the code 'modification-failed'.

Parameters
ChangeOp$changeOp
EntityDocument$entity
Summary | null$summaryThe summary object to update with information about the change.
Returns
ChangeOpResult

◆ checkPermissions()

Wikibase\Repo\Api\ModifyEntity::checkPermissions ( EntityDocument  $entity,
User  $user,
ChangeOp  $changeOp 
)
private

Check the rights for the user accessing the module.

Parameters
EntityDocument$entitythe entity to check
User$userUser doing the action
ChangeOp$changeOp
Returns
Status the check's result

◆ createSummary()

Wikibase\Repo\Api\ModifyEntity::createSummary ( array  $params)
protected

Create a new Summary instance suitable for representing the action performed by this module.

Parameters
array$params
Returns
Summary

Reimplemented in Wikibase\Repo\Api\ModifyTerm.

◆ execute()

Wikibase\Repo\Api\ModifyEntity::execute ( )

◆ getAllowedParams()

◆ getAllowedParamsForEntity()

Wikibase\Repo\Api\ModifyEntity::getAllowedParamsForEntity ( )
private

Get allowed params for the entity in general.

Returns
array

◆ getAllowedParamsForId()

Wikibase\Repo\Api\ModifyEntity::getAllowedParamsForId ( )
private

Get allowed params for the identification of the entity Lookup through an id is common for all entities.

Returns
array[]

◆ getAllowedParamsForSiteLink()

Wikibase\Repo\Api\ModifyEntity::getAllowedParamsForSiteLink ( )
private

Get allowed params for the identification by a sitelink pair Lookup through the sitelink object is not used in every subclasses.

Returns
array[]

◆ getChangeOp()

Wikibase\Repo\Api\ModifyEntity::getChangeOp ( array  $preparedParameters,
EntityDocument  $entity 
)
abstractprotected

◆ getResultBuilder()

Wikibase\Repo\Api\ModifyEntity::getResultBuilder ( )
protected

◆ getTitleLookup()

Wikibase\Repo\Api\ModifyEntity::getTitleLookup ( )
protected

◆ isFreshIdAssigned()

Wikibase\Repo\Api\ModifyEntity::isFreshIdAssigned ( )

Return whether a fresh id is assigned or not.

Returns
bool false if fresh id is not assigned, true otherwise

◆ loadEntityFromSavingHelper()

Wikibase\Repo\Api\ModifyEntity::loadEntityFromSavingHelper ( ?EntityId  $entityId)
private

Try to find the entity or fail and create it, or die in the process.

Parameters
EntityId | null$entityId
Returns
EntityDocument
Exceptions
ApiUsageException

◆ modifyEntity()

Wikibase\Repo\Api\ModifyEntity::modifyEntity ( EntityDocument  $entity,
ChangeOp  $changeOp,
array  $preparedParameters 
)
abstractprotected

Actually modify the entity.

Parameters
EntityDocument$entity
ChangeOp$changeOp
array$preparedParameters
Returns
Summary|null a summary of the modification, or null to indicate failure.

Reimplemented in Wikibase\Repo\Api\SetSiteLink, Wikibase\Repo\Api\SetLabel, Wikibase\Repo\Api\SetDescription, Wikibase\Repo\Api\SetAliases, and Wikibase\Repo\Api\EditEntity.

◆ prepareParameters()

Wikibase\Repo\Api\ModifyEntity::prepareParameters ( array  $params)
protected
Parameters
array$params
Returns
array

Reimplemented in Wikibase\Repo\Api\EditEntity.

◆ setServices()

Wikibase\Repo\Api\ModifyEntity::setServices ( SiteLinkGlobalIdentifiersProvider  $siteLinkGlobalIdentifiersProvider)

◆ validateEntitySpecificParameters()

Wikibase\Repo\Api\ModifyEntity::validateEntitySpecificParameters ( array  $preparedParameters,
EntityDocument  $entity,
int  $baseRevId 
)
protected

Reimplemented in Wikibase\Repo\Api\EditEntity.

◆ validateParameters()

Wikibase\Repo\Api\ModifyEntity::validateParameters ( array  $params)
protected

Make sure the required parameters are provided and that they are valid.

Parameters
array$params

Reimplemented in Wikibase\Repo\Api\SetAliases.

Member Data Documentation

◆ $badgeItems

Wikibase\Repo\Api\ModifyEntity::$badgeItems
protected

◆ $enabledEntityTypes

Wikibase\Repo\Api\ModifyEntity::$enabledEntityTypes
protected

◆ $entitySavingHelper

Wikibase\Repo\Api\ModifyEntity::$entitySavingHelper
private

◆ $errorReporter

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

◆ $isFreshIdAssigned

Wikibase\Repo\Api\ModifyEntity::$isFreshIdAssigned
private

◆ $permissionChecker

Wikibase\Repo\Api\ModifyEntity::$permissionChecker
private

◆ $resultBuilder

Wikibase\Repo\Api\ModifyEntity::$resultBuilder
private

◆ $revisionLookup

Wikibase\Repo\Api\ModifyEntity::$revisionLookup
private

◆ $siteLinkGlobalIdentifiersProvider

Wikibase\Repo\Api\ModifyEntity::$siteLinkGlobalIdentifiersProvider
protected

◆ $siteLinkGroups

Wikibase\Repo\Api\ModifyEntity::$siteLinkGroups
protected

◆ $stringNormalizer

Wikibase\Repo\Api\ModifyEntity::$stringNormalizer
protected

◆ $titleLookup

Wikibase\Repo\Api\ModifyEntity::$titleLookup
private

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