mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 22:27:31 -04:00
Refactor getEncryptionModule routine
This commit is contained in:
parent
9f04a7c71e
commit
b344ff1a67
1 changed files with 13 additions and 17 deletions
|
|
@ -177,17 +177,15 @@ class Manager implements IManager {
|
|||
* @throws Exceptions\ModuleDoesNotExistsException
|
||||
*/
|
||||
public function getEncryptionModule($moduleId = '') {
|
||||
if (!empty($moduleId)) {
|
||||
if (isset($this->encryptionModules[$moduleId])) {
|
||||
return call_user_func($this->encryptionModules[$moduleId]['callback']);
|
||||
} else {
|
||||
$message = "Module with ID: $moduleId does not exist.";
|
||||
$hint = $this->l->t('Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator.', [$moduleId]);
|
||||
throw new Exceptions\ModuleDoesNotExistsException($message, $hint);
|
||||
}
|
||||
} else {
|
||||
if (empty($moduleId)) {
|
||||
return $this->getDefaultEncryptionModule();
|
||||
}
|
||||
if (isset($this->encryptionModules[$moduleId])) {
|
||||
return call_user_func($this->encryptionModules[$moduleId]['callback']);
|
||||
}
|
||||
$message = "Module with ID: $moduleId does not exist.";
|
||||
$hint = $this->l->t('Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator.', [$moduleId]);
|
||||
throw new Exceptions\ModuleDoesNotExistsException($message, $hint);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -198,17 +196,15 @@ class Manager implements IManager {
|
|||
*/
|
||||
protected function getDefaultEncryptionModule() {
|
||||
$defaultModuleId = $this->getDefaultEncryptionModuleId();
|
||||
if (!empty($defaultModuleId)) {
|
||||
if (isset($this->encryptionModules[$defaultModuleId])) {
|
||||
return call_user_func($this->encryptionModules[$defaultModuleId]['callback']);
|
||||
} else {
|
||||
$message = 'Default encryption module not loaded';
|
||||
throw new Exceptions\ModuleDoesNotExistsException($message);
|
||||
}
|
||||
} else {
|
||||
if (empty($defaultModuleId)) {
|
||||
$message = 'No default encryption module defined';
|
||||
throw new Exceptions\ModuleDoesNotExistsException($message);
|
||||
}
|
||||
if (isset($this->encryptionModules[$defaultModuleId])) {
|
||||
return call_user_func($this->encryptionModules[$defaultModuleId]['callback']);
|
||||
}
|
||||
$message = 'Default encryption module not loaded';
|
||||
throw new Exceptions\ModuleDoesNotExistsException($message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue