@@ -37,22 +37,22 @@ |
||
37 | 37 | * @method void setExpiration(int $expiration) |
38 | 38 | */ |
39 | 39 | class Direct extends Entity { |
40 | - /** @var string */ |
|
41 | - protected $userId; |
|
40 | + /** @var string */ |
|
41 | + protected $userId; |
|
42 | 42 | |
43 | - /** @var int */ |
|
44 | - protected $fileId; |
|
43 | + /** @var int */ |
|
44 | + protected $fileId; |
|
45 | 45 | |
46 | - /** @var string */ |
|
47 | - protected $token; |
|
46 | + /** @var string */ |
|
47 | + protected $token; |
|
48 | 48 | |
49 | - /** @var int */ |
|
50 | - protected $expiration; |
|
49 | + /** @var int */ |
|
50 | + protected $expiration; |
|
51 | 51 | |
52 | - public function __construct() { |
|
53 | - $this->addType('userId', 'string'); |
|
54 | - $this->addType('fileId', 'int'); |
|
55 | - $this->addType('token', 'string'); |
|
56 | - $this->addType('expiration', 'int'); |
|
57 | - } |
|
52 | + public function __construct() { |
|
53 | + $this->addType('userId', 'string'); |
|
54 | + $this->addType('fileId', 'int'); |
|
55 | + $this->addType('token', 'string'); |
|
56 | + $this->addType('expiration', 'int'); |
|
57 | + } |
|
58 | 58 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ) { |
59 | 59 | $backend = $this->backendService->getBackend($storageOptions['backend']); |
60 | 60 | if (!$backend) { |
61 | - throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']); |
|
61 | + throw new \UnexpectedValueException('Invalid backend '.$storageOptions['backend']); |
|
62 | 62 | } |
63 | 63 | $storageConfig->setBackend($backend); |
64 | 64 | if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $storageOptions['authMechanism'] = 'null'; // to make error handling easier |
69 | 69 | } |
70 | 70 | if (!$authMechanism) { |
71 | - throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']); |
|
71 | + throw new \UnexpectedValueException('Invalid authentication mechanism '.$storageOptions['authMechanism']); |
|
72 | 72 | } |
73 | 73 | $storageConfig->setAuthMechanism($authMechanism); |
74 | 74 | $storageConfig->setBackendOptions($storageOptions['options']); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $parts = explode('/', ltrim($rootMountPath, '/'), 3); |
141 | 141 | if (count($parts) < 3) { |
142 | 142 | // something went wrong, skip |
143 | - \OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']); |
|
143 | + \OC::$server->getLogger()->error('Could not parse mount point "'.$rootMountPath.'"', ['app' => 'files_external']); |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | $relativeMountPath = rtrim($parts[2], '/'); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $storageOptions['authMechanism'] = null; // ensure config hash works |
155 | 155 | } |
156 | 156 | if (isset($storageOptions['id'])) { |
157 | - $configId = (int)$storageOptions['id']; |
|
157 | + $configId = (int) $storageOptions['id']; |
|
158 | 158 | if (isset($storages[$configId])) { |
159 | 159 | $currentStorage = $storages[$configId]; |
160 | 160 | } |
@@ -33,179 +33,179 @@ |
||
33 | 33 | * Read mount config from legacy mount.json |
34 | 34 | */ |
35 | 35 | abstract class LegacyStoragesService { |
36 | - /** @var BackendService */ |
|
37 | - protected $backendService; |
|
36 | + /** @var BackendService */ |
|
37 | + protected $backendService; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Read legacy config data |
|
41 | - * |
|
42 | - * @return array list of mount configs |
|
43 | - */ |
|
44 | - abstract protected function readLegacyConfig(); |
|
39 | + /** |
|
40 | + * Read legacy config data |
|
41 | + * |
|
42 | + * @return array list of mount configs |
|
43 | + */ |
|
44 | + abstract protected function readLegacyConfig(); |
|
45 | 45 | |
46 | - /** |
|
47 | - * Copy legacy storage options into the given storage config object. |
|
48 | - * |
|
49 | - * @param StorageConfig $storageConfig storage config to populate |
|
50 | - * @param string $mountType mount type |
|
51 | - * @param string $applicable applicable user or group |
|
52 | - * @param array $storageOptions legacy storage options |
|
53 | - * |
|
54 | - * @return StorageConfig populated storage config |
|
55 | - */ |
|
56 | - protected function populateStorageConfigWithLegacyOptions( |
|
57 | - &$storageConfig, |
|
58 | - $mountType, |
|
59 | - $applicable, |
|
60 | - $storageOptions |
|
61 | - ) { |
|
62 | - $backend = $this->backendService->getBackend($storageOptions['backend']); |
|
63 | - if (!$backend) { |
|
64 | - throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']); |
|
65 | - } |
|
66 | - $storageConfig->setBackend($backend); |
|
67 | - if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') { |
|
68 | - $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']); |
|
69 | - } else { |
|
70 | - $authMechanism = $backend->getLegacyAuthMechanism($storageOptions); |
|
71 | - $storageOptions['authMechanism'] = 'null'; // to make error handling easier |
|
72 | - } |
|
73 | - if (!$authMechanism) { |
|
74 | - throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']); |
|
75 | - } |
|
76 | - $storageConfig->setAuthMechanism($authMechanism); |
|
77 | - $storageConfig->setBackendOptions($storageOptions['options']); |
|
78 | - if (isset($storageOptions['mountOptions'])) { |
|
79 | - $storageConfig->setMountOptions($storageOptions['mountOptions']); |
|
80 | - } |
|
81 | - if (!isset($storageOptions['priority'])) { |
|
82 | - $storageOptions['priority'] = $backend->getPriority(); |
|
83 | - } |
|
84 | - $storageConfig->setPriority($storageOptions['priority']); |
|
85 | - if ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_USER) { |
|
86 | - $applicableUsers = $storageConfig->getApplicableUsers(); |
|
87 | - if ($applicable !== 'all') { |
|
88 | - $applicableUsers[] = $applicable; |
|
89 | - $storageConfig->setApplicableUsers($applicableUsers); |
|
90 | - } |
|
91 | - } elseif ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP) { |
|
92 | - $applicableGroups = $storageConfig->getApplicableGroups(); |
|
93 | - $applicableGroups[] = $applicable; |
|
94 | - $storageConfig->setApplicableGroups($applicableGroups); |
|
95 | - } |
|
96 | - return $storageConfig; |
|
97 | - } |
|
46 | + /** |
|
47 | + * Copy legacy storage options into the given storage config object. |
|
48 | + * |
|
49 | + * @param StorageConfig $storageConfig storage config to populate |
|
50 | + * @param string $mountType mount type |
|
51 | + * @param string $applicable applicable user or group |
|
52 | + * @param array $storageOptions legacy storage options |
|
53 | + * |
|
54 | + * @return StorageConfig populated storage config |
|
55 | + */ |
|
56 | + protected function populateStorageConfigWithLegacyOptions( |
|
57 | + &$storageConfig, |
|
58 | + $mountType, |
|
59 | + $applicable, |
|
60 | + $storageOptions |
|
61 | + ) { |
|
62 | + $backend = $this->backendService->getBackend($storageOptions['backend']); |
|
63 | + if (!$backend) { |
|
64 | + throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']); |
|
65 | + } |
|
66 | + $storageConfig->setBackend($backend); |
|
67 | + if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') { |
|
68 | + $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']); |
|
69 | + } else { |
|
70 | + $authMechanism = $backend->getLegacyAuthMechanism($storageOptions); |
|
71 | + $storageOptions['authMechanism'] = 'null'; // to make error handling easier |
|
72 | + } |
|
73 | + if (!$authMechanism) { |
|
74 | + throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']); |
|
75 | + } |
|
76 | + $storageConfig->setAuthMechanism($authMechanism); |
|
77 | + $storageConfig->setBackendOptions($storageOptions['options']); |
|
78 | + if (isset($storageOptions['mountOptions'])) { |
|
79 | + $storageConfig->setMountOptions($storageOptions['mountOptions']); |
|
80 | + } |
|
81 | + if (!isset($storageOptions['priority'])) { |
|
82 | + $storageOptions['priority'] = $backend->getPriority(); |
|
83 | + } |
|
84 | + $storageConfig->setPriority($storageOptions['priority']); |
|
85 | + if ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_USER) { |
|
86 | + $applicableUsers = $storageConfig->getApplicableUsers(); |
|
87 | + if ($applicable !== 'all') { |
|
88 | + $applicableUsers[] = $applicable; |
|
89 | + $storageConfig->setApplicableUsers($applicableUsers); |
|
90 | + } |
|
91 | + } elseif ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP) { |
|
92 | + $applicableGroups = $storageConfig->getApplicableGroups(); |
|
93 | + $applicableGroups[] = $applicable; |
|
94 | + $storageConfig->setApplicableGroups($applicableGroups); |
|
95 | + } |
|
96 | + return $storageConfig; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Read the external storage config |
|
101 | - * |
|
102 | - * @return StorageConfig[] map of storage id to storage config |
|
103 | - */ |
|
104 | - public function getAllStorages() { |
|
105 | - $mountPoints = $this->readLegacyConfig(); |
|
106 | - /** |
|
107 | - * Here is the how the horribly messy mount point array looks like |
|
108 | - * from the mount.json file: |
|
109 | - * |
|
110 | - * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath] |
|
111 | - * |
|
112 | - * - $mountType is either "user" or "group" |
|
113 | - * - $applicable is the name of a user or group (or the current user for personal mounts) |
|
114 | - * - $mountPath is the mount point path (where the storage must be mounted) |
|
115 | - * - $storageOptions is a map of storage options: |
|
116 | - * - "priority": storage priority |
|
117 | - * - "backend": backend identifier |
|
118 | - * - "class": LEGACY backend class name |
|
119 | - * - "options": backend-specific options |
|
120 | - * - "authMechanism": authentication mechanism identifier |
|
121 | - * - "mountOptions": mount-specific options (ex: disable previews, scanner, etc) |
|
122 | - */ |
|
123 | - // group by storage id |
|
124 | - /** @var StorageConfig[] $storages */ |
|
125 | - $storages = []; |
|
126 | - // for storages without id (legacy), group by config hash for |
|
127 | - // later processing |
|
128 | - $storagesWithConfigHash = []; |
|
129 | - foreach ($mountPoints as $mountType => $applicables) { |
|
130 | - foreach ($applicables as $applicable => $mountPaths) { |
|
131 | - foreach ($mountPaths as $rootMountPath => $storageOptions) { |
|
132 | - $currentStorage = null; |
|
133 | - /** |
|
134 | - * Flag whether the config that was read already has an id. |
|
135 | - * If not, it will use a config hash instead and generate |
|
136 | - * a proper id later |
|
137 | - * |
|
138 | - * @var boolean |
|
139 | - */ |
|
140 | - $hasId = false; |
|
141 | - // the root mount point is in the format "/$user/files/the/mount/point" |
|
142 | - // we remove the "/$user/files" prefix |
|
143 | - $parts = explode('/', ltrim($rootMountPath, '/'), 3); |
|
144 | - if (count($parts) < 3) { |
|
145 | - // something went wrong, skip |
|
146 | - \OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']); |
|
147 | - continue; |
|
148 | - } |
|
149 | - $relativeMountPath = rtrim($parts[2], '/'); |
|
150 | - // note: we cannot do this after the loop because the decrypted config |
|
151 | - // options might be needed for the config hash |
|
152 | - $storageOptions['options'] = \OCA\Files_External\MountConfig::decryptPasswords($storageOptions['options']); |
|
153 | - if (!isset($storageOptions['backend'])) { |
|
154 | - $storageOptions['backend'] = $storageOptions['class']; // legacy compat |
|
155 | - } |
|
156 | - if (!isset($storageOptions['authMechanism'])) { |
|
157 | - $storageOptions['authMechanism'] = null; // ensure config hash works |
|
158 | - } |
|
159 | - if (isset($storageOptions['id'])) { |
|
160 | - $configId = (int)$storageOptions['id']; |
|
161 | - if (isset($storages[$configId])) { |
|
162 | - $currentStorage = $storages[$configId]; |
|
163 | - } |
|
164 | - $hasId = true; |
|
165 | - } else { |
|
166 | - // missing id in legacy config, need to generate |
|
167 | - // but at this point we don't know the max-id, so use |
|
168 | - // first group it by config hash |
|
169 | - $storageOptions['mountpoint'] = $rootMountPath; |
|
170 | - $configId = \OCA\Files_External\MountConfig::makeConfigHash($storageOptions); |
|
171 | - if (isset($storagesWithConfigHash[$configId])) { |
|
172 | - $currentStorage = $storagesWithConfigHash[$configId]; |
|
173 | - } |
|
174 | - } |
|
175 | - if (is_null($currentStorage)) { |
|
176 | - // create new |
|
177 | - $currentStorage = new StorageConfig($configId); |
|
178 | - $currentStorage->setMountPoint($relativeMountPath); |
|
179 | - } |
|
180 | - try { |
|
181 | - $this->populateStorageConfigWithLegacyOptions( |
|
182 | - $currentStorage, |
|
183 | - $mountType, |
|
184 | - $applicable, |
|
185 | - $storageOptions |
|
186 | - ); |
|
187 | - if ($hasId) { |
|
188 | - $storages[$configId] = $currentStorage; |
|
189 | - } else { |
|
190 | - $storagesWithConfigHash[$configId] = $currentStorage; |
|
191 | - } |
|
192 | - } catch (\UnexpectedValueException $e) { |
|
193 | - // don't die if a storage backend doesn't exist |
|
194 | - \OC::$server->getLogger()->logException($e, [ |
|
195 | - 'message' => 'Could not load storage.', |
|
196 | - 'level' => ILogger::ERROR, |
|
197 | - 'app' => 'files_external', |
|
198 | - ]); |
|
199 | - } |
|
200 | - } |
|
201 | - } |
|
202 | - } |
|
99 | + /** |
|
100 | + * Read the external storage config |
|
101 | + * |
|
102 | + * @return StorageConfig[] map of storage id to storage config |
|
103 | + */ |
|
104 | + public function getAllStorages() { |
|
105 | + $mountPoints = $this->readLegacyConfig(); |
|
106 | + /** |
|
107 | + * Here is the how the horribly messy mount point array looks like |
|
108 | + * from the mount.json file: |
|
109 | + * |
|
110 | + * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath] |
|
111 | + * |
|
112 | + * - $mountType is either "user" or "group" |
|
113 | + * - $applicable is the name of a user or group (or the current user for personal mounts) |
|
114 | + * - $mountPath is the mount point path (where the storage must be mounted) |
|
115 | + * - $storageOptions is a map of storage options: |
|
116 | + * - "priority": storage priority |
|
117 | + * - "backend": backend identifier |
|
118 | + * - "class": LEGACY backend class name |
|
119 | + * - "options": backend-specific options |
|
120 | + * - "authMechanism": authentication mechanism identifier |
|
121 | + * - "mountOptions": mount-specific options (ex: disable previews, scanner, etc) |
|
122 | + */ |
|
123 | + // group by storage id |
|
124 | + /** @var StorageConfig[] $storages */ |
|
125 | + $storages = []; |
|
126 | + // for storages without id (legacy), group by config hash for |
|
127 | + // later processing |
|
128 | + $storagesWithConfigHash = []; |
|
129 | + foreach ($mountPoints as $mountType => $applicables) { |
|
130 | + foreach ($applicables as $applicable => $mountPaths) { |
|
131 | + foreach ($mountPaths as $rootMountPath => $storageOptions) { |
|
132 | + $currentStorage = null; |
|
133 | + /** |
|
134 | + * Flag whether the config that was read already has an id. |
|
135 | + * If not, it will use a config hash instead and generate |
|
136 | + * a proper id later |
|
137 | + * |
|
138 | + * @var boolean |
|
139 | + */ |
|
140 | + $hasId = false; |
|
141 | + // the root mount point is in the format "/$user/files/the/mount/point" |
|
142 | + // we remove the "/$user/files" prefix |
|
143 | + $parts = explode('/', ltrim($rootMountPath, '/'), 3); |
|
144 | + if (count($parts) < 3) { |
|
145 | + // something went wrong, skip |
|
146 | + \OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']); |
|
147 | + continue; |
|
148 | + } |
|
149 | + $relativeMountPath = rtrim($parts[2], '/'); |
|
150 | + // note: we cannot do this after the loop because the decrypted config |
|
151 | + // options might be needed for the config hash |
|
152 | + $storageOptions['options'] = \OCA\Files_External\MountConfig::decryptPasswords($storageOptions['options']); |
|
153 | + if (!isset($storageOptions['backend'])) { |
|
154 | + $storageOptions['backend'] = $storageOptions['class']; // legacy compat |
|
155 | + } |
|
156 | + if (!isset($storageOptions['authMechanism'])) { |
|
157 | + $storageOptions['authMechanism'] = null; // ensure config hash works |
|
158 | + } |
|
159 | + if (isset($storageOptions['id'])) { |
|
160 | + $configId = (int)$storageOptions['id']; |
|
161 | + if (isset($storages[$configId])) { |
|
162 | + $currentStorage = $storages[$configId]; |
|
163 | + } |
|
164 | + $hasId = true; |
|
165 | + } else { |
|
166 | + // missing id in legacy config, need to generate |
|
167 | + // but at this point we don't know the max-id, so use |
|
168 | + // first group it by config hash |
|
169 | + $storageOptions['mountpoint'] = $rootMountPath; |
|
170 | + $configId = \OCA\Files_External\MountConfig::makeConfigHash($storageOptions); |
|
171 | + if (isset($storagesWithConfigHash[$configId])) { |
|
172 | + $currentStorage = $storagesWithConfigHash[$configId]; |
|
173 | + } |
|
174 | + } |
|
175 | + if (is_null($currentStorage)) { |
|
176 | + // create new |
|
177 | + $currentStorage = new StorageConfig($configId); |
|
178 | + $currentStorage->setMountPoint($relativeMountPath); |
|
179 | + } |
|
180 | + try { |
|
181 | + $this->populateStorageConfigWithLegacyOptions( |
|
182 | + $currentStorage, |
|
183 | + $mountType, |
|
184 | + $applicable, |
|
185 | + $storageOptions |
|
186 | + ); |
|
187 | + if ($hasId) { |
|
188 | + $storages[$configId] = $currentStorage; |
|
189 | + } else { |
|
190 | + $storagesWithConfigHash[$configId] = $currentStorage; |
|
191 | + } |
|
192 | + } catch (\UnexpectedValueException $e) { |
|
193 | + // don't die if a storage backend doesn't exist |
|
194 | + \OC::$server->getLogger()->logException($e, [ |
|
195 | + 'message' => 'Could not load storage.', |
|
196 | + 'level' => ILogger::ERROR, |
|
197 | + 'app' => 'files_external', |
|
198 | + ]); |
|
199 | + } |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | 203 | |
204 | - // convert parameter values |
|
205 | - foreach ($storages as $storage) { |
|
206 | - $storage->getBackend()->validateStorageDefinition($storage); |
|
207 | - $storage->getAuthMechanism()->validateStorageDefinition($storage); |
|
208 | - } |
|
209 | - return $storages; |
|
210 | - } |
|
204 | + // convert parameter values |
|
205 | + foreach ($storages as $storage) { |
|
206 | + $storage->getBackend()->validateStorageDefinition($storage); |
|
207 | + $storage->getAuthMechanism()->validateStorageDefinition($storage); |
|
208 | + } |
|
209 | + return $storages; |
|
210 | + } |
|
211 | 211 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | */ |
63 | 63 | public function addEntityCollection(string $name, \Closure $entityExistsFunction) { |
64 | 64 | if (isset($this->collections[$name])) { |
65 | - throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
65 | + throw new \OutOfBoundsException('Duplicate entity name "'.$name.'"'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $this->collections[$name] = $entityExistsFunction; |
@@ -35,49 +35,49 @@ |
||
35 | 35 | * @since 9.1.0 |
36 | 36 | */ |
37 | 37 | class SystemTagsEntityEvent extends Event { |
38 | - /** |
|
39 | - * @deprecated 22.0.0 |
|
40 | - */ |
|
41 | - public const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity'; |
|
38 | + /** |
|
39 | + * @deprecated 22.0.0 |
|
40 | + */ |
|
41 | + public const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity'; |
|
42 | 42 | |
43 | - /** @var string */ |
|
44 | - protected $event; |
|
45 | - /** @var \Closure[] */ |
|
46 | - protected $collections; |
|
43 | + /** @var string */ |
|
44 | + protected $event; |
|
45 | + /** @var \Closure[] */ |
|
46 | + protected $collections; |
|
47 | 47 | |
48 | - /** |
|
49 | - * SystemTagsEntityEvent constructor. |
|
50 | - * |
|
51 | - * @param string $event |
|
52 | - * @since 9.1.0 |
|
53 | - */ |
|
54 | - public function __construct(string $event) { |
|
55 | - $this->event = $event; |
|
56 | - $this->collections = []; |
|
57 | - } |
|
48 | + /** |
|
49 | + * SystemTagsEntityEvent constructor. |
|
50 | + * |
|
51 | + * @param string $event |
|
52 | + * @since 9.1.0 |
|
53 | + */ |
|
54 | + public function __construct(string $event) { |
|
55 | + $this->event = $event; |
|
56 | + $this->collections = []; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param string $name |
|
61 | - * @param \Closure $entityExistsFunction The closure should take one |
|
62 | - * argument, which is the id of the entity, that tags |
|
63 | - * should be handled for. The return should then be bool, |
|
64 | - * depending on whether tags are allowed (true) or not. |
|
65 | - * @throws \OutOfBoundsException when the entity name is already taken |
|
66 | - * @since 9.1.0 |
|
67 | - */ |
|
68 | - public function addEntityCollection(string $name, \Closure $entityExistsFunction) { |
|
69 | - if (isset($this->collections[$name])) { |
|
70 | - throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
71 | - } |
|
59 | + /** |
|
60 | + * @param string $name |
|
61 | + * @param \Closure $entityExistsFunction The closure should take one |
|
62 | + * argument, which is the id of the entity, that tags |
|
63 | + * should be handled for. The return should then be bool, |
|
64 | + * depending on whether tags are allowed (true) or not. |
|
65 | + * @throws \OutOfBoundsException when the entity name is already taken |
|
66 | + * @since 9.1.0 |
|
67 | + */ |
|
68 | + public function addEntityCollection(string $name, \Closure $entityExistsFunction) { |
|
69 | + if (isset($this->collections[$name])) { |
|
70 | + throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
71 | + } |
|
72 | 72 | |
73 | - $this->collections[$name] = $entityExistsFunction; |
|
74 | - } |
|
73 | + $this->collections[$name] = $entityExistsFunction; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @return \Closure[] |
|
78 | - * @since 9.1.0 |
|
79 | - */ |
|
80 | - public function getEntityCollections(): array { |
|
81 | - return $this->collections; |
|
82 | - } |
|
76 | + /** |
|
77 | + * @return \Closure[] |
|
78 | + * @since 9.1.0 |
|
79 | + */ |
|
80 | + public function getEntityCollections(): array { |
|
81 | + return $this->collections; |
|
82 | + } |
|
83 | 83 | } |
@@ -67,6 +67,6 @@ |
||
67 | 67 | $implements |= Backend::COUNT_USERS; |
68 | 68 | } |
69 | 69 | |
70 | - return (bool)($actions & $implements); |
|
70 | + return (bool) ($actions & $implements); |
|
71 | 71 | } |
72 | 72 | } |
@@ -34,41 +34,41 @@ |
||
34 | 34 | * @since 14.0.0 |
35 | 35 | */ |
36 | 36 | abstract class ABackend implements IUserBackend, UserInterface { |
37 | - /** |
|
38 | - * @deprecated 14.0.0 |
|
39 | - * @since 14.0.0 |
|
40 | - * |
|
41 | - * @param int $actions The action to check for |
|
42 | - * @return bool |
|
43 | - */ |
|
44 | - public function implementsActions($actions): bool { |
|
45 | - $implements = 0; |
|
37 | + /** |
|
38 | + * @deprecated 14.0.0 |
|
39 | + * @since 14.0.0 |
|
40 | + * |
|
41 | + * @param int $actions The action to check for |
|
42 | + * @return bool |
|
43 | + */ |
|
44 | + public function implementsActions($actions): bool { |
|
45 | + $implements = 0; |
|
46 | 46 | |
47 | - if ($this instanceof ICreateUserBackend) { |
|
48 | - $implements |= Backend::CREATE_USER; |
|
49 | - } |
|
50 | - if ($this instanceof ISetPasswordBackend) { |
|
51 | - $implements |= Backend::SET_PASSWORD; |
|
52 | - } |
|
53 | - if ($this instanceof ICheckPasswordBackend) { |
|
54 | - $implements |= Backend::CHECK_PASSWORD; |
|
55 | - } |
|
56 | - if ($this instanceof IGetHomeBackend) { |
|
57 | - $implements |= Backend::GET_HOME; |
|
58 | - } |
|
59 | - if ($this instanceof IGetDisplayNameBackend) { |
|
60 | - $implements |= Backend::GET_DISPLAYNAME; |
|
61 | - } |
|
62 | - if ($this instanceof ISetDisplayNameBackend) { |
|
63 | - $implements |= Backend::SET_DISPLAYNAME; |
|
64 | - } |
|
65 | - if ($this instanceof IProvideAvatarBackend) { |
|
66 | - $implements |= Backend::PROVIDE_AVATAR; |
|
67 | - } |
|
68 | - if ($this instanceof ICountUsersBackend) { |
|
69 | - $implements |= Backend::COUNT_USERS; |
|
70 | - } |
|
47 | + if ($this instanceof ICreateUserBackend) { |
|
48 | + $implements |= Backend::CREATE_USER; |
|
49 | + } |
|
50 | + if ($this instanceof ISetPasswordBackend) { |
|
51 | + $implements |= Backend::SET_PASSWORD; |
|
52 | + } |
|
53 | + if ($this instanceof ICheckPasswordBackend) { |
|
54 | + $implements |= Backend::CHECK_PASSWORD; |
|
55 | + } |
|
56 | + if ($this instanceof IGetHomeBackend) { |
|
57 | + $implements |= Backend::GET_HOME; |
|
58 | + } |
|
59 | + if ($this instanceof IGetDisplayNameBackend) { |
|
60 | + $implements |= Backend::GET_DISPLAYNAME; |
|
61 | + } |
|
62 | + if ($this instanceof ISetDisplayNameBackend) { |
|
63 | + $implements |= Backend::SET_DISPLAYNAME; |
|
64 | + } |
|
65 | + if ($this instanceof IProvideAvatarBackend) { |
|
66 | + $implements |= Backend::PROVIDE_AVATAR; |
|
67 | + } |
|
68 | + if ($this instanceof ICountUsersBackend) { |
|
69 | + $implements |= Backend::COUNT_USERS; |
|
70 | + } |
|
71 | 71 | |
72 | - return (bool)($actions & $implements); |
|
73 | - } |
|
72 | + return (bool)($actions & $implements); |
|
73 | + } |
|
74 | 74 | } |
@@ -62,6 +62,6 @@ |
||
62 | 62 | $implements |= GroupInterface::REMOVE_FROM_GOUP; |
63 | 63 | } |
64 | 64 | |
65 | - return (bool)($actions & $implements); |
|
65 | + return (bool) ($actions & $implements); |
|
66 | 66 | } |
67 | 67 | } |
@@ -31,38 +31,38 @@ |
||
31 | 31 | * @since 14.0.0 |
32 | 32 | */ |
33 | 33 | abstract class ABackend implements GroupInterface { |
34 | - /** |
|
35 | - * @deprecated 14.0.0 |
|
36 | - * @since 14.0.0 |
|
37 | - * |
|
38 | - * @param int $actions The action to check for |
|
39 | - * @return bool |
|
40 | - */ |
|
41 | - public function implementsActions($actions): bool { |
|
42 | - $implements = 0; |
|
34 | + /** |
|
35 | + * @deprecated 14.0.0 |
|
36 | + * @since 14.0.0 |
|
37 | + * |
|
38 | + * @param int $actions The action to check for |
|
39 | + * @return bool |
|
40 | + */ |
|
41 | + public function implementsActions($actions): bool { |
|
42 | + $implements = 0; |
|
43 | 43 | |
44 | - if ($this instanceof IAddToGroupBackend) { |
|
45 | - $implements |= GroupInterface::ADD_TO_GROUP; |
|
46 | - } |
|
47 | - if ($this instanceof ICountUsersBackend) { |
|
48 | - $implements |= GroupInterface::COUNT_USERS; |
|
49 | - } |
|
50 | - if ($this instanceof ICreateGroupBackend) { |
|
51 | - $implements |= GroupInterface::CREATE_GROUP; |
|
52 | - } |
|
53 | - if ($this instanceof IDeleteGroupBackend) { |
|
54 | - $implements |= GroupInterface::DELETE_GROUP; |
|
55 | - } |
|
56 | - if ($this instanceof IGroupDetailsBackend) { |
|
57 | - $implements |= GroupInterface::GROUP_DETAILS; |
|
58 | - } |
|
59 | - if ($this instanceof IIsAdminBackend) { |
|
60 | - $implements |= GroupInterface::IS_ADMIN; |
|
61 | - } |
|
62 | - if ($this instanceof IRemoveFromGroupBackend) { |
|
63 | - $implements |= GroupInterface::REMOVE_FROM_GOUP; |
|
64 | - } |
|
44 | + if ($this instanceof IAddToGroupBackend) { |
|
45 | + $implements |= GroupInterface::ADD_TO_GROUP; |
|
46 | + } |
|
47 | + if ($this instanceof ICountUsersBackend) { |
|
48 | + $implements |= GroupInterface::COUNT_USERS; |
|
49 | + } |
|
50 | + if ($this instanceof ICreateGroupBackend) { |
|
51 | + $implements |= GroupInterface::CREATE_GROUP; |
|
52 | + } |
|
53 | + if ($this instanceof IDeleteGroupBackend) { |
|
54 | + $implements |= GroupInterface::DELETE_GROUP; |
|
55 | + } |
|
56 | + if ($this instanceof IGroupDetailsBackend) { |
|
57 | + $implements |= GroupInterface::GROUP_DETAILS; |
|
58 | + } |
|
59 | + if ($this instanceof IIsAdminBackend) { |
|
60 | + $implements |= GroupInterface::IS_ADMIN; |
|
61 | + } |
|
62 | + if ($this instanceof IRemoveFromGroupBackend) { |
|
63 | + $implements |= GroupInterface::REMOVE_FROM_GOUP; |
|
64 | + } |
|
65 | 65 | |
66 | - return (bool)($actions & $implements); |
|
67 | - } |
|
66 | + return (bool)($actions & $implements); |
|
67 | + } |
|
68 | 68 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | |
22 | 22 | |
23 | -require_once __DIR__ . '/../lib/base.php'; |
|
23 | +require_once __DIR__.'/../lib/base.php'; |
|
24 | 24 | |
25 | 25 | header('Content-Type: application/json'); |
26 | 26 |
@@ -29,12 +29,12 @@ |
||
29 | 29 | $isEnabled = $server->getAppManager()->isEnabledForUser('cloud_federation_api'); |
30 | 30 | |
31 | 31 | if ($isEnabled) { |
32 | - // Make sure the routes are loaded |
|
33 | - \OC_App::loadApp('cloud_federation_api'); |
|
34 | - $capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator()); |
|
35 | - header('Content-Type: application/json'); |
|
36 | - echo json_encode($capabilities->getCapabilities()['ocm']); |
|
32 | + // Make sure the routes are loaded |
|
33 | + \OC_App::loadApp('cloud_federation_api'); |
|
34 | + $capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator()); |
|
35 | + header('Content-Type: application/json'); |
|
36 | + echo json_encode($capabilities->getCapabilities()['ocm']); |
|
37 | 37 | } else { |
38 | - header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501); |
|
39 | - exit("501 Not Implemented"); |
|
38 | + header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501); |
|
39 | + exit("501 Not Implemented"); |
|
40 | 40 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | public function __construct($providerId) { |
34 | 34 | $l = \OC::$server->getL10N('federation'); |
35 | - $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.'; |
|
35 | + $message = 'Cloud Federation Provider with ID: "'.$providerId.'" does not exist.'; |
|
36 | 36 | $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]); |
37 | 37 | parent::__construct($message, $hint); |
38 | 38 | } |
@@ -31,17 +31,17 @@ |
||
31 | 31 | * @since 14.0.0 |
32 | 32 | */ |
33 | 33 | class ProviderDoesNotExistsException extends HintException { |
34 | - /** |
|
35 | - * ProviderDoesNotExistsException constructor. |
|
36 | - * |
|
37 | - * @since 14.0.0 |
|
38 | - * |
|
39 | - * @param string $providerId cloud federation provider ID |
|
40 | - */ |
|
41 | - public function __construct($providerId) { |
|
42 | - $l = \OC::$server->getL10N('federation'); |
|
43 | - $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.'; |
|
44 | - $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]); |
|
45 | - parent::__construct($message, $hint); |
|
46 | - } |
|
34 | + /** |
|
35 | + * ProviderDoesNotExistsException constructor. |
|
36 | + * |
|
37 | + * @since 14.0.0 |
|
38 | + * |
|
39 | + * @param string $providerId cloud federation provider ID |
|
40 | + */ |
|
41 | + public function __construct($providerId) { |
|
42 | + $l = \OC::$server->getL10N('federation'); |
|
43 | + $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.'; |
|
44 | + $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]); |
|
45 | + parent::__construct($message, $hint); |
|
46 | + } |
|
47 | 47 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | public function __construct($action) { |
33 | 33 | $l = \OC::$server->getL10N('federation'); |
34 | - $message = 'Action "' . $action . '" not supported or implemented.'; |
|
34 | + $message = 'Action "'.$action.'" not supported or implemented.'; |
|
35 | 35 | $hint = $l->t('Action "%s" not supported or implemented.', [$action]); |
36 | 36 | parent::__construct($message, $hint); |
37 | 37 | } |
@@ -31,16 +31,16 @@ |
||
31 | 31 | * @since 14.0.0 |
32 | 32 | */ |
33 | 33 | class ActionNotSupportedException extends HintException { |
34 | - /** |
|
35 | - * ActionNotSupportedException constructor. |
|
36 | - * |
|
37 | - * @since 14.0.0 |
|
38 | - * |
|
39 | - */ |
|
40 | - public function __construct($action) { |
|
41 | - $l = \OC::$server->getL10N('federation'); |
|
42 | - $message = 'Action "' . $action . '" not supported or implemented.'; |
|
43 | - $hint = $l->t('Action "%s" not supported or implemented.', [$action]); |
|
44 | - parent::__construct($message, $hint); |
|
45 | - } |
|
34 | + /** |
|
35 | + * ActionNotSupportedException constructor. |
|
36 | + * |
|
37 | + * @since 14.0.0 |
|
38 | + * |
|
39 | + */ |
|
40 | + public function __construct($action) { |
|
41 | + $l = \OC::$server->getL10N('federation'); |
|
42 | + $message = 'Action "' . $action . '" not supported or implemented.'; |
|
43 | + $hint = $l->t('Action "%s" not supported or implemented.', [$action]); |
|
44 | + parent::__construct($message, $hint); |
|
45 | + } |
|
46 | 46 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | try { |
58 | - $folder = $this->appData->getFolder((string)$node->getId()); |
|
58 | + $folder = $this->appData->getFolder((string) $node->getId()); |
|
59 | 59 | $folder->delete(); |
60 | 60 | } catch (NotFoundException $e) { |
61 | 61 | //Nothing to do |
@@ -36,39 +36,39 @@ |
||
36 | 36 | * Class that will watch filesystem activity and remove previews as needed. |
37 | 37 | */ |
38 | 38 | class Watcher { |
39 | - /** @var IAppData */ |
|
40 | - private $appData; |
|
39 | + /** @var IAppData */ |
|
40 | + private $appData; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Watcher constructor. |
|
44 | - * |
|
45 | - * @param IAppData $appData |
|
46 | - */ |
|
47 | - public function __construct(IAppData $appData) { |
|
48 | - $this->appData = $appData; |
|
49 | - } |
|
42 | + /** |
|
43 | + * Watcher constructor. |
|
44 | + * |
|
45 | + * @param IAppData $appData |
|
46 | + */ |
|
47 | + public function __construct(IAppData $appData) { |
|
48 | + $this->appData = $appData; |
|
49 | + } |
|
50 | 50 | |
51 | - public function postWrite(Node $node) { |
|
52 | - $this->deleteNode($node); |
|
53 | - } |
|
51 | + public function postWrite(Node $node) { |
|
52 | + $this->deleteNode($node); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function deleteNode(Node $node) { |
|
56 | - // We only handle files |
|
57 | - if ($node instanceof Folder) { |
|
58 | - return; |
|
59 | - } |
|
55 | + protected function deleteNode(Node $node) { |
|
56 | + // We only handle files |
|
57 | + if ($node instanceof Folder) { |
|
58 | + return; |
|
59 | + } |
|
60 | 60 | |
61 | - try { |
|
62 | - $folder = $this->appData->getFolder((string)$node->getId()); |
|
63 | - $folder->delete(); |
|
64 | - } catch (NotFoundException $e) { |
|
65 | - //Nothing to do |
|
66 | - } |
|
67 | - } |
|
61 | + try { |
|
62 | + $folder = $this->appData->getFolder((string)$node->getId()); |
|
63 | + $folder->delete(); |
|
64 | + } catch (NotFoundException $e) { |
|
65 | + //Nothing to do |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - public function versionRollback(array $data) { |
|
70 | - if (isset($data['node'])) { |
|
71 | - $this->deleteNode($data['node']); |
|
72 | - } |
|
73 | - } |
|
69 | + public function versionRollback(array $data) { |
|
70 | + if (isset($data['node'])) { |
|
71 | + $this->deleteNode($data['node']); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |