/** * Creates a StorageConfig instance based on array data * * @param array data * * @return StorageConfig storage config instance */ protected function makeStorageConfig($data) { $storage = new StorageConfig(); if (isset($data['id'])) { $storage->setId($data['id']); } $storage->setMountPoint($data['mountPoint']); $storage->setBackendClass($data['backendClass']); $storage->setBackendOptions($data['backendOptions']); if (isset($data['applicableUsers'])) { $storage->setApplicableUsers($data['applicableUsers']); } if (isset($data['applicableGroups'])) { $storage->setApplicableGroups($data['applicableGroups']); } if (isset($data['priority'])) { $storage->setPriority($data['priority']); } if (isset($data['mountOptions'])) { $storage->setMountOptions($data['mountOptions']); } return $storage; }
/** * Creates a StorageConfig instance based on array data * * @param array data * * @return StorageConfig storage config instance */ protected function makeStorageConfig($data) { $storage = new StorageConfig(); if (isset($data['id'])) { $storage->setId($data['id']); } $storage->setMountPoint($data['mountPoint']); if (!isset($data['backend'])) { // data providers are run before $this->backendService is initialised // so $data['backend'] can be specified directly $data['backend'] = $this->backendService->getBackend($data['backendIdentifier']); } if (!isset($data['backend'])) { throw new \Exception('oops, no backend'); } if (!isset($data['authMechanism'])) { $data['authMechanism'] = $this->backendService->getAuthMechanism($data['authMechanismIdentifier']); } if (!isset($data['authMechanism'])) { throw new \Exception('oops, no auth mechanism'); } $storage->setBackend($data['backend']); $storage->setAuthMechanism($data['authMechanism']); $storage->setBackendOptions($data['backendOptions']); if (isset($data['applicableUsers'])) { $storage->setApplicableUsers($data['applicableUsers']); } if (isset($data['applicableGroups'])) { $storage->setApplicableGroups($data['applicableGroups']); } if (isset($data['priority'])) { $storage->setPriority($data['priority']); } if (isset($data['mountOptions'])) { $storage->setMountOptions($data['mountOptions']); } return $storage; }
/** * Add new storage to the configuration * * @param StorageConfig $newStorage storage attributes * * @return StorageConfig storage config, with added id */ public function addStorage(StorageConfig $newStorage) { $allStorages = $this->readConfig(); $configId = $this->dbConfig->addMount($newStorage->getMountPoint(), $newStorage->getBackend()->getIdentifier(), $newStorage->getAuthMechanism()->getIdentifier(), $newStorage->getPriority(), $this->getType()); $newStorage->setId($configId); foreach ($newStorage->getApplicableUsers() as $user) { $this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_USER, $user); } foreach ($newStorage->getApplicableGroups() as $group) { $this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_GROUP, $group); } foreach ($newStorage->getBackendOptions() as $key => $value) { $this->dbConfig->setConfig($configId, $key, $value); } foreach ($newStorage->getMountOptions() as $key => $value) { $this->dbConfig->setOption($configId, $key, $value); } if (count($newStorage->getApplicableUsers()) === 0 && count($newStorage->getApplicableGroups()) === 0) { $this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_GLOBAL, null); } // add new storage $allStorages[$configId] = $newStorage; $this->triggerHooks($newStorage, Filesystem::signal_create_mount); $newStorage->setStatus(StorageNotAvailableException::STATUS_SUCCESS); return $newStorage; }
/** * Add new storage to the configuration * * @param array $newStorage storage attributes * * @return StorageConfig storage config, with added id */ public function addStorage(StorageConfig $newStorage) { $allStorages = $this->readConfig(); $configId = $this->generateNextId($allStorages); $newStorage->setId($configId); // add new storage $allStorages[$configId] = $newStorage; $this->writeConfig($allStorages); $this->triggerHooks($newStorage, Filesystem::signal_create_mount); $newStorage->setStatus(\OC_Mount_Config::STATUS_SUCCESS); return $newStorage; }