MediaWiki  master
Revision\MutableRevisionSlots Class Reference

Mutable version of RevisionSlots, for constructing a new revision. More...

Inheritance diagram for Revision\MutableRevisionSlots:
Collaboration diagram for Revision\MutableRevisionSlots:

Public Member Functions

 __construct (array $slots=[], ?callable $resetCallback=null)
 
 inheritSlot (SlotRecord $slot)
 Sets the given slot to an inherited version of $slot. More...
 
 removeSlot ( $role)
 Remove the slot for the given role, discontinue the corresponding stream. More...
 
 setContent ( $role, Content $content)
 Sets the content for the slot with the given role. More...
 
 setSlot (SlotRecord $slot)
 Sets the given slot. More...
 
- Public Member Functions inherited from Revision\RevisionSlots
 __construct ( $slots)
 Stable to call. More...
 
 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...
 
 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...
 

Static Public Member Functions

static newFromParentRevisionSlots (array $slots, ?callable $resetCallback=null)
 Constructs a MutableRevisionSlots that inherits from the given list of slots. More...
 

Private Member Functions

 triggerResetCallback ()
 Trigger the reset callback supplied to the constructor, if any. More...
 

Private Attributes

callable null $resetCallback
 

Additional Inherited Members

- Protected Attributes inherited from Revision\RevisionSlots
SlotRecord[] callable $slots
 

Detailed Description

Mutable version of RevisionSlots, for constructing a new revision.

Since
1.31
1.32 Renamed from MediaWiki\Storage\MutableRevisionSlots

Definition at line 33 of file MutableRevisionSlots.php.

Constructor & Destructor Documentation

◆ __construct()

Revision\MutableRevisionSlots::__construct ( array  $slots = [],
?callable  $resetCallback = null 
)
Parameters
SlotRecord[]$slotsAn array of SlotRecords.
callable | null$resetCallbackCallback to be triggered whenever slots change. Signature: function ( MutableRevisionSlots ): void.

Definition at line 67 of file MutableRevisionSlots.php.

References Revision\MutableRevisionSlots\$resetCallback, and Revision\RevisionSlots\$slots.

Member Function Documentation

◆ inheritSlot()

Revision\MutableRevisionSlots::inheritSlot ( SlotRecord  $slot)

Sets the given slot to an inherited version of $slot.

If a slot with the same role is already present, it is replaced.

Parameters
SlotRecord$slot

Definition at line 95 of file MutableRevisionSlots.php.

References Revision\SlotRecord\newInherited(), and Revision\MutableRevisionSlots\setSlot().

◆ newFromParentRevisionSlots()

static Revision\MutableRevisionSlots::newFromParentRevisionSlots ( array  $slots,
?callable  $resetCallback = null 
)
static

Constructs a MutableRevisionSlots that inherits from the given list of slots.

Parameters
SlotRecord[]$slots
callable | null$resetCallbackCallback to be triggered whenever slots change. Signature: function ( MutableRevisionSlots ): void.
Returns
MutableRevisionSlots

Definition at line 49 of file MutableRevisionSlots.php.

References Revision\MutableRevisionSlots\$resetCallback, Revision\RevisionSlots\$slots, and Revision\SlotRecord\newInherited().

◆ removeSlot()

Revision\MutableRevisionSlots::removeSlot (   $role)

Remove the slot for the given role, discontinue the corresponding stream.

Parameters
string$role

Definition at line 116 of file MutableRevisionSlots.php.

References Revision\RevisionSlots\getSlots(), and Revision\MutableRevisionSlots\triggerResetCallback().

Referenced by MediaWiki\Storage\RevisionSlotsUpdate\apply().

◆ setContent()

Revision\MutableRevisionSlots::setContent (   $role,
Content  $content 
)

Sets the content for the slot with the given role.

If a slot with the same role is already present, it is replaced.

Parameters
string$role
Content$content

Definition at line 106 of file MutableRevisionSlots.php.

References $content, Revision\SlotRecord\newUnsaved(), and Revision\MutableRevisionSlots\setSlot().

◆ setSlot()

Revision\MutableRevisionSlots::setSlot ( SlotRecord  $slot)

◆ triggerResetCallback()

Revision\MutableRevisionSlots::triggerResetCallback ( )
private

Trigger the reset callback supplied to the constructor, if any.

Definition at line 128 of file MutableRevisionSlots.php.

References Revision\MutableRevisionSlots\$resetCallback.

Referenced by Revision\MutableRevisionSlots\removeSlot(), and Revision\MutableRevisionSlots\setSlot().

Member Data Documentation

◆ $resetCallback

callable null Revision\MutableRevisionSlots::$resetCallback
private

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