You are here

ProviderUsingHandlerWithAdapterBase.php in Geocoder 8.3

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

Namespace

Drupal\geocoder

File

src/ProviderUsingHandlerWithAdapterBase.php
View source
<?php

namespace Drupal\geocoder;

use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Http\Client\HttpClient;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides a base class for providers using handlers with HTTP adapter.
 */
abstract class ProviderUsingHandlerWithAdapterBase extends ProviderUsingHandlerBase {

  /**
   * The HTTP adapter.
   *
   * @var \Http\Client\HttpClient
   */
  protected $httpAdapter;

  /**
   * Constructs a geocoder provider plugin object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory service.
   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
   *   The cache backend used to cache geocoding data.
   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
   *   The Drupal language manager service.
   * @param \Http\Client\HttpClient $http_adapter
   *   The HTTP adapter.
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, HttpClient $http_adapter) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $config_factory, $cache_backend, $language_manager);
    $this->httpAdapter = $http_adapter;
  }

  /**
   * {@inheritdoc}
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('config.factory'), $container
      ->get('cache.geocoder'), $container
      ->get('language_manager'), $container
      ->get('geocoder.http_adapter'));
  }

  /**
   * {@inheritdoc}
   */
  protected function getArguments() : array {
    return array_merge([
      $this->httpAdapter,
    ], parent::getArguments());
  }

}

Classes

Namesort descending Description
ProviderUsingHandlerWithAdapterBase Provides a base class for providers using handlers with HTTP adapter.