create() public static method

public static create ( ) : Configuration
return Configuration
 /**
  * Builds a Client based on the connections given.
  *
  * @return ClientInterface
  */
 public function build()
 {
     $connectionManager = new ConnectionManager();
     foreach ($this->config['connections'] as $alias => $conn) {
         $config = isset($this->config['connections'][$alias]['config']) ? $this->config['connections'][$alias]['config'] : Configuration::create()->withTimeout($this->getDefaultTimeout());
         $connectionManager->registerConnection($alias, $conn['uri'], $config);
         if (isset($conn['is_master']) && $conn['is_master'] === true) {
             $connectionManager->setMaster($alias);
         }
     }
     $ev = null;
     if (isset($this->config['event_listeners'])) {
         $ev = new EventDispatcher();
         foreach ($this->config['event_listeners'] as $k => $callbacks) {
             foreach ($callbacks as $callback) {
                 $ev->addListener($k, $callback);
             }
         }
     }
     return new $this->config['client_class']($connectionManager, $ev);
 }
Esempio n. 2
0
 /**
  * @param string        $uri
  * @param Configuration $config
  */
 public function __construct($uri, ConfigInterface $config = null)
 {
     $this->uri = $uri;
     $this->config = null !== $config ? $config : Configuration::create();
 }