Skip to content

Commit cd78254

Browse files
committed
ECS-310
1 parent eaa48c8 commit cd78254

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
@@ -144,7 +144,7 @@ public function getQueryLog(): Collection
144144
return $this->queryLog?->all() ?? new Collection();
145145
}
146146

147-
public static function fromConfig(array $config, mixed $handler = null): static
147+
public static function fromConfig(array $config): static
148148
{
149149
$builder = (new ClientBuilder())
150150
->setHosts($config['hosts'])
@@ -157,8 +157,8 @@ public static function fromConfig(array $config, mixed $handler = null): static
157157
$builder->setBasicAuthentication($username, $password);
158158
}
159159

160-
if (!is_null($handler)) {
161-
$builder->setHandler($handler);
160+
if (filled($config['handler'] ?? null)) {
161+
$builder->setHandler(call_user_func_array($config['handler'], []));
162162
}
163163

164164
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)