Passed
Push — master ( ca93c9...82ee30 )
by Morris
15:49
created
apps/files_external/lib/Controller/StoragesController.php 1 patch
Indentation   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -51,337 +51,337 @@
 block discarded – undo
51 51
  */
52 52
 abstract class StoragesController extends Controller {
53 53
 
54
-	/**
55
-	 * L10N service
56
-	 *
57
-	 * @var IL10N
58
-	 */
59
-	protected $l10n;
54
+    /**
55
+     * L10N service
56
+     *
57
+     * @var IL10N
58
+     */
59
+    protected $l10n;
60 60
 
61
-	/**
62
-	 * Storages service
63
-	 *
64
-	 * @var StoragesService
65
-	 */
66
-	protected $service;
61
+    /**
62
+     * Storages service
63
+     *
64
+     * @var StoragesService
65
+     */
66
+    protected $service;
67 67
 
68
-	/**
69
-	 * @var ILogger
70
-	 */
71
-	protected $logger;
68
+    /**
69
+     * @var ILogger
70
+     */
71
+    protected $logger;
72 72
 
73
-	/**
74
-	 * @var IUserSession
75
-	 */
76
-	protected $userSession;
73
+    /**
74
+     * @var IUserSession
75
+     */
76
+    protected $userSession;
77 77
 
78
-	/**
79
-	 * @var IGroupManager
80
-	 */
81
-	protected $groupManager;
78
+    /**
79
+     * @var IGroupManager
80
+     */
81
+    protected $groupManager;
82 82
 
83
-	/**
84
-	 * Creates a new storages controller.
85
-	 *
86
-	 * @param string $AppName application name
87
-	 * @param IRequest $request request object
88
-	 * @param IL10N $l10n l10n service
89
-	 * @param StoragesService $storagesService storage service
90
-	 * @param ILogger $logger
91
-	 */
92
-	public function __construct(
93
-		$AppName,
94
-		IRequest $request,
95
-		IL10N $l10n,
96
-		StoragesService $storagesService,
97
-		ILogger $logger,
98
-		IUserSession $userSession,
99
-		IGroupManager $groupManager
100
-	) {
101
-		parent::__construct($AppName, $request);
102
-		$this->l10n = $l10n;
103
-		$this->service = $storagesService;
104
-		$this->logger = $logger;
105
-		$this->userSession = $userSession;
106
-		$this->groupManager = $groupManager;
107
-	}
83
+    /**
84
+     * Creates a new storages controller.
85
+     *
86
+     * @param string $AppName application name
87
+     * @param IRequest $request request object
88
+     * @param IL10N $l10n l10n service
89
+     * @param StoragesService $storagesService storage service
90
+     * @param ILogger $logger
91
+     */
92
+    public function __construct(
93
+        $AppName,
94
+        IRequest $request,
95
+        IL10N $l10n,
96
+        StoragesService $storagesService,
97
+        ILogger $logger,
98
+        IUserSession $userSession,
99
+        IGroupManager $groupManager
100
+    ) {
101
+        parent::__construct($AppName, $request);
102
+        $this->l10n = $l10n;
103
+        $this->service = $storagesService;
104
+        $this->logger = $logger;
105
+        $this->userSession = $userSession;
106
+        $this->groupManager = $groupManager;
107
+    }
108 108
 
109
-	/**
110
-	 * Create a storage from its parameters
111
-	 *
112
-	 * @param string $mountPoint storage mount point
113
-	 * @param string $backend backend identifier
114
-	 * @param string $authMechanism authentication mechanism identifier
115
-	 * @param array $backendOptions backend-specific options
116
-	 * @param array|null $mountOptions mount-specific options
117
-	 * @param array|null $applicableUsers users for which to mount the storage
118
-	 * @param array|null $applicableGroups groups for which to mount the storage
119
-	 * @param int|null $priority priority
120
-	 *
121
-	 * @return StorageConfig|DataResponse
122
-	 */
123
-	protected function createStorage(
124
-		$mountPoint,
125
-		$backend,
126
-		$authMechanism,
127
-		$backendOptions,
128
-		$mountOptions = null,
129
-		$applicableUsers = null,
130
-		$applicableGroups = null,
131
-		$priority = null
132
-	) {
133
-		try {
134
-			return $this->service->createStorage(
135
-				$mountPoint,
136
-				$backend,
137
-				$authMechanism,
138
-				$backendOptions,
139
-				$mountOptions,
140
-				$applicableUsers,
141
-				$applicableGroups,
142
-				$priority
143
-			);
144
-		} catch (\InvalidArgumentException $e) {
145
-			$this->logger->logException($e);
146
-			return new DataResponse(
147
-				[
148
-					'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class')
149
-				],
150
-				Http::STATUS_UNPROCESSABLE_ENTITY
151
-			);
152
-		}
153
-	}
109
+    /**
110
+     * Create a storage from its parameters
111
+     *
112
+     * @param string $mountPoint storage mount point
113
+     * @param string $backend backend identifier
114
+     * @param string $authMechanism authentication mechanism identifier
115
+     * @param array $backendOptions backend-specific options
116
+     * @param array|null $mountOptions mount-specific options
117
+     * @param array|null $applicableUsers users for which to mount the storage
118
+     * @param array|null $applicableGroups groups for which to mount the storage
119
+     * @param int|null $priority priority
120
+     *
121
+     * @return StorageConfig|DataResponse
122
+     */
123
+    protected function createStorage(
124
+        $mountPoint,
125
+        $backend,
126
+        $authMechanism,
127
+        $backendOptions,
128
+        $mountOptions = null,
129
+        $applicableUsers = null,
130
+        $applicableGroups = null,
131
+        $priority = null
132
+    ) {
133
+        try {
134
+            return $this->service->createStorage(
135
+                $mountPoint,
136
+                $backend,
137
+                $authMechanism,
138
+                $backendOptions,
139
+                $mountOptions,
140
+                $applicableUsers,
141
+                $applicableGroups,
142
+                $priority
143
+            );
144
+        } catch (\InvalidArgumentException $e) {
145
+            $this->logger->logException($e);
146
+            return new DataResponse(
147
+                [
148
+                    'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class')
149
+                ],
150
+                Http::STATUS_UNPROCESSABLE_ENTITY
151
+            );
152
+        }
153
+    }
154 154
 
