You are here

class HttpServiceApiWrapperFactory in HTTP Client Manager 8.2

Class HttpServiceApiWrapperFactory.

@package Drupal\http_client_manager

Hierarchy

Expanded class hierarchy of HttpServiceApiWrapperFactory

1 string reference to 'HttpServiceApiWrapperFactory'
http_client_manager.services.yml in ./http_client_manager.services.yml
http_client_manager.services.yml
1 service uses HttpServiceApiWrapperFactory
http_client_manager.api_wrapper.factory in ./http_client_manager.services.yml
Drupal\http_client_manager\HttpServiceApiWrapperFactory

File

src/HttpServiceApiWrapperFactory.php, line 12

Namespace

Drupal\http_client_manager
View source
class HttpServiceApiWrapperFactory implements HttpServiceApiWrapperFactoryInterface {

  /**
   * An array of HTTP Service Api Wrapper Services.
   *
   * @var \Drupal\http_client_manager\Plugin\HttpServiceApiWrapper\HttpServiceApiWrapperInterface[]
   */
  protected $apiWrappers;

  /**
   * HttpServiceApiWrapperFactory constructor.
   */
  public function __construct() {
    $this->apiWrappers = [];
  }

  /**
   * {@inheritdoc}
   */
  public function addApiWrapper(HttpServiceApiWrapperInterface $wrapper, $api) {
    $this->apiWrappers[$api] = $wrapper;
  }

  /**
   * {@inheritdoc}
   */
  public function get($name) {
    if (!isset($this->apiWrappers[$name])) {
      $message = sprintf('Cannot find an api wrapper with the name "%s', $name);
      throw new \InvalidArgumentException($message);
    }
    return $this->apiWrappers[$name];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HttpServiceApiWrapperFactory::$apiWrappers protected property An array of HTTP Service Api Wrapper Services.
HttpServiceApiWrapperFactory::addApiWrapper public function Add an HTTP Service API wrapper. Overrides HttpServiceApiWrapperFactoryInterface::addApiWrapper
HttpServiceApiWrapperFactory::get public function Get HTTP Service API wrapper. Overrides HttpServiceApiWrapperFactoryInterface::get
HttpServiceApiWrapperFactory::__construct public function HttpServiceApiWrapperFactory constructor.