You are here

class Provider in Geocoder 7.2

Hierarchy

Expanded class hierarchy of Provider

18 files declare their use of Provider
ArcGISOnline.php in src/Plugin/Geocoder/Provider/ArcGISOnline.php
The ArcGISOnline plugin.
BingMaps.php in src/Plugin/Geocoder/Provider/BingMaps.php
The BingMaps plugin.
File.php in src/Plugin/Geocoder/Provider/File.php
The File plugin.
FreeGeoIp.php in src/Plugin/Geocoder/Provider/FreeGeoIp.php
The FreeGeoIp plugin.
Geoip.php in src/Plugin/Geocoder/Provider/Geoip.php
The Geoip plugin.

... See full list

5 string references to 'Provider'
Geocoder::geocode in src/Geocoder.php
Geocode a string.
Geocoder::reverse in src/Geocoder.php
Reverse geocode coordinates.
geocoder_field_field_formatter_settings_form in modules/geocoder_field/geocoder_field.module
Implements hook_field_formatter_settings_form().
geocoder_field_field_widget_settings_form in modules/geocoder_field/geocoder_field.module
Implements hook_field_widget_settings_form().
geocoder_services_permission in modules/geocoder_services/geocoder_services.module
Implements hook_permission().

File

src/Plugin/Geocoder/Provider.php, line 16
Contains \Drupal\geocoder\Plugin\Geocoder\Provider.

Namespace

Drupal\geocoder\Plugin\Geocoder
View source
class Provider extends GeocoderPlugin implements ProviderInterface {

  /**
   * The messenger service.
   *
   * @var MessengerInterface
   */
  protected $messenger;

  /**
   * The loggerChannel service.
   *
   * @var LoggerChannelInterface
   */
  protected $loggerChannel;

  /**
   * @var HttpAdapterInterface
   */
  private $adapter;

  /**
   * @var \Geocoder\Provider\Provider
   */
  private $handler;

  /**
   * {@inheritdoc}
   */
  public function __construct($configuration, $plugin_id, $plugin_definition, HttpAdapterInterface $adapter, LoggerChannelInterface $logger_channel, MessengerInterface $messenger) {
    $this->loggerChannel = $logger_channel;
    $this->messenger = $messenger;
    $this->adapter = $adapter;
    parent::__construct($configuration, $plugin_id, $plugin_definition);
  }

  /**
   * The Geocoder Provider.
   *
   * @param \Geocoder\Provider\Provider $handler
   *   The Geocoder provider.
   *
   * @return ProviderInterface
   *   The plugin provider.
   */
  public function setHandler(\Geocoder\Provider\Provider $handler) {
    $this->handler = $handler;
    return $this;
  }

  /**
   * Get the Geocoder handler.
   *
   * @return \Geocoder\Provider\Provider
   */
  public function getHandler() {
    return $this->handler;
  }

  /**
   * Returns the HTTP adapter.
   *
   * @return HttpAdapterInterface
   */
  public function getAdapter() {
    return $this->adapter;
  }

  /**
   * {@inheritdoc}
   */
  public function geocode($data) {
    $cid = $this
      ->getCacheCid($data);
    if ($value = $this
      ->cache_get($cid)) {
      return $value;
    }
    try {
      $value = $this
        ->getHandler()
        ->geocode($data);
    } catch (\Exception $e) {
      throw $e;
    } catch (\InvalidCredentials $e) {
      throw $e;
    }
    $this
      ->cache_set($cid, $value);
    return $value;
  }

  /**
   * {@inheritdoc}
   */
  public function reverse($latitude, $longitude) {
    $cid = $this
      ->getCacheCid($latitude, $longitude);
    if ($value = $this
      ->cache_get($cid)) {
      return $value;
    }
    try {
      $value = $this
        ->getHandler()
        ->reverse($latitude, $longitude);
    } catch (\Exception $e) {
      throw $e;
    }
    $this
      ->cache_set($cid, $value);
    return $value;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GeocoderPlugin::cache_get public function Get a cache object based on the cache ID. Overrides GeocoderPluginInterface::cache_get
GeocoderPlugin::cache_set public function Stores data in the persistent cache. Overrides GeocoderPluginInterface::cache_set
GeocoderPlugin::getCacheCid public function Generates a cache ID based on the arguments. Overrides GeocoderPluginInterface::getCacheCid
GeocoderPlugin::getConfiguration public function Get the object's configuration. Overrides GeocoderPluginInterface::getConfiguration
GeocoderPlugin::init public function Init method launched after object initialization. Overrides GeocoderPluginInterface::init 18
GeocoderPlugin::setConfiguration public function Set the object's configuration. Overrides GeocoderPluginInterface::setConfiguration
Provider::$adapter private property
Provider::$handler private property
Provider::$loggerChannel protected property The loggerChannel service.
Provider::$messenger protected property The messenger service.
Provider::geocode public function Geocode data Overrides ProviderInterface::geocode 1
Provider::getAdapter public function Returns the HTTP adapter. Overrides ProviderInterface::getAdapter
Provider::getHandler public function Get the Geocoder handler. Overrides ProviderInterface::getHandler
Provider::reverse public function Reverse geocode latitude and longitude. Overrides ProviderInterface::reverse 1
Provider::setHandler public function The Geocoder Provider. Overrides ProviderInterface::setHandler
Provider::__construct public function GeocoderPlugin constructor. Overrides GeocoderPlugin::__construct