MediaWiki REL1_35
MediaWiki\Storage\RevisionSlotsUpdate Class Reference

Value object representing a modification of revision slots. More...

Collaboration diagram for MediaWiki\Storage\RevisionSlotsUpdate:

Public Member Functions

 __construct (array $modifiedSlots=[], array $removedRoles=[])
 
 apply (MutableRevisionSlots $slots)
 Applies this update to the given MutableRevisionSlots, setting all modified slots, and removing all removed roles.
 
 getModifiedRoles ()
 Returns a list of modified slot roles, that is, roles modified by calling modifySlot(), and not later removed by calling removeSlot().
 
 getModifiedSlot ( $role)
 Returns the SlotRecord associated with the given role, if the slot with that role was modified (and not again removed).
 
 getRemovedRoles ()
 Returns a list of removed slot roles, that is, roles removed by calling removeSlot(), and not later re-introduced by calling modifySlot().
 
 getTouchedRoles ()
 Returns a list of all slot roles that modified or removed.
 
 hasSameUpdates (RevisionSlotsUpdate $other)
 Returns true if $other represents the same update - that is, if all methods defined by RevisionSlotsUpdate when called on $this or $other will yield the same result when called with the same parameters.
 
 isModifiedSlot ( $role)
 Returns whether getModifiedSlot() will return a SlotRecord for the given role.
 
 isRemovedSlot ( $role)
 Returns whether the given role is to be removed from the page.
 
 modifyContent ( $role, Content $content)
 Sets the content for the slot with the given role to be modified.
 
 modifySlot (SlotRecord $slot)
 Sets the given slot to be modified.
 
 removeSlot ( $role)
 Remove the slot for the given role, discontinue the corresponding stream.
 

Static Public Member Functions

static newFromContent (array $newContent, RevisionSlots $parentSlots=null)
 Constructs a RevisionSlotsUpdate representing the update of $parentSlots when changing $newContent.
 
static newFromRevisionSlots (RevisionSlots $newSlots, RevisionSlots $parentSlots=null)
 Constructs a RevisionSlotsUpdate representing the update that turned $parentSlots into $newSlots.
 

Private Attributes

SlotRecord[] $modifiedSlots = []
 modified slots, using the slot role as the key.
 
bool[] $removedRoles = []
 removed roles, stored in the keys of the array.
 

Detailed Description

Value object representing a modification of revision slots.

Since
1.32

Definition at line 36 of file RevisionSlotsUpdate.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\RevisionSlotsUpdate::__construct ( array  $modifiedSlots = [],
array  $removedRoles = [] 
)

Member Function Documentation

◆ apply()

MediaWiki\Storage\RevisionSlotsUpdate::apply ( MutableRevisionSlots  $slots)

◆ getModifiedRoles()

MediaWiki\Storage\RevisionSlotsUpdate::getModifiedRoles ( )

Returns a list of modified slot roles, that is, roles modified by calling modifySlot(), and not later removed by calling removeSlot().

Note that slots in modified roles may still be inherited slots. This is for instance the case when the RevisionSlotsUpdate objects represents some kind of rollback operation, in which slots that existed in an earlier revision are restored in a new revision.

Returns
string[]

Definition at line 138 of file RevisionSlotsUpdate.php.

Referenced by MediaWiki\Storage\RevisionSlotsUpdate\apply(), MediaWiki\Storage\RevisionSlotsUpdate\getTouchedRoles(), MediaWiki\Storage\RevisionSlotsUpdate\hasSameUpdates(), and MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().

◆ getModifiedSlot()

MediaWiki\Storage\RevisionSlotsUpdate::getModifiedSlot (   $role)

Returns the SlotRecord associated with the given role, if the slot with that role was modified (and not again removed).

Note
If the SlotRecord returned by this method returns a non-inherited slot, the content of that slot may or may not already have PST applied. Methods that take a RevisionSlotsUpdate as a parameter should specify whether they expect PST to already have been applied to all slots. Inherited slots should never have PST applied again.
Parameters
string$roleThe role name of the desired slot
Exceptions
RevisionAccessExceptionif the slot does not exist or was removed.
Returns
SlotRecord

Definition at line 218 of file RevisionSlotsUpdate.php.

Referenced by MediaWiki\Storage\RevisionSlotsUpdate\apply(), MediaWiki\Storage\RevisionSlotsUpdate\hasSameUpdates(), and MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().

◆ getRemovedRoles()

MediaWiki\Storage\RevisionSlotsUpdate::getRemovedRoles ( )

Returns a list of removed slot roles, that is, roles removed by calling removeSlot(), and not later re-introduced by calling modifySlot().

Returns
string[]

Definition at line 148 of file RevisionSlotsUpdate.php.

Referenced by MediaWiki\Storage\RevisionSlotsUpdate\apply(), MediaWiki\Storage\RevisionSlotsUpdate\getTouchedRoles(), MediaWiki\Storage\RevisionSlotsUpdate\hasSameUpdates(), and MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().

◆ getTouchedRoles()

MediaWiki\Storage\RevisionSlotsUpdate::getTouchedRoles ( )

