You are here

GeocoderBase.php in Geolocation Field 8

Same filename and directory in other branches
  1. 8.3 src/GeocoderBase.php
  2. 8.2 src/GeocoderBase.php

Namespace

Drupal\geolocation

File

src/GeocoderBase.php
View source
<?php

namespace Drupal\geolocation;

use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Config\Config;

/**
 * Class GeocoderBase.
 *
 * @package Drupal\geolocation
 */
abstract class GeocoderBase extends PluginBase implements GeocoderInterface, ContainerFactoryPluginInterface {

  /**
   * Geolocation settings config instance.
   *
   * @var \Drupal\Core\Config\Config
   */
  protected $geolocationSettings;

  /**
   * Constructs a new GeocoderBase 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\Config $config
   *   The 'geolocation.settings' config.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, Config $config) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->geolocationSettings = $config;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('config.factory')
      ->get('geolocation.settings'));
  }

  /**
   * {@inheritdoc}
   */
  public function getOptionsForm() {
    return [
      '#type' => 'html_tag',
      '#tag' => 'span',
      '#value' => $this
        ->t('No settings available.'),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function processOptionsForm(array $form_element) {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function formAttachGeocoder(array &$render_array, $element_name) {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function formValidateInput(FormStateInterface $form_state) {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function formProcessInput(array &$input, $element_name) {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function geocode($address) {
    return NULL;
  }

}

Classes

Namesort descending Description
GeocoderBase Class GeocoderBase.