MatthiasMullie\Scrapbook\Buffered\Utils\Defer::commit PHP Method

commit() public method

When the commit fails, no changes in this transaction will be applied (and those that had already been applied will be undone). False will be returned in that case.
public commit ( ) : boolean
return boolean
    public function commit()
    {
        list($old, $new) = $this->generateRollback();
        $updates = $this->generateUpdates();
        $updates = $this->combineUpdates($updates);
        usort($updates, array($this, 'sortUpdates'));
        foreach ($updates as $update) {
            // apply update to cache & receive a simple bool to indicate
            // success (true) or failure (false)
            $success = call_user_func_array($update[1], $update[2]);
            if ($success === false) {
                $this->rollback($old, $new);
                return false;
            }
        }
        $this->clear();
        return true;
    }

Usage Example

示例#1
0
 /**
  * Commits all deferred updates to real cache.
  * that had already been written to will be deleted.
  *
  * @return bool
  */
 public function commit()
 {
     $this->clear();
     return $this->defer->commit();
 }