MediaWiki  master
MediaWiki\Revision\RevisionSlots Class Reference

Value object representing the set of slots belonging to a revision. More...

Inheritance diagram for MediaWiki\Revision\RevisionSlots:
Collaboration diagram for MediaWiki\Revision\RevisionSlots:

Public Member Functions

 __construct ( $slots)
 
 computeSha1 ()
 Computes the combined hash of the revisions's slots. More...
 
 computeSize ()
 Computes the total nominal size of the revision's slots, in bogo-bytes. More...
 
 getContent ( $role)
 Returns the Content of the given slot. More...
 
 getInheritedSlots ()
 Return all slots that are not originate in the revision they belong to (that is, they are inherited from some other revision). More...
 
 getOriginalSlots ()
 Return all slots that belong to the revision they originate from (that is, they are not inherited from some other revision). More...
 
 getPrimarySlots ()
 Return all primary slots (those that are not derived). More...
 
 getRolesWithDifferentContent (RevisionSlots $other)
 Find roles for which the $other RevisionSlots object has different content as this RevisionSlots object, including any roles that are present in one but not the other. More...
 
 getSlot ( $role)
 Returns the SlotRecord of the given slot. More...
 
 getSlotRoles ()
 Returns the slot names (roles) of all slots present in this revision. More...
 
 getSlots ()
 Returns an associative array that maps role names to SlotRecords. More...
 
 hasSameContent (RevisionSlots $other)
 Checks whether the other RevisionSlots instance has the same content as this instance. More...
 
 hasSlot ( $role)
 Returns whether the given slot is set. More...
 

Protected Attributes

SlotRecord[] callable $slots
 

Private Member Functions

 setSlotsInternal (array $slots)
 

Detailed Description

Value object representing the set of slots belonging to a revision.

Note
RevisionSlots provides "raw" access to the slots and does not apply audience checks. If audience checks are desired, use RevisionRecord::getSlot() or RevisionRecord::getContent() instead.

@newable

Since
1.31
1.32 Renamed from MediaWiki\Storage\RevisionSlots

Definition at line 41 of file RevisionSlots.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Revision\RevisionSlots::__construct (   $slots)
Stability: stable
to call.
Parameters
SlotRecord[] | callable$slotsSlotRecords, or a callback that returns such a structure.

Definition at line 53 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\$slots, and MediaWiki\Revision\RevisionSlots\setSlotsInternal().

Member Function Documentation

◆ computeSha1()

MediaWiki\Revision\RevisionSlots::computeSha1 ( )

Computes the combined hash of the revisions's slots.

Note
For backwards compatibility, the combined hash of a single slot is that slot's hash. For consistency, the combined hash of an empty set of slots is the hash of the empty string.
Warning
This is potentially expensive! It may cause some slots' content to be loaded and deserialized, then re-serialized and hashed.
Returns
string

Definition at line 195 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\$slots, MediaWiki\Revision\SlotRecord\base36Sha1(), MediaWiki\Revision\RevisionSlots\getPrimarySlots(), and MediaWiki\Revision\SlotRecord\getSha1().

◆ computeSize()

MediaWiki\Revision\RevisionSlots::computeSize ( )

Computes the total nominal size of the revision's slots, in bogo-bytes.

Warning
This is potentially expensive! It may cause some slots' content to be loaded and deserialized.
Returns
int

Definition at line 153 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\getPrimarySlots(), and MediaWiki\Revision\SlotRecord\getSize().

◆ getContent()

MediaWiki\Revision\RevisionSlots::getContent (   $role)

Returns the Content of the given slot.

Call getSlotNames() to get a list of available slots.

Note that for mutable Content objects, each call to this method will return a fresh clone.

See also
SlotRecord::getContent()
Parameters
string$roleThe role name of the desired slot
Exceptions
RevisionAccessExceptionif the slot does not exist or slot data could not be lazy-loaded. See SlotRecord::getContent() for details.
Returns
Content

Definition at line 93 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\getSlot().

◆ getInheritedSlots()

MediaWiki\Revision\RevisionSlots::getInheritedSlots ( )

Return all slots that are not originate in the revision they belong to (that is, they are inherited from some other revision).

Note
This may cause the slot meta-data for the revision to be lazy-loaded.
Returns
SlotRecord[]

Definition at line 235 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\getSlots(), and MediaWiki\Revision\SlotRecord\isInherited().

◆ getOriginalSlots()

MediaWiki\Revision\RevisionSlots::getOriginalSlots ( )

Return all slots that belong to the revision they originate from (that is, they are not inherited from some other revision).

Note
This may cause the slot meta-data for the revision to be lazy-loaded.
Returns
SlotRecord[]

Definition at line 218 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\getSlots(), and MediaWiki\Revision\SlotRecord\isInherited().

◆ getPrimarySlots()

MediaWiki\Revision\RevisionSlots::getPrimarySlots ( )

Return all primary slots (those that are not derived).

Returns
SlotRecord[]
Since
1.36

Definition at line 250 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\getSlots(), and MediaWiki\Revision\SlotRecord\isDerived().

Referenced by MediaWiki\Revision\RevisionSlots\computeSha1(), and MediaWiki\Revision\RevisionSlots\computeSize().

◆ getRolesWithDifferentContent()

MediaWiki\Revision\RevisionSlots::getRolesWithDifferentContent ( RevisionSlots  $other)

Find roles for which the $other RevisionSlots object has different content as this RevisionSlots object, including any roles that are present in one but not the other.

Parameters
RevisionSlots$other
Returns
string[] a list of slot roles that are different.

Definition at line 303 of file RevisionSlots.php.

References $s, $t, and MediaWiki\Revision\RevisionSlots\getSlots().

◆ getSlot()

MediaWiki\Revision\RevisionSlots::getSlot (   $role)

Returns the SlotRecord of the given slot.

Call getSlotNames() to get a list of available slots.

Parameters
string$roleThe role name of the desired slot
Exceptions
RevisionAccessExceptionif the slot does not exist or slot data could not be lazy-loaded.
Returns
SlotRecord

Definition at line 108 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\$slots, and MediaWiki\Revision\RevisionSlots\getSlots().

Referenced by MediaWiki\Revision\RevisionSlots\getContent().

◆ getSlotRoles()

MediaWiki\Revision\RevisionSlots::getSlotRoles ( )

Returns the slot names (roles) of all slots present in this revision.

getContent() will succeed only for the names returned by this method.

Returns
string[]

Definition at line 140 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\$slots, and MediaWiki\Revision\RevisionSlots\getSlots().

◆ getSlots()

◆ hasSameContent()

MediaWiki\Revision\RevisionSlots::hasSameContent ( RevisionSlots  $other)

Checks whether the other RevisionSlots instance has the same content as this instance.

Note that this does not mean that the slots have to be the same: they could for instance belong to different revisions.

Parameters
RevisionSlots$other
Returns
bool

Definition at line 268 of file RevisionSlots.php.

References $s, $t, and MediaWiki\Revision\RevisionSlots\getSlots().

◆ hasSlot()

MediaWiki\Revision\RevisionSlots::hasSlot (   $role)

Returns whether the given slot is set.

Parameters
string$roleThe role name of the desired slot
Returns
bool

Definition at line 128 of file RevisionSlots.php.

References MediaWiki\Revision\RevisionSlots\$slots, and MediaWiki\Revision\RevisionSlots\getSlots().

◆ setSlotsInternal()

MediaWiki\Revision\RevisionSlots::setSlotsInternal ( array  $slots)
private

Member Data Documentation

◆ $slots


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