Fix double constructor

This commit is contained in:
Joel Bout 2015-12-21 15:07:34 +01:00
parent 2ca812159d
commit ae186f3bf5

View File

@ -82,17 +82,6 @@ class LdapAdapter implements LoginAdapter
$this->adapter = new Ldap(); $this->adapter = new Ldap();
} }
/**
* @param array $configuration
*/
public function __construct(array $configuration) {
$this->configuration = $configuration;
$this->adapter = new Ldap();
$this->adapter->setOptions($configuration['config']);
}
public function setOptions(array $options) { public function setOptions(array $options) {
$this->configuration = $options; $this->configuration = $options;
$this->adapter->setOptions($options['config']); $this->adapter->setOptions($options['config']);
@ -101,7 +90,11 @@ class LdapAdapter implements LoginAdapter
public function getOption($name) { public function getOption($name) {
return $this->configuration[$name]; return $this->configuration[$name];
} }
public function hasOption($name) {
return isset($this->configuration[$name]);
}
/** /**
* Set the credential * Set the credential
* *
@ -127,7 +120,10 @@ class LdapAdapter implements LoginAdapter
$result = $adapter->getAccountObject(); $result = $adapter->getAccountObject();
$params = get_object_vars($result); $params = get_object_vars($result);
$factory = new LdapUserFactory($this->getOption(self::OPTION_USER_MAPPING)); $mapping = $this->hasOption(self::OPTION_USER_MAPPING)
? $this->getOption(self::OPTION_USER_MAPPING)
: array();
$factory = new LdapUserFactory($mapping);
$user = $factory->createUser($params); $user = $factory->createUser($params);
return $user; return $user;