LdapTools\Connection\LdapServerPool::setSelectionMethod PHP Method

setSelectionMethod() public method

Set the selection method for checking servers (ie. 'random', 'order').
public setSelectionMethod ( string $method )
$method string
    public function setSelectionMethod($method)
    {
        if (!defined('self::SELECT_' . strtoupper($method))) {
            throw new InvalidArgumentException(sprintf('Selection method "%s" is unknown.', $method));
        }
        $this->selectionMethod = strtolower($method);
    }

Usage Example

Beispiel #1
0
 /**
  * @param DomainConfiguration $config
  * @param EventDispatcherInterface $dispatcher
  * @param LdapLoggerInterface $logger
  */
 public function __construct(DomainConfiguration $config, EventDispatcherInterface $dispatcher = null, LdapLoggerInterface $logger = null)
 {
     $this->usernameFormatter = BindUserStrategy::getInstance($config);
     $this->serverPool = new LdapServerPool($config);
     $this->config = $config;
     $this->dispatcher = $dispatcher ?: new SymfonyEventDispatcher();
     $this->logger = $logger;
     $this->setupOperationInvoker();
     $this->serverPool->setSelectionMethod($config->getServerSelection());
     if (!$config->getLazyBind()) {
         $this->connect();
     }
 }