155
-	/**
156
-	 * Validate storage config
157
-	 *
158
-	 * @param StorageConfig $storage storage config
159
-	 *1
160
-	 * @return DataResponse|null returns response in case of validation error
161
-	 */
162
-	protected function validate(StorageConfig $storage) {
163
-		$mountPoint = $storage->getMountPoint();
164
-		if ($mountPoint === '') {
165
-			return new DataResponse(
166
-				[
167
-					'message' => (string)$this->l10n->t('Invalid mount point'),
168
-				],
169
-				Http::STATUS_UNPROCESSABLE_ENTITY
170
-			);
171
-		}
155
+    /**
156
+     * Validate storage config
157
+     *
158
+     * @param StorageConfig $storage storage config
159
+     *1
160
+     * @return DataResponse|null returns response in case of validation error
161
+     */
162
+    protected function validate(StorageConfig $storage) {
163
+        $mountPoint = $storage->getMountPoint();
164
+        if ($mountPoint === '') {
165
+            return new DataResponse(
166
+                [
167
+                    'message' => (string)$this->l10n->t('Invalid mount point'),
168
+                ],
169
+                Http::STATUS_UNPROCESSABLE_ENTITY
170
+            );
171
+        }
172 172
 
173
-		if ($storage->getBackendOption('objectstore')) {
174
-			// objectstore must not be sent from client side
175
-			return new DataResponse(
176
-				[
177
-					'message' => (string)$this->l10n->t('Objectstore forbidden'),
178
-				],
179
-				Http::STATUS_UNPROCESSABLE_ENTITY
180
-			);
181
-		}
173
+        if ($storage->getBackendOption('objectstore')) {
174
+            // objectstore must not be sent from client side
175
+            return new DataResponse(
176
+                [
177
+                    'message' => (string)$this->l10n->t('Objectstore forbidden'),
178
+                ],
179
+                Http::STATUS_UNPROCESSABLE_ENTITY
180
+            );
181
+        }
182 182
 
183
-		/** @var Backend */
184
-		$backend = $storage->getBackend();
185
-		/** @var AuthMechanism */
186
-		$authMechanism = $storage->getAuthMechanism();
187
-		if ($backend->checkDependencies()) {
188
-			// invalid backend
189
-			return new DataResponse(
190
-				[
191
-					'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [
192
-						$backend->getIdentifier(),
193
-					]),
194
-				],
195
-				Http::STATUS_UNPROCESSABLE_ENTITY
196
-			);
197
-		}
183
+        /** @var Backend */
184
+        $backend = $storage->getBackend();
185
+        /** @var AuthMechanism */
186
+        $authMechanism = $storage->getAuthMechanism();
187
+        if ($backend->checkDependencies()) {
188
+            // invalid backend
189
+            return new DataResponse(
190
+                [
191
+                    'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [
192
+                        $backend->getIdentifier(),
193
+                    ]),
194
+                ],
195
+                Http::STATUS_UNPROCESSABLE_ENTITY
196
+            );
197
+        }
198 198
 
199
-		if (!$backend->isVisibleFor($this->service->getVisibilityType())) {
200
-			// not permitted to use backend
201
-			return new DataResponse(
202
-				[
203
-					'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [
204
-						$backend->getIdentifier(),
205
-					]),
206
-				],
207
-				Http::STATUS_UNPROCESSABLE_ENTITY
208
-			);
209
-		}
210
-		if (!$authMechanism->isVisibleFor($this->service->getVisibilityType())) {
211
-			// not permitted to use auth mechanism
212
-			return new DataResponse(
213
-				[
214
-					'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [
215
-						$authMechanism->getIdentifier(),
216
-					]),
217
-				],
218
-				Http::STATUS_UNPROCESSABLE_ENTITY
219
-			);
220
-		}
199
+        if (!$backend->isVisibleFor($this->service->getVisibilityType())) {
200
+            // not permitted to use backend
201
+            return new DataResponse(
202
+                [
203
+                    'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [
204
+                        $backend->getIdentifier(),
205
+                    ]),
206
+                ],
207
+                Http::STATUS_UNPROCESSABLE_ENTITY
208
+            );
209
+        }
210
+        if (!$authMechanism->isVisibleFor($this->service->getVisibilityType())) {
211
+            // not permitted to use auth mechanism
212
+            return new DataResponse(
213
+                [
214
+                    'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [
215
+                        $authMechanism->getIdentifier(),
216
+                    ]),
217
+                ],
218
+                Http::STATUS_UNPROCESSABLE_ENTITY
219
+            );
220
+        }
221 221
 
222
-		if (!$backend->validateStorage($storage)) {
223
-			// unsatisfied parameters
224
-			return new DataResponse(
225
-				[
226
-					'message' => (string)$this->l10n->t('Unsatisfied backend parameters'),
227
-				],
228
-				Http::STATUS_UNPROCESSABLE_ENTITY
229
-			);
230
-		}
231
-		if (!$authMechanism->validateStorage($storage)) {
232
-			// unsatisfied parameters
233
-			return new DataResponse(
234
-				[
235
-					'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters'),
236
-				],
237
-				Http::STATUS_UNPROCESSABLE_ENTITY
238
-			);
239
-		}
222
+        if (!$backend->validateStorage($storage)) {
223
+            // unsatisfied parameters
224
+            return new DataResponse(
225
+                [
226
+                    'message' => (string)$this->l10n->t('Unsatisfied backend parameters'),
227
+                ],
228
+                Http::STATUS_UNPROCESSABLE_ENTITY
229
+            );
230
+        }
231
+        if (!$authMechanism->validateStorage($storage)) {
232
+            // unsatisfied parameters
233
+            return new DataResponse(
234
+                [
235
+                    'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters'),
236
+                ],
237
+                Http::STATUS_UNPROCESSABLE_ENTITY
238
+            );
239
+        }
240 240
 
241
-		return null;
242
-	}
241
+        return null;
242
+    }
243 243
 
244
-	protected function manipulateStorageConfig(StorageConfig $storage) {
245
-		/** @var AuthMechanism */
246
-		$authMechanism = $storage->getAuthMechanism();
247
-		$authMechanism->manipulateStorageConfig($storage);
248
-		/** @var Backend */
249
-		$backend = $storage->getBackend();
250
-		$backend->manipulateStorageConfig($storage);
251
-	}
244
+    protected function manipulateStorageConfig(StorageConfig $storage) {
245
+        /** @var AuthMechanism */
246
+        $authMechanism = $storage->getAuthMechanism();
247
+        $authMechanism->manipulateStorageConfig($storage);
248
+        /** @var Backend */
249
+        $backend = $storage->getBackend();
250
+        $backend->manipulateStorageConfig($storage);
251
+    }
252 252
 
