Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\ChangeOp\ChangeOpReference Class Reference

Class for reference change operation. More...

+ Inheritance diagram for Wikibase\Repo\ChangeOp\ChangeOpReference:
+ Collaboration diagram for Wikibase\Repo\ChangeOp\ChangeOpReference:

Public Member Functions

 __construct ( $statementGuid, Reference $reference, $referenceHash, SnakValidator $snakValidator, $index=null)
 Constructs a new reference change operation.
 
 apply (EntityDocument $entity, Summary $summary=null)
 
 validate (EntityDocument $entity)
 
- Public Member Functions inherited from Wikibase\Repo\ChangeOp\ChangeOpBase
 getActions ()
 

Protected Member Functions

 addReference (ReferenceList $references, Summary $summary=null)
 
 setReference (ReferenceList $references, Summary $summary=null)
 
 getSnakSummaryArgs (Snak $snak)
 
- Protected Member Functions inherited from Wikibase\Repo\ChangeOp\ChangeOpBase
 updateSummary (?Summary $summary, $action, $language='', $args='')
 

Private Attributes

 $statementGuid
 
 $reference
 
 $referenceHash
 
 $index
 
 $snakValidator
 

Detailed Description

Class for reference change operation.

Author
Tobias Gritschacher < tobia.nosp@m.s.gr.nosp@m.itsch.nosp@m.ache.nosp@m.r@wik.nosp@m.imed.nosp@m.ia.de >
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\ChangeOp\ChangeOpReference::__construct (   $statementGuid,
Reference  $reference,
  $referenceHash,
SnakValidator  $snakValidator,
  $index = null 
)

Constructs a new reference change operation.

Parameters
string$statementGuid
Reference$reference
string$referenceHash(if empty '' a new reference will be created)
SnakValidator$snakValidator
int | null$index
Exceptions
InvalidArgumentException

Member Function Documentation

◆ addReference()

Wikibase\Repo\ChangeOp\ChangeOpReference::addReference ( ReferenceList  $references,
Summary  $summary = null 
)
protected
Parameters
ReferenceList$references
Summary | null$summary
Exceptions
ChangeOpException

◆ apply()

Wikibase\Repo\ChangeOp\ChangeOpReference::apply ( EntityDocument  $entity,
Summary  $summary = null 
)
  • a new reference gets added when $referenceHash is empty and $reference is set
  • the reference gets set to $reference when $referenceHash and $reference are set

Applies the change represented by this ChangeOp to the given Entity.As ChangeOp does not yet know whether it is going to change the entity or not, and since expensive validations should be run only on ChangeOps that will change the entity, ChangeOpResult::validate is recommended for such validations.

Parameters
EntityDocument$entity
Summary | null$summary
Exceptions
InvalidArgumentExceptionwhen called with an unexpected entity type.
ChangeOpExceptionwhen the change can not be applied to the entity, e.g. because the same data was edited in the meantime.
Returns
ChangeOpResult

Implements Wikibase\Repo\ChangeOp\ChangeOp.

◆ getSnakSummaryArgs()

Wikibase\Repo\ChangeOp\ChangeOpReference::getSnakSummaryArgs ( Snak  $snak)
protected
Parameters
Snak$snak
Returns
array

◆ setReference()

Wikibase\Repo\ChangeOp\ChangeOpReference::setReference ( ReferenceList  $references,
Summary  $summary = null 
)
protected
Parameters
ReferenceList$references
Summary | null$summary
Exceptions
ChangeOpException

◆ validate()

Wikibase\Repo\ChangeOp\ChangeOpReference::validate ( EntityDocument  $entity)
See also
ChangeOp::validate
Parameters
EntityDocument$entity
Returns
Result

Implements Wikibase\Repo\ChangeOp\ChangeOp.

Member Data Documentation

◆ $index

Wikibase\Repo\ChangeOp\ChangeOpReference::$index
private

◆ $reference

Wikibase\Repo\ChangeOp\ChangeOpReference::$reference
private

◆ $referenceHash

Wikibase\Repo\ChangeOp\ChangeOpReference::$referenceHash
private

◆ $snakValidator

Wikibase\Repo\ChangeOp\ChangeOpReference::$snakValidator
private

◆ $statementGuid

Wikibase\Repo\ChangeOp\ChangeOpReference::$statementGuid
private

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