You are here

class GeocoderPlugin in Geocoder 7.2

Same name in this branch
  1. 7.2 src/Annotation/GeocoderPlugin.php \Drupal\geocoder\Annotation\GeocoderPlugin
  2. 7.2 src/Plugin/GeocoderPlugin.php \Drupal\geocoder\Plugin\GeocoderPlugin

Hierarchy

Expanded class hierarchy of GeocoderPlugin

2 files declare their use of GeocoderPlugin
Dumper.php in src/Plugin/Geocoder/Dumper.php
Contains \Drupal\geocoder\Plugin\Geocoder\Dumper.
Provider.php in src/Plugin/Geocoder/Provider.php
Contains \Drupal\geocoder\Plugin\Geocoder\Provider.

File

src/Plugin/GeocoderPlugin.php, line 13
Contains \Drupal\geocoder\Plugin\GeocoderPlugin.

Namespace

Drupal\geocoder\Plugin
View source
class GeocoderPlugin extends PluginBase implements GeocoderPluginInterface {

  /**
   * GeocoderPlugin constructor.
   *
   * @param array $configuration
   * @param string $plugin_id
   * @param mixed $plugin_definition
   */
  public function __construct($configuration, $plugin_id, $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this
      ->init();
  }

  /**
   * {@inheritdoc}
   */
  public function init() {
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setConfiguration(array $configuration = array()) {
    if (!empty($configuration)) {
      $this->configuration = $configuration;
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getConfiguration() {
    return $this->configuration;
  }

  /**
   * {@inheritdoc}
   */
  public function cache_get($cid) {
    if ((bool) Config::get('geocoder.cache', TRUE)) {
      if ($cache = cache_get($cid, 'cache_geocoder')) {
        return $cache->data;
      }
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function cache_set($cid, $data) {
    if ((bool) Config::get('geocoder.cache', TRUE)) {
      cache_set($cid, $data, 'cache_geocoder', CACHE_PERMANENT);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheCid() {
    $args = func_get_args();
    $args[] = $this
      ->getPluginId();
    $args[] = $this
      ->getConfiguration();
    return sha1(serialize(array_filter($args)));
  }

}

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
GeocoderPlugin::__construct public function GeocoderPlugin constructor. 1