Elastica\Client::__construct PHP Метод

__construct() публичный Метод

Creates a new Elastica client.
public __construct ( array $config = [], callback $callback = null, Psr\Log\LoggerInterface $logger = null )
$config array OPTIONAL Additional config options
$callback callback OPTIONAL Callback function which can be used to be notified about errors (for example connection down)
$logger Psr\Log\LoggerInterface
    public function __construct(array $config = [], $callback = null, LoggerInterface $logger = null)
    {
        $this->_callback = $callback;
        if (!$logger && isset($config['log']) && $config['log']) {
            $logger = new Log($config['log']);
        }
        $this->_logger = $logger ?: new NullLogger();
        $this->setConfig($config);
        $this->_initConnections();
    }

Usage Example

Пример #1
0
 /**
  * Constructor. Appends the default index name to the config array, which by default
  * is `_all`
  *
  * @param array $config config options
  * @param callback $callback Callback function which can be used to be notified
  * about errors (for example connection down)
  */
 public function __construct(array $config = [], $callback = null)
 {
     $config += ['index' => '_all'];
     if (isset($config['name'])) {
         $this->configName = $config['name'];
     }
     parent::__construct($config, $callback);
 }
All Usage Examples Of Elastica\Client::__construct