save() abstract public method

Saves data to a storage
abstract public save ( array $data ) : VersionPress\ChangeInfos\ChangeInfo | null
$data array Associative array with values to save. On `insert`, the $data will contain full entity data plus things like VPID. On further updates, the data will typically contain just the updated values and a VPID (assigned in {@link VersionPress\Database\WpdbMirrorBridge} so that the appropriate file could be located).
return VersionPress\ChangeInfos\ChangeInfo | null Null indicates that the save operation didn't really change anything (may happen). Otherwise, the ChangeInfo object is returned.
 public function delete($restriction)
 {
     $parentVpId = $restriction[$this->parentReferenceName];
     $parent = $this->parentStorage->loadEntity($parentVpId, null);
     $fieldToDelete = $this->getJoinedKeyByVpId($parent, $restriction['vp_id']);
     $oldEntity = $this->extractEntityFromParentByVpId($parent, $restriction['vp_id']);
     $oldParentEntity = $parent;
     $parent[$fieldToDelete] = false;
     // mark for deletion
     $newParentEntity = $parent;
     $this->parentStorage->save($parent);
     return $this->createChangeInfoWithParentEntity($oldEntity, $oldEntity, $oldParentEntity, $newParentEntity, 'delete');
 }
示例#2
0
 private function saveStandardEntities(Storage $storage, $entities)
 {
     foreach ($entities as $entity) {
         $storage->save($entity);
         $this->checkTimeout();
     }
 }