253
-	/**
254
-	 * Check whether the given storage is available / valid.
255
-	 *
256
-	 * Note that this operation can be time consuming depending
257
-	 * on whether the remote storage is available or not.
258
-	 *
259
-	 * @param StorageConfig $storage storage configuration
260
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
261
-	 */
262
-	protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) {
263
-		try {
264
-			$this->manipulateStorageConfig($storage);
253
+    /**
254
+     * Check whether the given storage is available / valid.
255
+     *
256
+     * Note that this operation can be time consuming depending
257
+     * on whether the remote storage is available or not.
258
+     *
259
+     * @param StorageConfig $storage storage configuration
260
+     * @param bool $testOnly whether to storage should only test the connection or do more things
261
+     */
262
+    protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) {
263
+        try {
264
+            $this->manipulateStorageConfig($storage);
265 265
 
266
-			/** @var Backend */
267
-			$backend = $storage->getBackend();
268
-			// update status (can be time-consuming)
269
-			$storage->setStatus(
270
-				\OCA\Files_External\MountConfig::getBackendStatus(
271
-					$backend->getStorageClass(),
272
-					$storage->getBackendOptions(),
273
-					false,
274
-					$testOnly
275
-				)
276
-			);
277
-		} catch (InsufficientDataForMeaningfulAnswerException $e) {
278
-			$status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE;
279
-			$storage->setStatus(
280
-				$status,
281
-				$this->l10n->t('Insufficient data: %s', [$e->getMessage()])
282
-			);
283
-		} catch (StorageNotAvailableException $e) {
284
-			$storage->setStatus(
285
-				$e->getCode(),
286
-				$this->l10n->t('%s', [$e->getMessage()])
287
-			);
288
-		} catch (\Exception $e) {
289
-			// FIXME: convert storage exceptions to StorageNotAvailableException
290
-			$storage->setStatus(
291
-				StorageNotAvailableException::STATUS_ERROR,
292
-				get_class($e) . ': ' . $e->getMessage()
293
-			);
294
-		}
295
-	}
266
+            /** @var Backend */
267
+            $backend = $storage->getBackend();
268
+            // update status (can be time-consuming)
269
+            $storage->setStatus(
270
+                \OCA\Files_External\MountConfig::getBackendStatus(
271
+                    $backend->getStorageClass(),
272
+                    $storage->getBackendOptions(),
273
+                    false,
274
+                    $testOnly
275
+                )
276
+            );
277
+        } catch (InsufficientDataForMeaningfulAnswerException $e) {
278
+            $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE;
279
+            $storage->setStatus(
280
+                $status,
281
+                $this->l10n->t('Insufficient data: %s', [$e->getMessage()])
282
+            );
283
+        } catch (StorageNotAvailableException $e) {
284
+            $storage->setStatus(
285
+                $e->getCode(),
286
+                $this->l10n->t('%s', [$e->getMessage()])
287
+            );
288
+        } catch (\Exception $e) {
289
+            // FIXME: convert storage exceptions to StorageNotAvailableException
290
+            $storage->setStatus(
291
+                StorageNotAvailableException::STATUS_ERROR,
292
+                get_class($e) . ': ' . $e->getMessage()
293
+            );
294
+        }
295
+    }
296 296
 
297
-	/**
298
-	 * Get all storage entries
299
-	 *
300
-	 * @return DataResponse
301
-	 */
302
-	public function index() {
303
-		$storages = $this->formatStoragesForUI($this->service->getStorages());
297
+    /**
298
+     * Get all storage entries
299
+     *
300
+     * @return DataResponse
301
+     */
302
+    public function index() {
303
+        $storages = $this->formatStoragesForUI($this->service->getStorages());
304 304
 
305
-		return new DataResponse(
306
-			$storages,
307
-			Http::STATUS_OK
308
-		);
309
-	}
305
+        return new DataResponse(
306
+            $storages,
307
+            Http::STATUS_OK
308
+        );
309
+    }
310 310
 
311
-	protected function formatStoragesForUI(array $storages): array {
312
-		return array_map(function ($storage) {
313
-			return $this->formatStorageForUI($storage);
314
-		}, $storages);
315
-	}
311
+    protected function formatStoragesForUI(array $storages): array {
312
+        return array_map(function ($storage) {
313
+            return $this->formatStorageForUI($storage);
314
+        }, $storages);
315
+    }
316 316
 
317
-	protected function formatStorageForUI(StorageConfig $storage): StorageConfig {
318
-		/** @var DefinitionParameter[] $parameters */
319
-		$parameters = array_merge($storage->getBackend()->getParameters(), $storage->getAuthMechanism()->getParameters());
317
+    protected function formatStorageForUI(StorageConfig $storage): StorageConfig {
318
+        /** @var DefinitionParameter[] $parameters */
319
+        $parameters = array_merge($storage->getBackend()->getParameters(), $storage->getAuthMechanism()->getParameters());
320 320
 
321
-		$options = $storage->getBackendOptions();
322
-		foreach ($options as $key => $value) {
323
-			foreach ($parameters as $parameter) {
324
-				if ($parameter->getName() === $key && $parameter->getType() === DefinitionParameter::VALUE_PASSWORD) {
325
-					$storage->setBackendOption($key, DefinitionParameter::UNMODIFIED_PLACEHOLDER);
326
-					break;
327
-				}
328
-			}
329
-		}
321
+        $options = $storage->getBackendOptions();
322
+        foreach ($options as $key => $value) {
323
+            foreach ($parameters as $parameter) {
324
+                if ($parameter->getName() === $key && $parameter->getType() === DefinitionParameter::VALUE_PASSWORD) {
325
+                    $storage->setBackendOption($key, DefinitionParameter::UNMODIFIED_PLACEHOLDER);
326
+                    break;
327
+                }
328
+            }
329
+        }
330 330
 
331
-		return $storage;
332
-	}
331
+        return $storage;
332
+    }
333 333
 
334
-	/**
335
-	 * Get an external storage entry.
336
-	 *
337
-	 * @param int $id storage id
338
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
339
-	 *
340
-	 * @return DataResponse
341
-	 */
342
-	public function show($id, $testOnly = true) {
343
-		try {
344
-			$storage = $this->service->getStorage($id);
334
+    /**
335
+     * Get an external storage entry.
336
+     *
337
+     * @param int $id storage id
338
+     * @param bool $testOnly whether to storage should only test the connection or do more things
339
+     *
340
+     * @return DataResponse
341
+     */
342
+    public function show($id, $testOnly = true) {
343
+        try {
344
+            $storage = $this->service->getStorage($id);
345 345
 
346
-			$this->updateStorageStatus($storage, $testOnly);
347
-		} catch (NotFoundException $e) {
348
-			return new DataResponse(
349
-				[
350
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]),
351
-				],
352
-				Http::STATUS_NOT_FOUND
353
-			);
354
-		}
346
+            $this->updateStorageStatus($storage, $testOnly);
347
+        } catch (NotFoundException $e) {
348
+            return new DataResponse(
349
+                [
350
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]),
351
+                ],
352
+                Http::STATUS_NOT_FOUND
353
+            );
354
+        }
355 355
 
