Skip to content

Commit 72b0c7f

Browse files
committed
ECS-310
1 parent 6804cff commit 72b0c7f

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

config/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
'username' => env('ELASTICSEARCH_USERNAME', ''),
1212
'password' => env('ELASTICSEARCH_PASSWORD', ''),
1313
'ssl_verification' => env('ELASTICSEARCH_SSL_VERIFICATION', false),
14+
'handler' => null, // for call_user_func_array
1415
],
1516
];

src/ElasticClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function getQueryLog(): Collection
116116
return $this->queryLog?->all() ?? new Collection();
117117
}
118118

119-
public static function fromConfig(array $config, mixed $handler = null): static
119+
public static function fromConfig(array $config): static
120120
{
121121
$builder = (new ClientBuilder())
122122
->setHosts($config['hosts'])
@@ -127,8 +127,8 @@ public static function fromConfig(array $config, mixed $handler = null): static
127127
$builder->setBasicAuthentication($config['username'], $config['password'] ?? '');
128128
}
129129

130-
if (!is_null($handler)) {
131-
$builder->setHandler($handler);
130+
if (filled($config['handler'] ?? null)) {
131+
$builder->setHandler(call_user_func_array($config['handler'], []));
132132
}
133133

134134
return new static($builder->build());

src/ElasticQueryServiceProvider.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ public function register(): void
2929

3030
$this->app->singleton(
3131
ElasticClient::class,
32-
fn (Application $app) => ElasticClient::fromConfig($app['config']['laravel-elastic-query.connection'], $this->getElasticClientHandler())
32+
fn (Application $app) => ElasticClient::fromConfig($app['config']['laravel-elastic-query.connection'])
3333
);
3434
}
35-
36-
protected function getElasticClientHandler(): ?callable
37-
{
38-
return null;
39-
}
4035
}

0 commit comments

Comments
 (0)