MediaWiki REL1_34
|
Value object representing a modification of revision slots. More...
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. | |
Value object representing a modification of revision slots.
Definition at line 36 of file RevisionSlotsUpdate.php.
MediaWiki\Storage\RevisionSlotsUpdate::__construct | ( | array | $modifiedSlots = [] , |
array | $removedRoles = [] |
||
) |
SlotRecord[] | $modifiedSlots | |
string[] | $removedRoles |
Definition at line 116 of file RevisionSlotsUpdate.php.
References MediaWiki\Storage\RevisionSlotsUpdate\$modifiedSlots, MediaWiki\Storage\RevisionSlotsUpdate\$removedRoles, MediaWiki\Storage\RevisionSlotsUpdate\modifySlot(), and MediaWiki\Storage\RevisionSlotsUpdate\removeSlot().
MediaWiki\Storage\RevisionSlotsUpdate::apply | ( | MutableRevisionSlots | $slots | ) |
Applies this update to the given MutableRevisionSlots, setting all modified slots, and removing all removed roles.
MutableRevisionSlots | $slots |
Definition at line 290 of file RevisionSlotsUpdate.php.
References MediaWiki\Storage\RevisionSlotsUpdate\getModifiedRoles(), MediaWiki\Storage\RevisionSlotsUpdate\getModifiedSlot(), MediaWiki\Storage\RevisionSlotsUpdate\getRemovedRoles(), MediaWiki\Revision\MutableRevisionSlots\removeSlot(), and MediaWiki\Revision\MutableRevisionSlots\setSlot().
Referenced by MediaWiki\Revision\MutableRevisionRecord\applyUpdate().
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.
Definition at line 137 of file RevisionSlotsUpdate.php.
Referenced by MediaWiki\Storage\RevisionSlotsUpdate\apply(), MediaWiki\Storage\RevisionSlotsUpdate\getTouchedRoles(), MediaWiki\Storage\RevisionSlotsUpdate\hasSameUpdates(), and MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().
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).
string | $role | The role name of the desired slot |
RevisionAccessException | if the slot does not exist or was removed. |
Definition at line 217 of file RevisionSlotsUpdate.php.
Referenced by MediaWiki\Storage\RevisionSlotsUpdate\apply(), MediaWiki\Storage\DerivedPageDataUpdater\getPreparedEdit(), MediaWiki\Storage\RevisionSlotsUpdate\hasSameUpdates(), and MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().
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().
Definition at line 147 of file RevisionSlotsUpdate.php.
Referenced by MediaWiki\Storage\RevisionSlotsUpdate\apply(), MediaWiki\Storage\RevisionSlotsUpdate\getTouchedRoles(), MediaWiki\Storage\RevisionSlotsUpdate\hasSameUpdates(), and MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().
MediaWiki\Storage\RevisionSlotsUpdate::getTouchedRoles | ( | ) |
Returns a list of all slot roles that modified or removed.
Definition at line 156 of file RevisionSlotsUpdate.php.
References MediaWiki\Storage\RevisionSlotsUpdate\getModifiedRoles(), and MediaWiki\Storage\RevisionSlotsUpdate\getRemovedRoles().
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.
RevisionSlotsUpdate | $other |
Definition at line 261 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().
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.
string | $role | The role name of the desired slot |
Definition at line 234 of file RevisionSlotsUpdate.php.
Referenced by MediaWiki\Storage\DerivedPageDataUpdater\getPreparedEdit(), and MediaWiki\Storage\DerivedPageDataUpdater\prepareContent().
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.
string | $role | The role name of the desired slot |
Definition at line 247 of file RevisionSlotsUpdate.php.
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.
string | $role | |
Content | $content |
Definition at line 184 of file RevisionSlotsUpdate.php.
References $content, and MediaWiki\Storage\RevisionSlotsUpdate\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().
SlotRecord | $slot |
Definition at line 169 of file RevisionSlotsUpdate.php.
References MediaWiki\Revision\SlotRecord\getRole().
Referenced by MediaWiki\Storage\RevisionSlotsUpdate\__construct(), and MediaWiki\Storage\RevisionSlotsUpdate\modifyContent().
|
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.
Content[] | $newContent | The new content, using slot roles as array keys. |
Definition at line 92 of file RevisionSlotsUpdate.php.
References $content.
|
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.
RevisionSlots | $newSlots | |
RevisionSlots | null | $parentSlots |
Definition at line 58 of file RevisionSlotsUpdate.php.
References MediaWiki\Revision\RevisionSlots\getSlots().
Referenced by MediaWiki\Storage\DerivedPageDataUpdater\getRevisionSlotsUpdate().
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().
string | $role |
Definition at line 197 of file RevisionSlotsUpdate.php.
Referenced by MediaWiki\Storage\RevisionSlotsUpdate\__construct().
|
private |
modified slots, using the slot role as the key.
Definition at line 41 of file RevisionSlotsUpdate.php.
Referenced by MediaWiki\Storage\RevisionSlotsUpdate\__construct().
|
private |
removed roles, stored in the keys of the array.
Definition at line 46 of file RevisionSlotsUpdate.php.
Referenced by MediaWiki\Storage\RevisionSlotsUpdate\__construct().