Horde_Lock::setLock PHP Method

setLock() abstract public method

Sets a lock on the requested principal and returns the generated lock ID. NOTE: No security checks are done in the Horde_Lock API. It is expected that the calling application has done all necessary security checks before requesting a lock be granted.
abstract public setLock ( string $requestor, string $scope, string $principal, integer $lifetime = 1, $exclusive = Horde_Lock::TYPE_SHARED ) : mixed
$requestor string User ID of the lock requestor.
$scope string The scope of the lock. Typically the name of the application requesting the lock or some other identifier used to group locks together.
$principal string A principal on which a lock should be granted. The format can be any string but is suggested to be in URI form.
$lifetime integer Time (in seconds) for which the lock will be considered valid.
return mixed A string lock ID.
    public abstract function setLock($requestor, $scope, $principal, $lifetime = 1, $exclusive = Horde_Lock::TYPE_SHARED);

Usage Example

Example #1
0
 /**
  * @throws Wicked_Exception
  */
 public function lock()
 {
     if ($this->_locks) {
         $id = $this->_locks->setLock(Wicked::lockUser(), 'wicked', $this->pageName(), $GLOBALS['conf']['wicked']['lock']['time'] * 60, Horde_Lock::TYPE_EXCLUSIVE);
         if ($id) {
             $this->_lock = $this->_locks->getLockInfo($id);
         } else {
             throw new Wicked_Exception(_("The page is already locked."));
         }
     }
 }
All Usage Examples Of Horde_Lock::setLock