Skip to content

Commit eaa48c8

Browse files
committed
ECS-310
1 parent 138100d commit eaa48c8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/ElasticClient.php

Lines changed: 5 additions & 1 deletion
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): static
147+
public static function fromConfig(array $config, mixed $handler = null): static
148148
{
149149
$builder = (new ClientBuilder())
150150
->setHosts($config['hosts'])
@@ -157,6 +157,10 @@ public static function fromConfig(array $config): static
157157
$builder->setBasicAuthentication($username, $password);
158158
}
159159

160+
if (!is_null($handler)) {
161+
$builder->setHandler($handler);
162+
}
163+
160164
return new static($builder->build());
161165
}
162166

src/ElasticQueryServiceProvider.php

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

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

0 commit comments

Comments
 (0)