Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\DataModel\Entity\EntityDocument Interface Reference

Minimal interface for all objects that represent an entity. More...

+ Inheritance diagram for Wikibase\DataModel\Entity\EntityDocument:

Public Member Functions

 getType ()
 Returns a type identifier for the entity, e.g.
 
 getId ()
 Returns the id of the entity or null if it does not have one.
 
 setId ( $id)
 Sets the id of the entity.
 
 isEmpty ()
 An entity is considered empty if it does not contain any content that can be removed.
 
 equals ( $target)
 Two entities are considered equal if they are of the same type and have the same value.
 
 copy ()
 Returns a deep clone of the entity.
 

Detailed Description

Minimal interface for all objects that represent an entity.

All entities have an entity type and an EntityId.

Since
0.8.2
Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >
Bene* < benes.nosp@m.tar..nosp@m.wikim.nosp@m.edia.nosp@m.@gmai.nosp@m.l.co.nosp@m.m >

Member Function Documentation

◆ copy()

Wikibase\DataModel\Entity\EntityDocument::copy ( )

Returns a deep clone of the entity.

The clone must be equal in all details, including the id. No change done to the clone is allowed to interfere with the original object. Only properties containing immutable objects are allowed to (and should) reference the original object.

Since EntityDocuments are mutable (at least the id can be set) the method is not allowed to return $this.

Since
5.0
Returns
self

Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.

◆ equals()

Wikibase\DataModel\Entity\EntityDocument::equals (   $target)

Two entities are considered equal if they are of the same type and have the same value.

The value does not include the id, so entities with the same value but different id are considered equal.

Since
5.0
Parameters
mixed$target
Returns
bool

Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.

◆ getId()

Wikibase\DataModel\Entity\EntityDocument::getId ( )

Returns the id of the entity or null if it does not have one.

Since
0.8.2
Returns
EntityId|null

Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.

◆ getType()

Wikibase\DataModel\Entity\EntityDocument::getType ( )

Returns a type identifier for the entity, e.g.

"item" or "property".

Since
0.8.2
Returns
string

Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.

◆ isEmpty()

Wikibase\DataModel\Entity\EntityDocument::isEmpty ( )

An entity is considered empty if it does not contain any content that can be removed.

Having an ID set never counts as having content.

Knowing if an entity is empty is relevant when, for example, moving or merging entities and code wants to make sure all content is transferred from the old to the new entity.

Since
4.3
Returns
bool

Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.

◆ setId()

Wikibase\DataModel\Entity\EntityDocument::setId (   $id)

Sets the id of the entity.

A specific derivative of EntityId is always supported.

Since
3.0
Parameters
EntityId$id
Exceptions
InvalidArgumentExceptionif the id is not of the correct type.

Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.


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