You are here

public function HttpClientManagerFactory::get in HTTP Client Manager 8

Same name and namespace in other branches
  1. 8.2 src/HttpClientManagerFactory.php \Drupal\http_client_manager\HttpClientManagerFactory::get()

Retrieves the registered http client for the requested service api.

Parameters

string $service_api: The service api name.

Return value

\Drupal\http_client_manager\HttpClientInterface The registered http client for this service api.

Overrides HttpClientManagerFactoryInterface::get

File

src/HttpClientManagerFactory.php, line 25

Class

HttpClientManagerFactory
Class HttpClientManagerFactory.

Namespace

Drupal\http_client_manager

Code

public function get($service_api) {
  if (!isset($this->clients[$service_api])) {
    $apiHandler = $this->container
      ->get('http_client_manager.http_services_api');
    $eventDispatcher = $this->container
      ->get('event_dispatcher');
    $this->clients[$service_api] = new HttpClient($service_api, $apiHandler, $eventDispatcher);
  }
  return $this->clients[$service_api];
}