, parameters:array}> * available backends, to build the settings form from */ public function describeBackends(): array { $result = []; foreach ($this->backends->getAvailableBackends() as $backend) { $result[] = [ 'id' => $backend->getIdentifier(), 'name' => $backend->getText(), 'auth' => array_keys($backend->getAuthSchemes()), 'parameters' => array_map(fn ($p) => $p->jsonSerialize(), $backend->getParameters()), ]; } return $result; } /** * @param array $options backend and auth options (e.g. host, bucket, key, secret) * @param IUser|null $admin user for auth mechanisms that need one (password/session-based ones are not supported) */ public function create(string $backendId, string $authId, array $options, ?IUser $admin = null): IStorage { $backend = $this->backends->getBackend($backendId); $auth = $this->backends->getAuthMechanism($authId); if ($backend === null || $auth === null) { throw new BackendException("Unknown storage backend or auth mechanism: $backendId / $authId"); } if (!in_array($auth->getScheme(), array_keys($backend->getAuthSchemes()), true)) { throw new BackendException("Auth mechanism $authId does not fit backend $backendId"); } $config = new StorageConfig(); $config->setBackend($backend); $config->setAuthMechanism($auth); $config->setBackendOptions($options); $config->setMountPoint('/ng_backup'); // never mounted, but some code expects a value $auth->manipulateStorageConfig($config, $admin); $backend->manipulateStorageConfig($config, $admin); $class = $backend->getStorageClass(); $storage = new $class($config->getBackendOptions()); $storage = $backend->wrapStorage($storage); return $auth->wrapStorage($storage); } }