Returns a list of all slot roles that modified or removed.

Returns
string[]

Definition at line 157 of file RevisionSlotsUpdate.php.

References MediaWiki\Storage\RevisionSlotsUpdate\getModifiedRoles(), and MediaWiki\Storage\RevisionSlotsUpdate\getRemovedRoles().

◆ hasSameUpdates()

MediaWiki\Storage\RevisionSlotsUpdate::hasSameUpdates ( RevisionSlotsUpdate  $other)

Returns true if $other represents the same update - that is, if all methods defined by RevisionSlotsUpdate when called on $this or $other will yield the same result when called with the same parameters.

SlotRecords for the same role are compared based on their model and content.

Parameters
RevisionSlotsUpdate$other
Returns
bool

Definition at line 262 of file RevisionSlotsUpdate.php.

References $s, $t, MediaWiki\Storage\RevisionSlotsUpdate\getModifiedRoles(), MediaWiki\Storage\RevisionSlotsUpdate\getModifiedSlot(), and MediaWiki\Storage\RevisionSlotsUpdate\getRemovedRoles().

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\isReusableFor().

◆ isModifiedSlot()

MediaWiki\Storage\RevisionSlotsUpdate::isModifiedSlot (   $role)

Returns whether getModifiedSlot() will return a SlotRecord for the given role.

Will return true for the role names returned by getModifiedRoles(), false otherwise.

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

Definition at line 235 of file RevisionSlotsUpdate.php.

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().

◆ isRemovedSlot()

MediaWiki\Storage\RevisionSlotsUpdate::isRemovedSlot (   $role)

Returns whether the given role is to be removed from the page.

Will return true for the role names returned by getRemovedRoles(), false otherwise.

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

Definition at line 248 of file RevisionSlotsUpdate.php.

◆ modifyContent()

MediaWiki\Storage\RevisionSlotsUpdate::modifyContent (   $role,
Content  $content 
)

Sets the content for the slot with the given role to be modified.

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

Parameters
string$role
Content$content

Definition at line 185 of file RevisionSlotsUpdate.php.

References $content, and MediaWiki\Storage\RevisionSlotsUpdate\modifySlot().

◆ modifySlot()

MediaWiki\Storage\RevisionSlotsUpdate::modifySlot ( SlotRecord  $slot)

Sets the given slot to be modified.

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

The roles used with modifySlot() will be returned from getModifiedRoles(), unless overwritten with removeSlot().

Parameters
SlotRecord$slot

Definition at line 170 of file RevisionSlotsUpdate.php.

References MediaWiki\Revision\SlotRecord\getRole().

Referenced by MediaWiki\Storage\RevisionSlotsUpdate\__construct(), and MediaWiki\Storage\RevisionSlotsUpdate\modifyContent().

◆ newFromContent()

static MediaWiki\Storage\RevisionSlotsUpdate::newFromContent ( array  $newContent,
RevisionSlots  $parentSlots = null 
)
static

Constructs a RevisionSlotsUpdate representing the update of $parentSlots when changing $newContent.

If a slot has the same content in $newContent as in $parentSlots, that slot is considered inherited and thus omitted from the resulting RevisionSlotsUpdate.

In contrast to newFromRevisionSlots(), slots in $parentSlots that are not present in $newContent are not considered removed. They are instead assumed to be inherited.

Parameters
Content[]$newContentThe new content, using slot roles as array keys.
RevisionSlots | null$parentSlots
Returns
RevisionSlotsUpdate

Definition at line 93 of file RevisionSlotsUpdate.php.

References $content.

◆ newFromRevisionSlots()

static MediaWiki\Storage\RevisionSlotsUpdate::newFromRevisionSlots ( RevisionSlots  $newSlots,
RevisionSlots  $parentSlots = null 
)
static

Constructs a RevisionSlotsUpdate representing the update that turned $parentSlots into $newSlots.

If $parentSlots is not given, $newSlots is assumed to come from a page's first revision.

Parameters
RevisionSlots$newSlots
RevisionSlots | null$parentSlots
Returns
RevisionSlotsUpdate

Definition at line 58 of file RevisionSlotsUpdate.php.

References MediaWiki\Revision\RevisionSlots\getSlots().

Referenced by MediaWiki\Storage\DerivedPageDataUpdater\getRevisionSlotsUpdate().

◆ removeSlot()

MediaWiki\Storage\RevisionSlotsUpdate::removeSlot (   $role)

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

The roles used with removeSlot() will be returned from getRemovedSlots(), unless overwritten with modifySlot().

Parameters
string$role

Definition at line 198 of file RevisionSlotsUpdate.php.

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

Member Data Documentation

◆ $modifiedSlots

SlotRecord [] MediaWiki\Storage\RevisionSlotsUpdate::$modifiedSlots = []
private

modified slots, using the slot role as the key.

Definition at line 41 of file RevisionSlotsUpdate.php.

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

◆ $removedRoles

bool [] MediaWiki\Storage\RevisionSlotsUpdate::$removedRoles = []
private

removed roles, stored in the keys of the array.

Definition at line 46 of file RevisionSlotsUpdate.php.

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


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