acquire() public method

Acquire the lock on the object
public acquire ( ) : object
return object the reloaded object
Example #1
0
 /**
  * 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
  */
 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;
 }