public function lock($absPath, $isDeep, $isSessionScoped, $timeoutHint = PHP_INT_MAX, $ownerInfo = null)
{
if (!$isSessionScoped) {
throw new NotImplementedException("Global scoped locks are not yet implemented in Jackalope. If you create such a lock you might not be able to remove it afterward. For now we deactivated this feature.");
}
// If the node does not exist, Jackrabbit will return an HTTP 412 error which is
// the same as if the node was not assigned the 'mix:lockable' mixin. To avoid
// problems in determining which of those error it would be, it's easier to detect
// non-existing nodes earlier.
if (!$this->session->nodeExists($absPath)) {
throw new PathNotFoundException("Unable to lock unexisting node '{$absPath}'");
}
$node = $this->session->getNode($absPath);
$state = $node->getState();
if ($state === Item::STATE_NEW || $state === Item::STATE_MODIFIED) {
throw new InvalidItemStateException("Cannot lock the non-clean node '{$absPath}': current state = {$state}");
}
$lock = $this->transport->lockNode($absPath, $isDeep, $isSessionScoped, $timeoutHint, $ownerInfo);
$lock->setLockManager($this);
// Store the lock for further use
$this->locks[$absPath] = $lock;
return $lock;
}