Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\Content\EntityContent Class Reference

Abstract content object for articles representing Wikibase entities. More...

+ Inheritance diagram for Wikibase\Repo\Content\EntityContent:
+ Collaboration diagram for Wikibase\Repo\Content\EntityContent:

Public Member Functions

 isValid ()
 
 isCountable ( $hasLinks=null)
 
 getEntityRedirect ()
 Returns the EntityRedirect represented by this EntityContent, or null if this EntityContent is not a redirect.
 
 getEntity ()
 Returns the entity contained by this entity content.
 
 getEntityHolder ()
 Returns a holder for the entity contained in this EntityContent object.
 
 getEntityId ()
 
 getTextForSearchIndex ()
 
 getTextForFilters ()
 
 getWikitextForTransclusion ()
 
 getTextForSummary ( $maxLength=250)
 Returns a textual representation of the content suitable for use in edit summaries and log messages.
 
 getNativeData ()
 
 getSize ()
 returns the content's nominal size in bogo-bytes.
 
 equals (Content $that=null)
 Both contents will be considered equal if they have the same ID and equal Entity data.
 
 getDiff (EntityContent $toContent)
 Returns a diff between this EntityContent and the given EntityContent.
 
 getPatchedCopy (EntityContentDiff $patch)
 Returns a patched copy of this Content object.
 
 isEmpty ()
 
 copy ()
 
 getEntityPageProperties ()
 Returns a map of properties about the entity, to be recorded in MediaWiki's page_props table.
 

Public Attributes

const EDIT_IGNORE_CONSTRAINTS = 1024
 Flag for use with EntityHandler::validateSave(), indicating that no pre-save validation should be applied.
 

Protected Member Functions

 getRedirectText ()
 
 getIgnoreKeysForFilters ()
 Get the keys within this Contents Entity JSON that should be removed for text passed to edit filters.
 

Private Member Functions

 getRedirectData ()
 Returns an array structure for the redirect represented by this EntityContent, if any.
 
 makeEmptyEntity ()
 
 getPatchedRedirect (Diff $redirectPatch)
 

Detailed Description

Abstract content object for articles representing Wikibase entities.

For more information on the relationship between entities and wiki pages, see docs/entity-storage.wiki.

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

@method \Wikibase\Repo\Content\EntityHandler getContentHandler()

Member Function Documentation

◆ copy()

Wikibase\Repo\Content\EntityContent::copy ( )
See also
Content::copy
Returns
self

◆ equals()

Wikibase\Repo\Content\EntityContent::equals ( Content $that = null)

Both contents will be considered equal if they have the same ID and equal Entity data.

If one of the contents is considered "new", then matching IDs is not a criteria for them to be considered equal.

See also
Content::equals
Parameters
Content | null$that
Returns
bool

◆ getDiff()

Wikibase\Repo\Content\EntityContent::getDiff ( EntityContent $toContent)

Returns a diff between this EntityContent and the given EntityContent.

Parameters
self$toContent
Returns
EntityContentDiff

◆ getEntity()

Wikibase\Repo\Content\EntityContent::getEntity ( )
abstract

Returns the entity contained by this entity content.

Deriving classes typically have a more specific get method as for greater clarity and type hinting.

Note
This method cannot be called on redirects (targets will never be resolved)
Returns
EntityDocument

Reimplemented in Wikibase\Repo\Content\ItemContent, and Wikibase\Repo\Content\PropertyContent.

◆ getEntityHolder()

Wikibase\Repo\Content\EntityContent::getEntityHolder ( )
abstract

Returns a holder for the entity contained in this EntityContent object.

Note
This method cannot be called on redirects (targets will never be resolved)
Returns
EntityHolder|null

Reimplemented in Wikibase\Repo\Content\ItemContent, and Wikibase\Repo\Content\PropertyContent.

◆ getEntityId()

Wikibase\Repo\Content\EntityContent::getEntityId ( )
Exceptions
RuntimeExceptionif the content object is empty or no entity ID is set
Returns
EntityId

◆ getEntityPageProperties()

Wikibase\Repo\Content\EntityContent::getEntityPageProperties ( )

Returns a map of properties about the entity, to be recorded in MediaWiki's page_props table.

The idea is to allow efficient lookups of entities based on such properties.

Returns
array A map from property names to property values.

Reimplemented in Wikibase\Repo\Content\ItemContent, and Wikibase\Repo\Content\PropertyContent.

◆ getEntityRedirect()

Wikibase\Repo\Content\EntityContent::getEntityRedirect ( )

Returns the EntityRedirect represented by this EntityContent, or null if this EntityContent is not a redirect.

