Pheasant\DomainObject::lock PHP Method

lock() public method

Creates a concurrency lock on the domain object, with an optional closure to execute if the object has changed in the db when the lock finally provided. Closure gets the original and the new object
public lock ( $onChanged = null )
    public function lock($onChanged = null)
    {
        $lock = new Locking\PessimisticLock($this);
        $locked = $lock->acquire();
        if (is_callable($onChanged) && !$locked->equals($this)) {
            call_user_func($onChanged, $this, $locked);
        }
        // reload data from locked
        $this->_data = $locked->_data;
        return $this;
    }