/**
* @param Configuration $config
* @param Connection\LdapConnectionInterface[] $connections
*/
public function __construct(Configuration $config, LdapConnectionInterface ...$connections)
{
$this->config = $config;
$this->domains = $config->getDomainConfiguration();
if (empty($this->domains) && empty($connections)) {
throw new \RuntimeException("Your configuration must have at least one domain.");
}
$this->registerAttributeConverters($config->getAttributeConverters());
// Pre-populate the connections array. They will be instantiated as needed.
foreach (array_keys($this->domains) as $domain) {
$this->connections[$domain] = null;
}
$this->addConnection(...$connections);
$this->context = array_keys($this->domains)[0];
if (!empty($this->config->getDefaultDomain())) {
$this->validateDomainName($this->config->getDefaultDomain());
$this->context = $this->config->getDefaultDomain();
}
}