356
-		$data = $this->formatStorageForUI($storage)->jsonSerialize();
357
-		$isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
358
-		$data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
356
+        $data = $this->formatStorageForUI($storage)->jsonSerialize();
357
+        $isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
358
+        $data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
359 359
 
360
-		return new DataResponse(
361
-			$data,
362
-			Http::STATUS_OK
363
-		);
364
-	}
360
+        return new DataResponse(
361
+            $data,
362
+            Http::STATUS_OK
363
+        );
364
+    }
365 365
 
366
-	/**
367
-	 * Deletes the storage with the given id.
368
-	 *
369
-	 * @param int $id storage id
370
-	 *
371
-	 * @return DataResponse
372
-	 */
373
-	public function destroy($id) {
374
-		try {
375
-			$this->service->removeStorage($id);
376
-		} catch (NotFoundException $e) {
377
-			return new DataResponse(
378
-				[
379
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]),
380
-				],
381
-				Http::STATUS_NOT_FOUND
382
-			);
383
-		}
366
+    /**
367
+     * Deletes the storage with the given id.
368
+     *
369
+     * @param int $id storage id
370
+     *
371
+     * @return DataResponse
372
+     */
373
+    public function destroy($id) {
374
+        try {
375
+            $this->service->removeStorage($id);
376
+        } catch (NotFoundException $e) {
377
+            return new DataResponse(
378
+                [
379
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]),
380
+                ],
381
+                Http::STATUS_NOT_FOUND
382
+            );
383
+        }
384 384
 
385
-		return new DataResponse([], Http::STATUS_NO_CONTENT);
386
-	}
385
+        return new DataResponse([], Http::STATUS_NO_CONTENT);
386
+    }
387 387
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Controller/UserStoragesController.php 1 patch
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -45,181 +45,181 @@
 block discarded – undo
45 45
  * User storages controller
46 46
  */
