You are here

HttpClientManagerFactory.php in HTTP Client Manager 8

Same filename and directory in other branches
  1. 8.2 src/HttpClientManagerFactory.php

File

src/HttpClientManagerFactory.php
View source
<?php

namespace Drupal\http_client_manager;

use Symfony\Component\DependencyInjection\ContainerAwareTrait;

/**
 * Class HttpClientManagerFactory.
 *
 * @package Drupal\http_client_manager
 */
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];
  }

}

Classes

Namesort descending Description
HttpClientManagerFactory Class HttpClientManagerFactory.