Skip to content

Commit 5e4abd7

Browse files
authored
Merge pull request #59984 from nextcloud/jtr/docs-lock-ILockManager-API
docs(lock): clarify ILockManager API documentation
2 parents 421e4de + cb39b95 commit 5e4abd7

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

lib/private/Files/Lock/LockManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class LockManager implements ILockManager {
2323

2424
#[\Override]
2525
public function registerLockProvider(ILockProvider $lockProvider): void {
26-
if ($this->lockProvider) {
26+
if ($this->lockProvider || $this->lockProviderClass) {
2727
throw new PreConditionNotMetException('There is already a registered lock provider');
2828
}
2929

lib/public/Files/Lock/ILockManager.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,56 @@
1212
use OCP\PreConditionNotMetException;
1313

1414
/**
15-
* Manage app integrations with files_lock with collaborative editors
15+
* Manage app integrations with the files_lock app and collaborative editors.
1616
*
17-
* The OCP parts are mainly for exposing the ability to lock/unlock for apps and
18-
* to give the files_lock app a way to register and then be triggered by the apps
19-
* while the actual locking implementation is kept in the LockProvider and DAV
20-
* plugin from files_lock app.
17+
* This public API exposes locking operations to apps and allows a lock provider
18+
* from files_lock to be registered. The actual locking implementation remains
19+
* in the provider and the DAV plugin of the files_lock app.
2120
*
2221
* @since 24.0.0
2322
*/
2423
interface ILockManager extends ILockProvider {
2524
/**
26-
* @throws PreConditionNotMetException if there is already a lock provider registered
25+
* Register the lock provider implementation.
26+
*
27+
* @throws PreConditionNotMetException if a lock provider is already registered
2728
* @since 24.0.0
2829
* @deprecated 30.0.0 Use registerLazyLockProvider
2930
*/
3031
public function registerLockProvider(ILockProvider $lockProvider): void;
3132

3233
/**
33-
* @param string $lockProviderClass
34-
* @return void
34+
* Register a lock provider class for lazy resolution from the server container.
35+
*
36+
* @throws PreConditionNotMetException if a lock provider is already registered
3537
* @since 30.0.0
3638
*/
3739
public function registerLazyLockProvider(string $lockProviderClass): void;
3840

3941
/**
40-
* @return bool
42+
* Check whether a lock provider is currently available.
43+
*
44+
* If a provider class was registered lazily, this may attempt to resolve it.
45+
*
4146
* @since 24.0.0
4247
*/
4348
public function isLockProviderAvailable(): bool;
4449

4550
/**
46-
* Run within the scope of a given lock condition
51+
* Run a callback within the scope of the given lock context.
4752
*
48-
* The callback will also be executed if no lock provider is present
53+
* The callback is also executed if no lock provider is available.
4954
*
55+
* @throws PreConditionNotMetException if another lock scope is already active
5056
* @since 24.0.0
5157
*/
5258
public function runInScope(LockContext $lock, callable $callback): void;
5359

5460
/**
55-
* @throws NoLockProviderException if there is no lock provider available
61+
* Get the lock context currently active in this scope.
62+
*
63+
* Returns null if no lock scope is active.
64+
*
5665
* @since 24.0.0
5766
*/
5867
public function getLockInScope(): ?LockContext;

0 commit comments

Comments
 (0)