47 47
 class UserStoragesController extends StoragesController {
48
-	/**
49
-	 * Creates a new user storages controller.
50
-	 *
51
-	 * @param string $AppName application name
52
-	 * @param IRequest $request request object
53
-	 * @param IL10N $l10n l10n service
54
-	 * @param UserStoragesService $userStoragesService storage service
55
-	 * @param ILogger $logger
56
-	 * @param IUserSession $userSession
57
-	 * @param IGroupManager $groupManager
58
-	 */
59
-	public function __construct(
60
-		$AppName,
61
-		IRequest $request,
62
-		IL10N $l10n,
63
-		UserStoragesService $userStoragesService,
64
-		ILogger $logger,
65
-		IUserSession $userSession,
66
-		IGroupManager $groupManager
67
-	) {
68
-		parent::__construct(
69
-			$AppName,
70
-			$request,
71
-			$l10n,
72
-			$userStoragesService,
73
-			$logger,
74
-			$userSession,
75
-			$groupManager
76
-		);
77
-	}
78
-
79
-	protected function manipulateStorageConfig(StorageConfig $storage) {
80
-		/** @var AuthMechanism */
81
-		$authMechanism = $storage->getAuthMechanism();
82
-		$authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
83
-		/** @var Backend */
84
-		$backend = $storage->getBackend();
85
-		$backend->manipulateStorageConfig($storage, $this->userSession->getUser());
86
-	}
87
-
88
-	/**
89
-	 * Get all storage entries
90
-	 *
91
-	 * @NoAdminRequired
92
-	 *
93
-	 * @return DataResponse
94
-	 */
95
-	public function index() {
96
-		return parent::index();
97
-	}
98
-
99
-	/**
100
-	 * Return storage
101
-	 *
102
-	 * @NoAdminRequired
103
-	 *
104
-	 * {@inheritdoc}
105
-	 */
106
-	public function show($id, $testOnly = true) {
107
-		return parent::show($id, $testOnly);
108
-	}
109
-
110
-	/**
111
-	 * Create an external storage entry.
112
-	 *
113
-	 * @param string $mountPoint storage mount point
114
-	 * @param string $backend backend identifier
115
-	 * @param string $authMechanism authentication mechanism identifier
116
-	 * @param array $backendOptions backend-specific options
117
-	 * @param array $mountOptions backend-specific mount options
118
-	 *
119
-	 * @return DataResponse
120
-	 *
121
-	 * @NoAdminRequired
122
-	 */
123
-	public function create(
124
-		$mountPoint,
125
-		$backend,
126
-		$authMechanism,
127
-		$backendOptions,
128
-		$mountOptions
129
-	) {
130
-		$newStorage = $this->createStorage(
131
-			$mountPoint,
132
-			$backend,
133
-			$authMechanism,
134
-			$backendOptions,
135
-			$mountOptions
136
-		);
137
-		if ($newStorage instanceof DataResponse) {
138
-			return $newStorage;
139
-		}
140
-
141
-		$response = $this->validate($newStorage);
142
-		if (!empty($response)) {
143
-			return $response;
144
-		}
145
-
146
-		$newStorage = $this->service->addStorage($newStorage);
147
-		$this->updateStorageStatus($newStorage);
148
-
149
-		return new DataResponse(
150
-			$this->formatStorageForUI($newStorage),
151
-			Http::STATUS_CREATED
152
-		);
153
-	}
154
-
155
-	/**
156
-	 * Update an external storage entry.
157
-	 *
158
-	 * @param int $id storage id
159
-	 * @param string $mountPoint storage mount point
160
-	 * @param string $backend backend identifier
161
-	 * @param string $authMechanism authentication mechanism identifier
162
-	 * @param array $backendOptions backend-specific options
163
-	 * @param array $mountOptions backend-specific mount options
164
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
165
-	 *
166
-	 * @return DataResponse
167
-	 *
168
-	 * @NoAdminRequired
169
-	 */
170
-	public function update(
171
-		$id,
172
-		$mountPoint,
173
-		$backend,
174
-		$authMechanism,
175
-		$backendOptions,
176
-		$mountOptions,
177
-		$testOnly = true
178
-	) {
179
-		$storage = $this->createStorage(
180
-			$mountPoint,
181
-			$backend,
182
-			$authMechanism,
183
-			$backendOptions,
184
-			$mountOptions
185
-		);
186
-		if ($storage instanceof DataResponse) {
187
-			return $storage;
188
-		}
189
-		$storage->setId($id);
190
-
191
-		$response = $this->validate($storage);
192
-		if (!empty($response)) {
193
-			return $response;
194
-		}
195
-
196
-		try {
197
-			$storage = $this->service->updateStorage($storage);
198
-		} catch (NotFoundException $e) {
199
-			return new DataResponse(
200
-				[
201
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
202
-				],
203
-				Http::STATUS_NOT_FOUND
204
-			);
205
-		}
206
-
207
-		$this->updateStorageStatus($storage, $testOnly);
208
-
209
-		return new DataResponse(
210
-			$this->formatStorageForUI($storage),
211
-			Http::STATUS_OK
212
-		);
213
-	}
214
-
215
-	/**
216
-	 * Delete storage
217
-	 *
218
-	 * @NoAdminRequired
219
-	 *
220
-	 * {@inheritdoc}
221
-	 */
222
-	public function destroy($id) {
223
-		return parent::destroy($id);
224
-	}
48
+    /**
49
+     * Creates a new user storages controller.
50
+     *
51
+     * @param string $AppName application name
52
+     * @param IRequest $request request object
53
+     * @param IL10N $l10n l10n service
54
+     * @param UserStoragesService $userStoragesService storage service
55
+     * @param ILogger $logger
56
+     * @param IUserSession $userSession
57
+     * @param IGroupManager $groupManager
58
+     */
59
+    public function __construct(
60
+        $AppName,
61
+        IRequest $request,
62
+        IL10N $l10n,
63
+        UserStoragesService $userStoragesService,
64
+        ILogger $logger,
65
+        IUserSession $userSession,
66
+        IGroupManager $groupManager
67
+    ) {
68
+        parent::__construct(
69
+            $AppName,
70
+            $request,
71
+            $l10n,
72
+            $userStoragesService,
73
+            $logger,
74
+            $userSession,
75
+            $groupManager
76
+        );
77
+    }
78
+
79
+    protected function manipulateStorageConfig(StorageConfig $storage) {
80
+        /** @var AuthMechanism */
81
+        $authMechanism = $storage->getAuthMechanism();
82
+        $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
83
+        /** @var Backend */
84
+        $backend = $storage->getBackend();
85
+        $backend->manipulateStorageConfig($storage, $this->userSession->getUser());
86
+    }
87
+
88
+    /**
89
+     * Get all storage entries
90
+     *
91
+     * @NoAdminRequired
92
+     *
93
+     * @return DataResponse
94
+     */
95
+    public function index() {
96
+        return parent::index();
97
+    }
98
+
99
+    /**
100
+     * Return storage
101
+     *
102
+     * @NoAdminRequired
103
+     *
104
+     * {@inheritdoc}
105
+     */
106
+    public function show($id, $testOnly = true) {
107
+        return parent::show($id, $testOnly);
108
+    }
109
+
110
+    /**
111
+     * Create an external storage entry.
112
+     *
113
+     * @param string $mountPoint storage mount point
114
+     * @param string $backend backend identifier
115
+     * @param string $authMechanism authentication mechanism identifier
116
+     * @param array $backendOptions backend-specific options
117
+     * @param array $mountOptions backend-specific mount options
118
+     *
119
+     * @return DataResponse
120
+     *
121
+     * @NoAdminRequired
122
+     */
123
+    public function create(
124
+        $mountPoint,
125
+        $backend,
126
+        $authMechanism,
127
+        $backendOptions,
128
+        $mountOptions
129
+    ) {
130
+        $newStorage = $this->createStorage(
131
+            $mountPoint,
132
+            $backend,
133
+            $authMechanism,
134
+            $backendOptions,
135
+            $mountOptions
136
+        );
137
+        if ($newStorage instanceof DataResponse) {
138
+            return $newStorage;
139
+        }
140
+
141
+        $response = $this->validate($newStorage);
142
+        if (!empty($response)) {
143
+            return $response;
144
+        }
145
+
146
+        $newStorage = $this->service->addStorage($newStorage);
147
+        $this->updateStorageStatus($newStorage);
148
+
149
+        return new DataResponse(
150
+            $this->formatStorageForUI($newStorage),
151
+            Http::STATUS_CREATED
152
+        );
153
+    }
154
+
155
+    /**
156
+     * Update an external storage entry.
157
+     *
158
+     * @param int $id storage id
159
+     * @param string $mountPoint storage mount point
160
+     * @param string $backend backend identifier
161
+     * @param string $authMechanism authentication mechanism identifier
162
+     * @param array $backendOptions backend-specific options
163
+     * @param array $mountOptions backend-specific mount options
164
+     * @param bool $testOnly whether to storage should only test the connection or do more things
165
+     *
166
+     * @return DataResponse
167
+     *
168
+     * @NoAdminRequired
169
+     */
170
+    public function update(
171
+        $id,
172
+        $mountPoint,
173
+        $backend,
174
+        $authMechanism,
175
+        $backendOptions,
176
+        $mountOptions,
177
+        $testOnly = true
178
+    ) {
179
+        $storage = $this->createStorage(
180
+            $mountPoint,
181
+            $backend,
182
+            $authMechanism,
183
+            $backendOptions,
184
+            $mountOptions
185
+        );
186
+        if ($storage instanceof DataResponse) {
187
+            return $storage;
188
+        }
189
+        $storage->setId($id);
190
+
191
+        $response = $this->validate($storage);
192
+        if (!empty($response)) {
193
+            return $response;
194
+        }
195
+
196
+        try {
197
+            $storage = $this->service->updateStorage($storage);
198
+        } catch (NotFoundException $e) {
199
+            return new DataResponse(
200
+                [
201
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
202
+                ],
203
+                Http::STATUS_NOT_FOUND
204
+            );
205
+        }
206
+
207
+        $this->updateStorageStatus($storage, $testOnly);
208
+
209
+        return new DataResponse(
210
+            $this->formatStorageForUI($storage),
211
+            Http::STATUS_OK
212
+        );
213
+    }
214
+
215
+    /**
216
+     * Delete storage
217
+     *
218
+     * @NoAdminRequired
219
+     *
220
+     * {@inheritdoc}
221
+     */
222
+    public function destroy($id) {
223
+        return parent::destroy($id);
224
+    }
225 225
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Controller/UserGlobalStoragesController.php 1 patch
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -47,166 +47,166 @@
 block discarded – undo
47 47
  * User global storages controller
48 48
  */
49 49
 class UserGlobalStoragesController extends StoragesController {
50
-	/**
51
-	 * Creates a new user global storages controller.
52
-	 *
53
-	 * @param string $AppName application name
54
-	 * @param IRequest $request request object
55
-	 * @param IL10N $l10n l10n service
56
-	 * @param UserGlobalStoragesService $userGlobalStoragesService storage service
57
-	 * @param ILogger $logger
58
-	 * @param IUserSession $userSession
59
-	 * @param IGroupManager $groupManager
60
-	 */
61
-	public function __construct(
62
-		$AppName,
63
-		IRequest $request,
64
-		IL10N $l10n,
65
-		UserGlobalStoragesService $userGlobalStoragesService,
66
-		ILogger $logger,
67
-		IUserSession $userSession,
68
-		IGroupManager $groupManager
69
-	) {
70
-		parent::__construct(
71
-			$AppName,
72
-			$request,
73
-			$l10n,
74
-			$userGlobalStoragesService,
75
-			$logger,
76
-			$userSession,
77
-			$groupManager
78
-		);
79
-	}
80
-
81
-	/**
82
-	 * Get all storage entries
83
-	 *
84
-	 * @return DataResponse
85
-	 *
86
-	 * @NoAdminRequired
87
-	 */
88
-	public function index() {
89
-		$storages = $this->formatStoragesForUI($this->service->getUniqueStorages());
90
-
91
-		// remove configuration data, this must be kept private
92
-		foreach ($storages as $storage) {
93
-			$this->sanitizeStorage($storage);
94
-		}
95
-
96
-		return new DataResponse(
97
-			$storages,
98
-			Http::STATUS_OK
99
-		);
100
-	}
101
-
102
-	protected function manipulateStorageConfig(StorageConfig $storage) {
103
-		/** @var AuthMechanism */
104
-		$authMechanism = $storage->getAuthMechanism();
105
-		$authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
106
-		/** @var Backend */
107
-		$backend = $storage->getBackend();
108
-		$backend->manipulateStorageConfig($storage, $this->userSession->getUser());
109
-	}
110
-
111
-	/**
112
-	 * Get an external storage entry.
113
-	 *
114
-	 * @param int $id storage id
115
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
116
-	 * @return DataResponse
117
-	 *
118
-	 * @NoAdminRequired
119
-	 */
120
-	public function show($id, $testOnly = true) {
121
-		try {
122
-			$storage = $this->service->getStorage($id);
123
-
124
-			$this->updateStorageStatus($storage, $testOnly);
125
-		} catch (NotFoundException $e) {
126
-			return new DataResponse(
127
-				[
128
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
129
-				],
130
-				Http::STATUS_NOT_FOUND
131
-			);
132
-		}
133
-
134
-		$this->sanitizeStorage($storage);
135
-
136
-		$data = $this->formatStorageForUI($storage)->jsonSerialize();
137
-		$isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
138
-		$data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
139
-
140
-		return new DataResponse(
141
-			$data,
142
-			Http::STATUS_OK
143
-		);
144
-	}
145
-
146
-	/**
147
-	 * Update an external storage entry.
148
-	 * Only allows setting user provided backend fields
149
-	 *
150
-	 * @param int $id storage id
151
-	 * @param array $backendOptions backend-specific options
152
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
153
-	 *
154
-	 * @return DataResponse
155
-	 *
156
-	 * @NoAdminRequired
157
-	 */
158
-	public function update(
159
-		$id,
160
-		$backendOptions,
161
-		$testOnly = true
162
-	) {
163
-		try {
164
-			$storage = $this->service->getStorage($id);
165
-			$authMechanism = $storage->getAuthMechanism();
166
-			if ($authMechanism instanceof IUserProvided || $authMechanism instanceof  UserGlobalAuth) {
167
-				$authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions);
168
-				$authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
169
-			} else {
170
-				return new DataResponse(
171
-					[
172
-						'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id])
173
-					],
174
-					Http::STATUS_FORBIDDEN
175
-				);
176
-			}
177
-		} catch (NotFoundException $e) {
178
-			return new DataResponse(
179
-				[
180
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
181
-				],
182
-				Http::STATUS_NOT_FOUND
183
-			);
184
-		}
185
-
186
-		$this->updateStorageStatus($storage, $testOnly);
187
-		$this->sanitizeStorage($storage);
188
-
189
-		return new DataResponse(
190
-			$this->formatStorageForUI($storage),
191
-			Http::STATUS_OK
192
-		);
193
-	}
194
-
195
-	/**
196
-	 * Remove sensitive data from a StorageConfig before returning it to the user
197
-	 *
198
-	 * @param StorageConfig $storage
199
-	 */
200
-	protected function sanitizeStorage(StorageConfig $storage) {
201
-		$storage->setBackendOptions([]);
202
-		$storage->setMountOptions([]);
203
-
204
-		if ($storage->getAuthMechanism() instanceof IUserProvided) {
205
-			try {
206
-				$storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser());
207
-			} catch (InsufficientDataForMeaningfulAnswerException $e) {
208
-				// not configured yet
209
-			}
210
-		}
211
-	}
50
+    /**
51
+     * Creates a new user global storages controller.
52
+     *
53
+     * @param string $AppName application name
54
+     * @param IRequest $request request object
55
+     * @param IL10N $l10n l10n service
56
+     * @param UserGlobalStoragesService $userGlobalStoragesService storage service
57
+     * @param ILogger $logger
58
+     * @param IUserSession $userSession
59
+     * @param IGroupManager $groupManager
60
+     */
61
+    public function __construct(
62
+        $AppName,
63
+        IRequest $request,
64
+        IL10N $l10n,
65
+        UserGlobalStoragesService $userGlobalStoragesService,
66
+        ILogger $logger,
67
+        IUserSession $userSession,
68
+        IGroupManager $groupManager
69
+    ) {
70
+        parent::__construct(
71
+            $AppName,
72
+            $request,
73
+            $l10n,
74
+            $userGlobalStoragesService,
75
+            $logger,
76
+            $userSession,
77
+            $groupManager
78
+        );
79
+    }
80
+
81
+    /**
82
+     * Get all storage entries
83
+     *
84
+     * @return DataResponse
85
+     *
86
+     * @NoAdminRequired
87
+     */
88
+    public function index() {
89
+        $storages = $this->formatStoragesForUI($this->service->getUniqueStorages());
90
+
91
+        // remove configuration data, this must be kept private
92
+        foreach ($storages as $storage) {
93
+            $this->sanitizeStorage($storage);
94
+        }
95
+
96
+        return new DataResponse(
97
+            $storages,
98
+            Http::STATUS_OK
99
+        );
100
+    }
101
+
102
+    protected function manipulateStorageConfig(StorageConfig $storage) {
103
+        /** @var AuthMechanism */
104
+        $authMechanism = $storage->getAuthMechanism();
105
+        $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
106
+        /** @var Backend */
107
+        $backend = $storage->getBackend();
108
+        $backend->manipulateStorageConfig($storage, $this->userSession->getUser());
109
+    }
110
+
111
+    /**
112
+     * Get an external storage entry.
113
+     *
114
+     * @param int $id storage id
115
+     * @param bool $testOnly whether to storage should only test the connection or do more things
116
+     * @return DataResponse
117
+     *
118
+     * @NoAdminRequired
119
+     */
120
+    public function show($id, $testOnly = true) {
121
+        try {
122
+            $storage = $this->service->getStorage($id);
123
+
124
+            $this->updateStorageStatus($storage, $testOnly);
125
+        } catch (NotFoundException $e) {
126
+            return new DataResponse(
127
+                [
128
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
129
+                ],
130
+                Http::STATUS_NOT_FOUND
131
+            );
132
+        }
133
+
134
+        $this->sanitizeStorage($storage);
135
+
136
+        $data = $this->formatStorageForUI($storage)->jsonSerialize();
137
+        $isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
138
+        $data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
139
+
140
+        return new DataResponse(
141
+            $data,
142
+            Http::STATUS_OK
143
+        );
144
+    }
145
+
146
+    /**
147
+     * Update an external storage entry.
148
+     * Only allows setting user provided backend fields
149
+     *
150
+     * @param int $id storage id
151
+     * @param array $backendOptions backend-specific options
152
+     * @param bool $testOnly whether to storage should only test the connection or do more things
153
+     *
154
+     * @return DataResponse
155
+     *
156
+     * @NoAdminRequired
157
+     */
158
+    public function update(
159
+        $id,
160
+        $backendOptions,
161
+        $testOnly = true
162
+    ) {
163
+        try {
164
+            $storage = $this->service->getStorage($id);
165
+            $authMechanism = $storage->getAuthMechanism();
166
+            if ($authMechanism instanceof IUserProvided || $authMechanism instanceof  UserGlobalAuth) {
167
+                $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions);
168
+                $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
169
+            } else {
170
+                return new DataResponse(
171
+                    [
172
+                        'message' => (string)$this->l10n->t('Storage with ID "%d" is not user editable', [$id])
173
+                    ],
174
+                    Http::STATUS_FORBIDDEN
175
+                );
176
+            }
177
+        } catch (NotFoundException $e) {
178
+            return new DataResponse(
179
+                [
180
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
181
+                ],
182
+                Http::STATUS_NOT_FOUND
183
+            );
184
+        }
185
+
186
+        $this->updateStorageStatus($storage, $testOnly);
187
+        $this->sanitizeStorage($storage);
188
+
189
+        return new DataResponse(
190
+            $this->formatStorageForUI($storage),
191
+            Http::STATUS_OK
192
+        );
193
+    }
194
+
195
+    /**
196
+     * Remove sensitive data from a StorageConfig before returning it to the user
197
+     *
198
+     * @param StorageConfig $storage
199
+     */
200
+    protected function sanitizeStorage(StorageConfig $storage) {
201
+        $storage->setBackendOptions([]);
202
+        $storage->setMountOptions([]);
203
+
204
+        if ($storage->getAuthMechanism() instanceof IUserProvided) {
205
+            try {
206
+                $storage->getAuthMechanism()->manipulateStorageConfig($storage, $this->userSession->getUser());
207
+            } catch (InsufficientDataForMeaningfulAnswerException $e) {
208
+                // not configured yet
209
+            }
210
+        }
211
+    }
212 212
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Controller/GlobalStoragesController.php 1 patch
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -42,154 +42,154 @@
 block discarded – undo
