You are here

public function HttpClient::getClientConfig in HTTP Client Manager 8.2

1 call to HttpClient::getClientConfig()
HttpClient::setupGuzzleClient in src/HttpClient.php
Setup Guzzle Client from *.http_services_api.yml files.

File

src/HttpClient.php, line 217

Class

HttpClient
The http client.

Namespace

Drupal\http_client_manager

Code

public function getClientConfig() {
  $api = $this
    ->getApi();
  $config = !empty($api['config']) ? $api['config'] : [];
  $config['handler'] = HandlerStack::create();
  if (isset($config['debug']) && !is_bool($config['debug'])) {
    if ($debug_file = fopen($config['debug'], FILE_APPEND)) {
      $config['debug'] = $debug_file;
    }
    else {
      $message = $this
        ->t('HTTP Client Manager was unable to write to debug log file: @file', [
        '@file' => $config['debug'],
      ]);
      $this
        ->messenger()
        ->addWarning($message);
      $config['debug'] = FALSE;
    }
  }
  $event = new HttpClientHandlerStackEvent($config['handler'], $this->serviceApi);
  $this->eventDispatcher
    ->dispatch(HttpClientEvents::HANDLER_STACK, $event);
  return $config;
}