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

Public Member Functions

 __construct (private Factory $entity_factory)
 
 getContainerKey ()
 
 isForced ()
 
 getLocks ($uri, $returnChildLocks)
 
 lock ($uri, LockInfo $lockInfo)
 
 unlock ($uri, LockInfo $lockInfo)
 
 getContainerKey ()
 
 isForced ()
 

Private Member Functions

 key (string $uri)
 
 asArray (LockInfo $lockInfo)
 
 asLockInfo (array $item)
 

Private Attributes

Container $cache
 
Transformation $raw
 

Detailed Description

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

Definition at line 36 of file CacheBackend.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\WebDAV\Lock\CacheBackend::__construct ( private Factory  $entity_factory)

Definition at line 42 of file CacheBackend.php.

44 {
45 global $DIC;
46 $this->cache = $DIC->globalCache()->get($this);
47 $this->cache->flush();
48 $this->raw = new class () implements Transformation {
49 use DeriveApplyToFromTransform;
50 use DeriveInvokeFromTransform;
51
52 public function transform($from)
53 {
54 return $from;
55 }
56
57 };
58 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\raw(), and ILIAS\Refinery\transform().

+ Here is the call graph for this function:

Member Function Documentation

◆ asArray()

ILIAS\WebDAV\Lock\CacheBackend::asArray ( LockInfo  $lockInfo)
private

Definition at line 94 of file CacheBackend.php.

94 : array
95 {
96 return [
97 'owner' => $lockInfo->owner,
98 'token' => $lockInfo->token,
99 'scope' => $lockInfo->scope,
100 'depth' => $lockInfo->depth,
101 'timeout' => $lockInfo->timeout,
102 'uri' => $lockInfo->uri,
103 'created' => $lockInfo->created,
104 ];
105 }

Referenced by ILIAS\WebDAV\Lock\CacheBackend\lock().

+ Here is the caller graph for this function:

◆ asLockInfo()

ILIAS\WebDAV\Lock\CacheBackend::asLockInfo ( array  $item)
private

Definition at line 107 of file CacheBackend.php.

107 : LockInfo
108 {
109 $lock = new LockInfo();
110 $lock->owner = $item['owner'];
111 $lock->token = $item['token'];
112 $lock->scope = $item['scope'];
113 $lock->depth = $item['depth'];
114 $lock->timeout = $item['timeout'];
115 $lock->uri = $item['uri'];
116 $lock->created = $item['created'];
117
118 return $lock;
119 }

Referenced by ILIAS\WebDAV\Lock\CacheBackend\getLocks().

+ Here is the caller graph for this function:

◆ getContainerKey()

ILIAS\WebDAV\Lock\CacheBackend::getContainerKey ( )

Implements ILIAS\Cache\Container\Request.

Definition at line 60 of file CacheBackend.php.

60 : string
61 {
62 return 'webdav:locks';
63 }

◆ getLocks()

ILIAS\WebDAV\Lock\CacheBackend::getLocks (   $uri,
  $returnChildLocks 
)

Definition at line 75 of file CacheBackend.php.

75 : array
76 {
77 $key = $this->key($uri);
78 if ($key === null) {
79 return [];
80 }
81
82 if (!$this->cache->has($key)) {
83 return [];
84 }
85
86 $locks = [];
87 foreach ($this->cache->get($key, $this->raw) as $item) {
88 $locks[] = $this->asLockInfo($item);
89 }
90
91 return $locks;
92 }

References ILIAS\WebDAV\Lock\CacheBackend\asLockInfo(), and ILIAS\WebDAV\Lock\CacheBackend\key().

+ Here is the call graph for this function:

◆ isForced()

ILIAS\WebDAV\Lock\CacheBackend::isForced ( )

Implements ILIAS\Cache\Container\Request.

Definition at line 65 of file CacheBackend.php.

65 : bool
66 {
67 return true;
68 }

◆ key()

ILIAS\WebDAV\Lock\CacheBackend::key ( string  $uri)
private

Definition at line 70 of file CacheBackend.php.

70 : string
71 {
72 return 'locks:' . md5($uri);
73 }

Referenced by ILIAS\WebDAV\Lock\CacheBackend\getLocks(), ILIAS\WebDAV\Lock\CacheBackend\lock(), and ILIAS\WebDAV\Lock\CacheBackend\unlock().

+ Here is the caller graph for this function:

◆ lock()

ILIAS\WebDAV\Lock\CacheBackend::lock (   $uri,
LockInfo  $lockInfo 
)

Definition at line 121 of file CacheBackend.php.

121 : bool
122 {
123 $key = $this->key($uri);
124
125 $locks = $this->cache->get($key, $this->raw) ?? [];
126
127 $lock = new LockInfo();
128 $lock->owner = $lockInfo->owner;
129 $lock->token = $lockInfo->token;
130 $lock->scope = LockInfo::EXCLUSIVE;
131 $lock->depth = $lockInfo->depth;
132 $lock->timeout = $lockInfo->timeout;
133 $lock->uri = $uri;
134 $lock->created = $lockInfo->created ?? time();
135
136 $locks[] = $this->asArray($lock);
137
138 $this->cache->set($key, $locks);
139
140 return true;
141 }
asArray(LockInfo $lockInfo)

References ILIAS\WebDAV\Lock\CacheBackend\asArray(), ILIAS\WebDAV\Lock\CacheBackend\key(), and ILIAS\Repository\raw().

+ Here is the call graph for this function:

◆ unlock()

ILIAS\WebDAV\Lock\CacheBackend::unlock (   $uri,
LockInfo  $lockInfo 
)

Definition at line 143 of file CacheBackend.php.

143 : bool
144 {
145 $key = $this->key($uri);
146 if ($key === null) {
147 return false;
148 }
149 $this->cache->set($key, []);
150
151 $entity = $this->entity_factory->getByFullPath($uri);
152 $proxy = $entity?->getObjectProxy();
153 if ($proxy !== null && $proxy->getType() === Type::FILE) {
154 $proxy->getStreamHandler()->publish();
155 }
156
157 return true;
158 }

References ILIAS\WebDAV\Lock\CacheBackend\key().

+ Here is the call graph for this function:

Field Documentation

◆ $cache

Container ILIAS\WebDAV\Lock\CacheBackend::$cache
private

Definition at line 38 of file CacheBackend.php.

◆ $raw

Transformation ILIAS\WebDAV\Lock\CacheBackend::$raw
private

Definition at line 40 of file CacheBackend.php.


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