ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
ILIAS\WebDAV\Lock\Backend Class Reference
+ Inheritance diagram for ILIAS\WebDAV\Lock\Backend:
+ Collaboration diagram for ILIAS\WebDAV\Lock\Backend:

Public Member Functions

 __construct (private Factory $entity_factory, private LocksRepository $locks_repository)
 
 getLocks ($uri, $returnChildLocks)
 
 lock ($uri, LockInfo $lock_info)
 
 unlock ($uri, LockInfo $lock_info)
 

Private Attributes

int $user_id
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 31 of file Backend.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\WebDAV\Lock\Backend::__construct ( private Factory  $entity_factory,
private LocksRepository  $locks_repository 
)

Definition at line 35 of file Backend.php.

38 {
39 global $DIC; // TODO remove Service Locator
40 $this->user_id = $DIC->user()->getId();
41 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Member Function Documentation

◆ getLocks()

ILIAS\WebDAV\Lock\Backend::getLocks (   $uri,
  $returnChildLocks 
)
Returns
LockInfo[]

Definition at line 46 of file Backend.php.

46 : array
47 {
48 $entity = $this->entity_factory->getByFullPath($uri);
49 if ($entity === null) {
50 return [];
51 }
52
53 $lock_object = $this->locks_repository->maybeGetLockFromObjId($entity->getObjectProxy()->getObjId());
54 if ($lock_object === null) {
55 return [];
56 }
57
58 return [
59 $lock_object->getAsSabreDavLock($uri),
60 ];
61 }

◆ lock()

ILIAS\WebDAV\Lock\Backend::lock (   $uri,
LockInfo  $lock_info 
)

Definition at line 63 of file Backend.php.

63 : bool
64 {
65 $entity = $this->entity_factory->getByFullPath($uri);
66 $obj_id = $entity?->getObjectProxy()->getObjId();
67 if ($obj_id === null) {
68 return false;
69 }
70
71 $ilias_lock = new Lock(
72 $lock_info->token,
73 $obj_id,
74 $this->user_id,
75 $lock_info->owner,
76 time() + 3600,
77 $lock_info->depth,
78 'w',
79 $lock_info->scope
80 );
81 $this->locks_repository->save($ilias_lock);
82
83 $proxy = $entity?->getObjectProxy();
84 if ($proxy !== null && $proxy->getType() === Type::FILE) {
85 $proxy->getStreamHandler()?->publish();
86 }
87 return true;
88 }

◆ unlock()

ILIAS\WebDAV\Lock\Backend::unlock (   $uri,
LockInfo  $lock_info 
)

Definition at line 90 of file Backend.php.

90 : bool
91 {
92 $ilias_lock = $this->locks_repository->maybeGetLockFromToken($lock_info->token);
93
94 if ($ilias_lock !== null && $ilias_lock->getIliasOwner() === $this->user_id) {
95 $this->locks_repository->remove($lock_info->token);
96 return true;
97 }
98 return false;
99 }

Field Documentation

◆ $user_id

int ILIAS\WebDAV\Lock\Backend::$user_id
private

Definition at line 33 of file Backend.php.


The documentation for this class was generated from the following file: