You are here

class HttpClientManagerFactory in HTTP Client Manager 8

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

Class HttpClientManagerFactory.

@package Drupal\http_client_manager

Hierarchy

Expanded class hierarchy of HttpClientManagerFactory

1 file declares its use of HttpClientManagerFactory
HttpClientManagerFactoryTest.php in tests/src/Unit/HttpClientManagerFactoryTest.php
1 string reference to 'HttpClientManagerFactory'
http_client_manager.services.yml in ./http_client_manager.services.yml
http_client_manager.services.yml
1 service uses HttpClientManagerFactory
http_client_manager.factory in ./http_client_manager.services.yml
Drupal\http_client_manager\HttpClientManagerFactory

File

src/HttpClientManagerFactory.php, line 12

Namespace

Drupal\http_client_manager
View source
class HttpClientManagerFactory implements HttpClientManagerFactoryInterface {
  use ContainerAwareTrait;

  /**
   * An array of http clients.
   *
   * @var array
   */
  protected $clients = array();

  /**
   * {@inheritdoc}
   */
  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];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HttpClientManagerFactory::$clients protected property An array of http clients.
HttpClientManagerFactory::get public function Retrieves the registered http client for the requested service api. Overrides HttpClientManagerFactoryInterface::get