42 42
  * Global storages controller
43 43
  */
44 44
 class GlobalStoragesController extends StoragesController {
45
-	/**
46
-	 * Creates a new global storages controller.
47
-	 *
48
-	 * @param string $AppName application name
49
-	 * @param IRequest $request request object
50
-	 * @param IL10N $l10n l10n service
51
-	 * @param GlobalStoragesService $globalStoragesService storage service
52
-	 * @param ILogger $logger
53
-	 * @param IUserSession $userSession
54
-	 * @param IGroupManager $groupManager
55
-	 */
56
-	public function __construct(
57
-		$AppName,
58
-		IRequest $request,
59
-		IL10N $l10n,
60
-		GlobalStoragesService $globalStoragesService,
61
-		ILogger $logger,
62
-		IUserSession $userSession,
63
-		IGroupManager $groupManager
64
-	) {
65
-		parent::__construct(
66
-			$AppName,
67
-			$request,
68
-			$l10n,
69
-			$globalStoragesService,
70
-			$logger,
71
-			$userSession,
72
-			$groupManager
73
-		);
74
-	}
45
+    /**
46
+     * Creates a new global storages controller.
47
+     *
48
+     * @param string $AppName application name
49
+     * @param IRequest $request request object
50
+     * @param IL10N $l10n l10n service
51
+     * @param GlobalStoragesService $globalStoragesService storage service
52
+     * @param ILogger $logger
53
+     * @param IUserSession $userSession
54
+     * @param IGroupManager $groupManager
55
+     */
56
+    public function __construct(
57
+        $AppName,
58
+        IRequest $request,
59
+        IL10N $l10n,
60
+        GlobalStoragesService $globalStoragesService,
61
+        ILogger $logger,
62
+        IUserSession $userSession,
63
+        IGroupManager $groupManager
64
+    ) {
65
+        parent::__construct(
66
+            $AppName,
67
+            $request,
68
+            $l10n,
69
+            $globalStoragesService,
70
+            $logger,
71
+            $userSession,
72
+            $groupManager
73
+        );
74
+    }
75 75
 
76
-	/**
77
-	 * Create an external storage entry.
78
-	 *
79
-	 * @param string $mountPoint storage mount point
80
-	 * @param string $backend backend identifier
81
-	 * @param string $authMechanism authentication mechanism identifier
82
-	 * @param array $backendOptions backend-specific options
83
-	 * @param array $mountOptions mount-specific options
84
-	 * @param array $applicableUsers users for which to mount the storage
85
-	 * @param array $applicableGroups groups for which to mount the storage
86
-	 * @param int $priority priority
87
-	 *
88
-	 * @return DataResponse
89
-	 */
90
-	public function create(
91
-		$mountPoint,
92
-		$backend,
93
-		$authMechanism,
94
-		$backendOptions,
95
-		$mountOptions,
96
-		$applicableUsers,
97
-		$applicableGroups,
98
-		$priority
99
-	) {
100
-		$newStorage = $this->createStorage(
101
-			$mountPoint,
102
-			$backend,
103
-			$authMechanism,
104
-			$backendOptions,
105
-			$mountOptions,
106
-			$applicableUsers,
107
-			$applicableGroups,
108
-			$priority
109
-		);
110
-		if ($newStorage instanceof DataResponse) {
111
-			return $newStorage;
112
-		}
76
+    /**
77
+     * Create an external storage entry.
78
+     *
79
+     * @param string $mountPoint storage mount point
80
+     * @param string $backend backend identifier
81
+     * @param string $authMechanism authentication mechanism identifier
82
+     * @param array $backendOptions backend-specific options
83
+     * @param array $mountOptions mount-specific options
84
+     * @param array $applicableUsers users for which to mount the storage
85
+     * @param array $applicableGroups groups for which to mount the storage
86
+     * @param int $priority priority
87
+     *
88
+     * @return DataResponse
89
+     */
90
+    public function create(
91
+        $mountPoint,
92
+        $backend,
93
+        $authMechanism,
94
+        $backendOptions,
95
+        $mountOptions,
96
+        $applicableUsers,
97
+        $applicableGroups,
98
+        $priority
99
+    ) {
100
+        $newStorage = $this->createStorage(
101
+            $mountPoint,
102
+            $backend,
103
+            $authMechanism,
104
+            $backendOptions,
105
+            $mountOptions,
106
+            $applicableUsers,
107
+            $applicableGroups,
108
+            $priority
109
+        );
110
+        if ($newStorage instanceof DataResponse) {
111
+            return $newStorage;
112
+        }
113 113
 
114
-		$response = $this->validate($newStorage);
115
-		if (!empty($response)) {
116
-			return $response;
117
-		}
114
+        $response = $this->validate($newStorage);
115
+        if (!empty($response)) {
116
+            return $response;
117
+        }
118 118
 
119
-		$newStorage = $this->service->addStorage($newStorage);
119
+        $newStorage = $this->service->addStorage($newStorage);
120 120
 
121
-		$this->updateStorageStatus($newStorage);
121
+        $this->updateStorageStatus($newStorage);
122 122
 
123
-		return new DataResponse(
124
-			$this->formatStorageForUI($newStorage),
125
-			Http::STATUS_CREATED
126
-		);
127
-	}
123
+        return new DataResponse(
124
+            $this->formatStorageForUI($newStorage),
125
+            Http::STATUS_CREATED
126
+        );
127
+    }
128 128
 
129
-	/**
130
-	 * Update an external storage entry.
131
-	 *
132
-	 * @param int $id storage id
133
-	 * @param string $mountPoint storage mount point
134
-	 * @param string $backend backend identifier
135
-	 * @param string $authMechanism authentication mechansim identifier
136
-	 * @param array $backendOptions backend-specific options
137
-	 * @param array $mountOptions mount-specific options
138
-	 * @param array $applicableUsers users for which to mount the storage
139
-	 * @param array $applicableGroups groups for which to mount the storage
140
-	 * @param int $priority priority
141
-	 * @param bool $testOnly whether to storage should only test the connection or do more things
142
-	 *
143
-	 * @return DataResponse
144
-	 */
145
-	public function update(
146
-		$id,
147
-		$mountPoint,
148
-		$backend,
149
-		$authMechanism,
150
-		$backendOptions,
151
-		$mountOptions,
152
-		$applicableUsers,
153
-		$applicableGroups,
154
-		$priority,
155
-		$testOnly = true
156
-	) {
157
-		$storage = $this->createStorage(
158
-			$mountPoint,
159
-			$backend,
160
-			$authMechanism,
161
-			$backendOptions,
162
-			$mountOptions,
163
-			$applicableUsers,
164
-			$applicableGroups,
165
-			$priority
166
-		);
167
-		if ($storage instanceof DataResponse) {
168
-			return $storage;
169
-		}
170
-		$storage->setId($id);
129
+    /**
130
+     * Update an external storage entry.
131
+     *
132
+     * @param int $id storage id
133
+     * @param string $mountPoint storage mount point
134
+     * @param string $backend backend identifier
135
+     * @param string $authMechanism authentication mechansim identifier
136
+     * @param array $backendOptions backend-specific options
137
+     * @param array $mountOptions mount-specific options
138
+     * @param array $applicableUsers users for which to mount the storage
139
+     * @param array $applicableGroups groups for which to mount the storage
140
+     * @param int $priority priority
141
+     * @param bool $testOnly whether to storage should only test the connection or do more things
142
+     *
143
+     * @return DataResponse
144
+     */
145
+    public function update(
146
+        $id,
147
+        $mountPoint,
148
+        $backend,
149
+        $authMechanism,
150
+        $backendOptions,
151
+        $mountOptions,
152
+        $applicableUsers,
153
+        $applicableGroups,
154
+        $priority,
155
+        $testOnly = true
156
+    ) {
157
+        $storage = $this->createStorage(
158
+            $mountPoint,
159
+            $backend,
160
+            $authMechanism,
161
+            $backendOptions,
162
+            $mountOptions,
163
+            $applicableUsers,
164
+            $applicableGroups,
165
+            $priority
166
+        );
167
+        if ($storage instanceof DataResponse) {
168
+            return $storage;
169
+        }
170
+        $storage->setId($id);
171 171
 
172
-		$response = $this->validate($storage);
173
-		if (!empty($response)) {
174
-			return $response;
175
-		}
172
+        $response = $this->validate($storage);
173
+        if (!empty($response)) {
174
+            return $response;
175
+        }
176 176
 
177
-		try {
178
-			$storage = $this->service->updateStorage($storage);
179
-		} catch (NotFoundException $e) {
180
-			return new DataResponse(
181
-				[
182
-					'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
183
-				],
184
-				Http::STATUS_NOT_FOUND
185
-			);
186
-		}
177
+        try {
178
+            $storage = $this->service->updateStorage($storage);
179
+        } catch (NotFoundException $e) {
180
+            return new DataResponse(
181
+                [
182
+                    'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
183
+                ],
184
+                Http::STATUS_NOT_FOUND
185
+            );
186
+        }
187 187
 
188
-		$this->updateStorageStatus($storage, $testOnly);
188
+        $this->updateStorageStatus($storage, $testOnly);
189 189
 
190
-		return new DataResponse(
191
-			$this->formatStorageForUI($storage),
192
-			Http::STATUS_OK
193
-		);
194
-	}
190
+        return new DataResponse(
191
+            $this->formatStorageForUI($storage),
192
+            Http::STATUS_OK
193
+        );
194
+    }
195 195
 }
Please login to merge, or discard this patch.