Do not overwrite __construct() in forms, there's init() for that purpose
refs #5525
This commit is contained in:
parent
c36e30af1e
commit
d260c3fb94
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue