-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathCapabilities.php
50 lines (44 loc) Β· 1.12 KB
/
Capabilities.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\GroupFolders\AppInfo;
use OCA\GroupFolders\Folder\FolderManager;
use OCP\App\IAppManager;
use OCP\Capabilities\ICapability;
use OCP\IUser;
use OCP\IUserSession;
class Capabilities implements ICapability {
public function __construct(
private readonly IUserSession $userSession,
private readonly FolderManager $folderManager,
private readonly IAppManager $appManager,
) {
}
/**
* @return array{
* groupfolders?: array{
* appVersion: string,
* hasGroupFolders: bool,
* },
* }
*/
public function getCapabilities(): array {
$user = $this->userSession->getUser();
if (!$user) {
return [];
}
return [
Application::APP_ID => [
'appVersion' => $this->appManager->getAppVersion(Application::APP_ID),
'hasGroupFolders' => $this->hasFolders($user),
],
];
}
private function hasFolders(IUser $user): bool {
$folders = $this->folderManager->getFoldersForUser($user);
return count($folders) > 0;
}
}