Horde_Lock::getLocks PHP Method

getLocks() abstract public method

Return a list of valid locks with the option to limit the results by principal, scope and/or type.
abstract public getLocks ( string $scope = null, string $principal = null, integer $type = null ) : array
$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 Principal for which to check for locks
$type integer Only return locks of the given type. Defaults to null, or all locks
return array Array of locks with the ID as the key and the lock details as the value. If there are no current locks this will return an empty array.
    public abstract function getLocks($scope = null, $principal = null, $type = null);

Usage Example

Example #1
0
 /**
  * Returns a list of Sabre\DAV\Locks\LockInfo objects
  *
  * This method should return all the locks for a particular uri, including
  * locks that might be set on a parent uri.
  *
  * If returnChildLocks is set to true, this method should also look for
  * any locks in the subtree of the uri for locks.
  *
  * @param string $uri
  * @param bool $returnChildLocks
  * @return array
  */
 public function getLocks($uri, $returnChildLocks)
 {
     list($app) = explode('/', $uri);
     try {
         // @todo use $returnChildLocks when we implemented sub-tree
         // searching in Horde_Lock
         $locks = $this->_lock->getLocks($app, $uri);
     } catch (Horde_Lock_Exception $e) {
         throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
     }
     $infos = array();
     foreach ($locks as $lock) {
         $info = new Locks\LockInfo();
         $info->owner = $lock['lock_owner'];
         $info->token = $lock['lock_id'];
         $info->timeout = $lock['lock_expiry_timestamp'];
         $info->created = $lock['lock_origin_timestamp'];
         $info->scope = $lock['lock_type'] == Horde_Lock::TYPE_EXCLUSIVE ? Locks\LockInfo::EXCLUSIVE : Locks\LockInfo::SHARED;
         $info->uri = $lock['lock_principal'];
         $infos[] = $info;
     }
     return $infos;
 }
All Usage Examples Of Horde_Lock::getLocks