Skip to content

Commit

Permalink
fix(bridge): Make sure the client config option is an array
Browse files Browse the repository at this point in the history
Refs: #187
  • Loading branch information
damienalexandre committed Jul 12, 2024
1 parent cd13b81 commit 5ed5b40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Bridge/Symfony/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ public function getConfigTreeBuilder(): TreeBuilder
->normalizeKeys(false)
->prototype('array')
->children()
->variableNode('client')
->arrayNode('client')
->info('All options for the Elastica client constructor')
->example([
'host' => '%env(ELASTICSEARCH_HOST)%',
'transport' => 'JoliCode\Elastically\Transport\HttpClientTransport',
])
->normalizeKeys(false)
->defaultValue([])
->prototype('variable')->end()
->end()
->scalarNode('mapping_directory')
->info('Path to the mapping directory (in YAML)')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private function buildConnection(string $name, array $config, bool $isDefaultCon
if (\array_key_exists('client', $config) && \array_key_exists('transport', $config['client'])) {
$config['client']['transport'] = new Reference($config['client']['transport']);
}
$client->replaceArgument('$config', $config['client']);
$client->replaceArgument('$config', $config['client'] ?? []);
$client->replaceArgument('$resultSetBuilder', new Reference("elastically.{$name}.result_set_builder"));
$client->replaceArgument('$indexNameMapper', new Reference("elastically.{$name}.index_name_mapper"));
$container->setDefinition($id = "elastically.{$name}.client", $client);
Expand Down

0 comments on commit 5ed5b40

Please sign in to comment.