PHP Class VersionPress\Utils\EntityUtils

Exibir arquivo Open project: versionpress/versionpress Class Usage Examples

Public Methods

Method Description
getDiff ( array $oldEntityData, array $newEntityData ) : array Used by storages to determine a diff between two entity data. Note that the data might not be complet - for example, the $oldEntityData might be the previous, full state of the entity while the $newEntityData is just the change that was captured by VersionPress.

Private Methods

Method Description
isChanged ( $oldData, $newValue ) : boolean Evaluates if there is difference between old and new value.

Method Details

getDiff() public static method

Or the $newEntityData might be another full entity, for example in its new state. It doesn't really matter, the algo is always the same: it scans for new keys in $newEntityData and changed values on existing keys and adds those two things to the result. 'vp_id' key is ignored by default. Note: keys may never be "removed" (or marked as removed) in the diff because that will just not ever happen - the SQL UPDATE command is only capable of sending a change, clearing a key value at most but never "removing" it entirely.
public static getDiff ( array $oldEntityData, array $newEntityData ) : array
$oldEntityData array Usually a full entity data in its original state
$newEntityData array Full or partial data of the new entity
return array Key=>value pairs of things that are new or changed in $newEntity (they can never be "removed", that will never happen when capturing SQL UPDATE actions)