Prefer switch rather than if - elseif
This commit is contained in:
parent
1902b4f10f
commit
af898cc2b3
|
@ -233,25 +233,29 @@ class ConfigController extends BaseConfigController
|
||||||
|
|
||||||
$backendType = $this->getRequest()->getParam('type');
|
$backendType = $this->getRequest()->getParam('type');
|
||||||
$authenticationConfig = IcingaConfig::app('authentication')->toArray();
|
$authenticationConfig = IcingaConfig::app('authentication')->toArray();
|
||||||
if ($backendType === 'ldap') {
|
switch ($backendType) {
|
||||||
$form = new LdapBackendForm();
|
case 'ldap':
|
||||||
} else if ($backendType === 'db') {
|
$form = new LdapBackendForm();
|
||||||
$form = new DbBackendForm();
|
break;
|
||||||
} else if ($backendType === 'autologin') {
|
case 'db':
|
||||||
$existing = array_filter($authenticationConfig, function ($e) { return $e['backend'] === 'autologin'; });
|
$form = new DbBackendForm();
|
||||||
if (false === empty($existing)) {
|
break;
|
||||||
$this->addErrorMessage(
|
case 'autologin':
|
||||||
$this->translate('An autologin backend already exists')
|
$existing = array_filter($authenticationConfig, function ($e) { return $e['backend'] === 'autologin'; });
|
||||||
);
|
if (false === empty($existing)) {
|
||||||
|
$this->addErrorMessage(
|
||||||
|
$this->translate('An autologin backend already exists')
|
||||||
|
);
|
||||||
|
$this->redirectNow('config/configurationerror');
|
||||||
|
}
|
||||||
|
$form = new AutologinBackendForm();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->addErrorMessage(sprintf(
|
||||||
|
$this->translate('There is no backend type `%s\''),
|
||||||
|
$backendType
|
||||||
|
));
|
||||||
$this->redirectNow('config/configurationerror');
|
$this->redirectNow('config/configurationerror');
|
||||||
}
|
|
||||||
$form = new AutologinBackendForm();
|
|
||||||
} else {
|
|
||||||
$this->addErrorMessage(sprintf(
|
|
||||||
$this->translate('There is no backend type `%s\''),
|
|
||||||
$backendType
|
|
||||||
));
|
|
||||||
$this->redirectNow('config/configurationerror');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
Loading…
Reference in New Issue