@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @throws Exception |
132 | 132 | */ |
133 | 133 | public function loadPlatform() { |
134 | - $this->connectToElastic($this->configService->getElasticHost()); |
|
134 | + $this->connectToElastic($this->configService->getElasticHost()); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
@@ -383,29 +383,29 @@ discard block |
||
383 | 383 | * @throws Exception |
384 | 384 | */ |
385 | 385 | private function connectToElastic(array $hosts): void { |
386 | - $hosts = array_map([$this, 'cleanHost'], $hosts); |
|
387 | - $cb = ClientBuilder::create() |
|
388 | - ->setHosts($hosts) |
|
389 | - ->setRetries(3); |
|
390 | - $this->configureAuthentication($cb, $hosts); |
|
391 | - |
|
392 | - $this->client = $cb->build(); |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * setBasicAuthentication() on ClientBuilder if available, using list of hosts |
|
397 | - */ |
|
398 | - private function configureAuthentication(ClientBuilder $cb, array $hosts): void { |
|
399 | - foreach ($hosts as $host) { |
|
400 | - $user = parse_url($host, PHP_URL_USER) ?? ''; |
|
401 | - $pass = parse_url($host, PHP_URL_PASS) ?? ''; |
|
402 | - |
|
403 | - if ($user !== '' || $pass !== '') { |
|
404 | - $cb->setBasicAuthentication($user, $pass); |
|
405 | - return; |
|
406 | - } |
|
407 | - } |
|
408 | - } |
|
386 | + $hosts = array_map([$this, 'cleanHost'], $hosts); |
|
387 | + $cb = ClientBuilder::create() |
|
388 | + ->setHosts($hosts) |
|
389 | + ->setRetries(3); |
|
390 | + $this->configureAuthentication($cb, $hosts); |
|
391 | + |
|
392 | + $this->client = $cb->build(); |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * setBasicAuthentication() on ClientBuilder if available, using list of hosts |
|
397 | + */ |
|
398 | + private function configureAuthentication(ClientBuilder $cb, array $hosts): void { |
|
399 | + foreach ($hosts as $host) { |
|
400 | + $user = parse_url($host, PHP_URL_USER) ?? ''; |
|
401 | + $pass = parse_url($host, PHP_URL_PASS) ?? ''; |
|
402 | + |
|
403 | + if ($user !== '' || $pass !== '') { |
|
404 | + $cb->setBasicAuthentication($user, $pass); |
|
405 | + return; |
|
406 | + } |
|
407 | + } |
|
408 | + } |
|
409 | 409 | |
410 | 410 | |
411 | 411 | /** |