Note
This default implementation will fail if isRedirect() is true. Subclasses that support redirects must override getEntityRedirect().
Exceptions
LogicException
Returns
EntityRedirect|null

Reimplemented in Wikibase\Repo\Content\ItemContent.

◆ getIgnoreKeysForFilters()

Wikibase\Repo\Content\EntityContent::getIgnoreKeysForFilters ( )
abstractprotected

Get the keys within this Contents Entity JSON that should be removed for text passed to edit filters.

Returns
string[] Keys to ignore

Reimplemented in Wikibase\Repo\Content\ItemContent, and Wikibase\Repo\Content\PropertyContent.

◆ getNativeData()

Wikibase\Repo\Content\EntityContent::getNativeData ( )
See also
Content::getNativeData
Note
Avoid relying on this method! It bypasses EntityContentCodec, and does not make any guarantees about the structure of the array returned.
Returns
string[]|EntityDocument An undefined data structure representing the content. This is not guaranteed to conform to any serialization structure used in the database or externally.

◆ getPatchedCopy()

Wikibase\Repo\Content\EntityContent::getPatchedCopy ( EntityContentDiff $patch)

Returns a patched copy of this Content object.

Parameters
EntityContentDiff$patch
Exceptions
PatcherException
Returns
self

◆ getPatchedRedirect()

Wikibase\Repo\Content\EntityContent::getPatchedRedirect ( Diff $redirectPatch)
private
Parameters
Diff$redirectPatch
Returns
EntityRedirect|null

◆ getRedirectData()

Wikibase\Repo\Content\EntityContent::getRedirectData ( )
private

Returns an array structure for the redirect represented by this EntityContent, if any.

Note
This may or may not be consistent with what EntityContentCodec does. It is intended to be used primarily for diffing.
Returns
string[]

◆ getRedirectText()

Wikibase\Repo\Content\EntityContent::getRedirectText ( )
protected
Returns
string Returns the string representation of the redirect represented by this EntityContent (if any).
Note
Will fail if this EntityContent is not a redirect.

◆ getSize()

Wikibase\Repo\Content\EntityContent::getSize ( )

returns the content's nominal size in bogo-bytes.

Returns
int

◆ getTextForFilters()

Wikibase\Repo\Content\EntityContent::getTextForFilters ( )
Returns
string A string representing the content in a way useful for content filtering as performed by extensions like AbuseFilter.

◆ getTextForSearchIndex()

Wikibase\Repo\Content\EntityContent::getTextForSearchIndex ( )
Returns
string A string representing the content in a way useful for building a full text search index.

Reimplemented in Wikibase\Repo\Content\ItemContent.

◆ getTextForSummary()

Wikibase\Repo\Content\EntityContent::getTextForSummary ( $maxLength = 250)

Returns a textual representation of the content suitable for use in edit summaries and log messages.

Parameters
int$maxLengthmaximum length of the summary text
Returns
string

◆ getWikitextForTransclusion()

Wikibase\Repo\Content\EntityContent::getWikitextForTransclusion ( )
Returns
string|false The wikitext to include when another page includes this content, or false if the content is not includable in a wikitext page.

◆ isCountable()

Wikibase\Repo\Content\EntityContent::isCountable ( $hasLinks = null)
See also
EntityContent::isCountable
Parameters
bool | null$hasLinks
Returns
bool True if this is not a redirect and the item is not empty.

◆ isEmpty()

Wikibase\Repo\Content\EntityContent::isEmpty ( )
Returns
bool True if this is not a redirect and the page is empty.

Reimplemented in Wikibase\Repo\Content\ItemContent, and Wikibase\Repo\Content\PropertyContent.

◆ isValid()

Wikibase\Repo\Content\EntityContent::isValid ( )
See also
Content::isValid()
Returns
bool True if this content object is valid for saving. False if there is no entity, or the entity does not have an ID set.

Reimplemented in Wikibase\Repo\Content\PropertyContent.

◆ makeEmptyEntity()

Wikibase\Repo\Content\EntityContent::makeEmptyEntity ( )
private
Returns
EntityDocument

Member Data Documentation

◆ EDIT_IGNORE_CONSTRAINTS

const Wikibase\Repo\Content\EntityContent::EDIT_IGNORE_CONSTRAINTS = 1024

Flag for use with EntityHandler::validateSave(), indicating that no pre-save validation should be applied.

Can be passed in via EditEntity::attemptSave, EntityStore::saveEntity, as well as WikiPage::doUserEditContent()

Note
: must not collide with the EDIT_XXX flags defined by MediaWiki core in Defines.php.

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