Inheritance: implements GraphAware\Common\Driver\ConfigInterface
Beispiel #1
0
 /**
  * @return Session
  */
 public function session()
 {
     $options = [];
     if (null !== $this->config->getTimeout()) {
         $options['timeout'] = $this->config->getTimeout();
     }
     if (null !== $this->config->getCurlInterface()) {
         $options['curl'][10062] = $this->config->getCurlInterface();
     }
     $options['curl'][74] = true;
     $options['curl'][75] = true;
     return new Session($this->uri, new Client($options), $this->config);
 }
 /**
  * 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);
 }