diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index de024c16e..d5fb1256c 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -20,19 +20,27 @@ class DbBackendForm extends BaseBackendForm */ protected $resources; - public function __construct() + /** + * Initialize this form + * + * Populates $this->resources. + * + * @throws ConfigurationError In case no database resources can be found + */ + public function init() { $dbResources = array_keys( ResourceFactory::getResourceConfigs('db')->toArray() ); + if (empty($dbResources)) { throw new ConfigurationError( t('There are no database resources') ); } - $this->resources = array_combine($dbResources, $dbResources); - parent::__construct(); + // array_combine() is necessary in order to use the array as select input data + $this->resources = array_combine($dbResources, $dbResources); } public function createElements(array $formData) diff --git a/application/forms/Config/Authentication/LdapBackendForm.php b/application/forms/Config/Authentication/LdapBackendForm.php index 07e4e6f65..d9039b8c0 100644 --- a/application/forms/Config/Authentication/LdapBackendForm.php +++ b/application/forms/Config/Authentication/LdapBackendForm.php @@ -21,19 +21,27 @@ class LdapBackendForm extends BaseBackendForm */ protected $resources; - public function __construct() + /** + * Initialize this form + * + * Populates $this->resources. + * + * @throws ConfigurationError In case no database resources can be found + */ + public function init() { $ldapResources = array_keys( ResourceFactory::getResourceConfigs('ldap')->toArray() ); + if (empty($ldapResources)) { throw new ConfigurationError( t('There are no LDAP resources') ); } - $this->resources = array_combine($ldapResources, $ldapResources); - parent::__construct(); + // array_combine() is necessary in order to use the array as select input data + $this->resources = array_combine($ldapResources, $ldapResources); } public function createElements(array $formData)