Wikibase
MediaWiki Wikibase extension
|
Minimal interface for all objects that represent an entity. More...
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. | |
Minimal interface for all objects that represent an entity.
All entities have an entity type and an EntityId.
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.
Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.
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.
mixed | $target |
Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.
Wikibase\DataModel\Entity\EntityDocument::getId | ( | ) |
Returns the id of the entity or null if it does not have one.
Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.
Wikibase\DataModel\Entity\EntityDocument::getType | ( | ) |
Returns a type identifier for the entity, e.g.
"item" or "property".
Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.
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.
Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.
Wikibase\DataModel\Entity\EntityDocument::setId | ( | $id | ) |
Sets the id of the entity.
A specific derivative of EntityId is always supported.
EntityId | $id |
InvalidArgumentException | if the id is not of the correct type. |
Implemented in Wikibase\DataModel\Entity\Item, and Wikibase\DataModel\Entity\Property.