Cviebrock\LaravelElasticsearch\Manager::makeConnection PHP Method

makeConnection() protected method

Make a new connection.
protected makeConnection ( $name ) : Elasticsearch\Client | mixed
$name
return Elasticsearch\Client | mixed
    protected function makeConnection($name)
    {
        $config = $this->getConfig($name);
        return $this->factory->make($config);
    }

Usage Example

 /**
  * Make a new connection, and wrap the client in our handler Client.
  *
  * @param $name
  * @return \Elasticsearch\Client|mixed
  */
 protected function makeConnection($name)
 {
     // Create a base ES client for the connection.
     $baseClient = parent::makeConnection($name);
     // Find the base client wrapper class.
     $handlerClass = $this->getHandlerClass();
     // Load the handlers for this configuration.
     $handlers = $this->getConnectionHandlers($name);
     // Create a "wrapped" client passing in the appropriate configuration
     return new $handlerClass($baseClient, $handlers);
 }