diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-11 18:45:07 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-19 10:05:11 +0100 |
commit | 37beb58c6f395523d8e2934870c5f52a8c6f6df0 (patch) | |
tree | b14325a790ddaf7236c3f8c1939ce9ef10df58bb /apps/files_external/lib/storageconfig.php | |
parent | 74237a9c44192fb98944ea7f3c14fa6f22c0814b (diff) | |
download | nextcloud-server-37beb58c6f395523d8e2934870c5f52a8c6f6df0.tar.gz nextcloud-server-37beb58c6f395523d8e2934870c5f52a8c6f6df0.zip |
Introduce BackendService for managing external storage backends
Backends are registered to the BackendService through new data
structures:
Backends are concrete classes, deriving from
\OCA\Files_External\Lib\Backend\Backend. During construction, the
various configuration parameters of the Backend can be set, in a design
similar to Symfony Console.
DefinitionParameter stores a parameter configuration for an external
storage: name of parameter, human-readable name, type of parameter
(text, password, hidden, checkbox), flags (optional or not).
Storages in the StoragesController now get their parameters validated
server-side (fixes a TODO).
Diffstat (limited to 'apps/files_external/lib/storageconfig.php')
-rw-r--r-- | apps/files_external/lib/storageconfig.php | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/apps/files_external/lib/storageconfig.php b/apps/files_external/lib/storageconfig.php index 92c27701d80..cf8271ff4eb 100644 --- a/apps/files_external/lib/storageconfig.php +++ b/apps/files_external/lib/storageconfig.php @@ -21,6 +21,8 @@ namespace OCA\Files_external\Lib; +use \OCA\Files_External\Lib\Backend\Backend; + /** * External storage configuration */ @@ -34,11 +36,11 @@ class StorageConfig implements \JsonSerializable { private $id; /** - * Backend class name + * Backend * - * @var string + * @var Backend */ - private $backendClass; + private $backend; /** * Backend options @@ -138,21 +140,17 @@ class StorageConfig implements \JsonSerializable { } /** - * Returns the external storage backend class name - * - * @return string external storage backend class name + * @return Backend */ - public function getBackendClass() { - return $this->backendClass; + public function getBackend() { + return $this->backend; } /** - * Sets the external storage backend class name - * - * @param string external storage backend class name + * @param Backend */ - public function setBackendClass($backendClass) { - $this->backendClass = $backendClass; + public function setBackend(Backend $backend) { + $this->backend= $backend; } /** @@ -174,6 +172,25 @@ class StorageConfig implements \JsonSerializable { } /** + * @param string $key + * @return mixed + */ + public function getBackendOption($key) { + if (isset($this->backendOptions[$key])) { + return $this->backendOptions[$key]; + } + return null; + } + + /** + * @param string $key + * @param mixed $value + */ + public function setBackendOption($key, $value) { + $this->backendOptions[$key] = $value; + } + + /** * Returns the mount priority * * @return int priority @@ -283,7 +300,7 @@ class StorageConfig implements \JsonSerializable { $result['id'] = $this->id; } $result['mountPoint'] = $this->mountPoint; - $result['backendClass'] = $this->backendClass; + $result['backendClass'] = $this->backend->getClass(); $result['backendOptions'] = $this->backendOptions; if (!is_null($this->priority)) { $result['priority'] = $this->priority; |