Jump to content

Manual:SlotRecord.php

From mediawiki.org

The SlotRecord class is used for any Value object representing a content slot associated with a page revision. It provides direct access to a Content object. Such access may be implemented through a callback.

SlotRecord uses NonSerializableTrait.

Constants

[edit]

MAIN = 'main'

Public methods

[edit]

Methods for creating a SlotRecord

[edit]
  • newWithSuppressedContent( SlotRecord $slot ) - returns a new SlotRecord just like the given $slot, except that calling getContent() will fail with an exception.
  • newDerived( string $role, Content $content ) - returns a SlotRecord ('newUnsaved') for a derived slot.
  • newInherited( SlotRecord $slot ) - constructs a new SlotRecord for a new revision, inheriting the content of the given SlotRecord of a previous revision. It creates a prototype which is intended to be used with newSaved().
  • newUnsaved( string $role, Content $content, bool $derived ) - constructs a new SlotRecord from a Content object for a new revision. If Content was stored because of a user edit, this is preferred way of constructing a SlotRecord. Again, it creates a prototype which is intended to be used with newSaved().
  • newSaved( int $revisionId, ?int $contentId, string $contentAddress, SlotRecord $protoSlot ) - constructs a complete SlotRecord for a newly saved revision, based on the incomplete prototype SlotRecord. This adds information that has only become available during saving, particularly the revision ID, content ID and content address.

Dynamic getters

[edit]
  • getContent() - returns the Content of the given SlotRecord.
  • getRevision() - returns the ID of the Revision this slot is associated with.
  • getOrigin() - returns revision ID of the revision that originated the slot's content.
  • getRole()
  • getAddress()
  • getContentId()
  • getSize() - get content size.
  • getSha1()()
  • getModel() - returns the name of the content model. This is the model name that decides which ContentHandler is appropriate for interpreting the data of the blob referenced by the address returned by getAddress().
  • getFormat() - returns the blob serialization format as a MIME type; or else null so that it is up to the caller to auto-detect the serialization format, or to rely on the default format associated with the content model.

Dynamic checks

[edit]
  • isInherited() - whether this slot was inherited from an older revision (bool). Returns true if this SlotRecord is already attached to a revision and if the slot's revision of origin is the same as the revision it belongs to. Also returns true if the slot already has an address and this SlotRecord is not yet attached to a revision.
  • hasAddress() - whether this slot has an address (bool). Slots will have an address if their content has been stored. While building a new revision, SlotRecords will not have an address associated.
  • hasOrigin() - whether this SlotRecord has an origin, i.e. a revision ID that originated the slot's content.
  • hasContentId() - whether this SlotRecord has a content ID associated with it. SlotRecords will have a content ID if their content has been stored in the content table. While building a new revision, SlotRecords will not have an ID associated.
  • hasRevision() - whether this SlotRecord has a revision ID associated with it. SlotRecords will have a revision ID associated only if they were loaded as part of an existing revision. While building a new revision, SlotRecords will not have a revision ID associated.
  • hasSameContent( SlotRecord $other ) - returns true if $other has the same content as this slot.
  • isDerived() - whether this is a derived slot (bool).

Other

[edit]
  • base36Sha1( $blob ) - get the base 36 SHA-1 value for a string of text.