public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->getConfig($this->defaults + $this->elasticaDefaults);
if (empty($config['connections'])) {
$config['connections']['default'] = Config\Helpers::merge(array_intersect_key($config, $this->connectionDefaults), $builder->expand($this->connectionDefaults));
} else {
foreach ($config['connections'] as $name => $connectionConfig) {
$config['connections'][$name] = Config\Helpers::merge($connectionConfig, $builder->expand($this->connectionDefaults));
}
}
// replace curl string options with their CURLOPT_ constant values
foreach ($config['connections'] as $name => $connectionConfig) {
$curlOptions = array();
foreach ($connectionConfig['config']['curl'] as $option => $value) {
if (!defined($constant = 'CURLOPT_' . strtoupper($option))) {
throw new Nette\InvalidArgumentException('There is no constant "' . $constant . '", therefore "' . $option . '" cannot be set.');
}
$curlOptions[constant($constant)] = $value;
}
$config['connections'][$name]['config']['curl'] = $curlOptions;
}
$elasticaConfig = array_intersect_key($config, $this->elasticaDefaults);
$elastica = $builder->addDefinition($this->prefix('elastica'))->setClass('Kdyby\\ElasticSearch\\Client', array($elasticaConfig));
if ($config['debugger']) {
$builder->addDefinition($this->prefix('panel'))->setClass('Kdyby\\ElasticSearch\\Diagnostics\\Panel');
$elastica->addSetup($this->prefix('@panel') . '::register', array('@self'));
}
}