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;
    }
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;
    }
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 ; }
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
@chainable
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