You are here

interface GeofieldProximitySourceInterface in Geofield 8

Defines an interface for Geofield Proximity Source plugins.

Hierarchy

Expanded class hierarchy of GeofieldProximitySourceInterface

All classes that implement GeofieldProximitySourceInterface

File

src/Plugin/GeofieldProximitySourceInterface.php, line 12

Namespace

Drupal\geofield\Plugin
View source
interface GeofieldProximitySourceInterface extends PluginInspectionInterface {

  /**
   * Check for a valid couple of latitude and longitude.
   *
   * @param float $lat
   *   The latitude value.
   * @param float $lon
   *   The longitude value.
   *
   * @return bool
   *   The flag indicates whether location is valid.
   *
   * @todo: add more tests, particularly around max/min values.
   */
  public function isValidLocation($lat, $lon);

  /**
   * Check if Location is empty.
   *
   * @param float $lat
   *   The latitude value.
   * @param float $lon
   *   The longitude value.
   *
   * @return bool
   *   The bool result.
   */
  public function isEmptyLocation($lat, $lon);

  /**
   * Builds the specific form elements for the geofield proximity plugin.
   *
   * @param array $form
   *   The form element to build.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state.
   * @param array $options_parents
   *   The values parents.
   * @param bool $is_exposed
   *   The check/differentiate if it is part of an exposed form.
   */
  public function buildOptionsForm(array &$form, FormStateInterface $form_state, array $options_parents, $is_exposed = FALSE);

  /**
   * Validates the options form for the geofield proximity plugin.
   *
   * @param array $form
   *   The form element to build.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state.
   * @param array $options_parents
   *   The values parents.
   */
  public function validateOptionsForm(array &$form, FormStateInterface $form_state, array $options_parents);

  /**
   * Set the units to perform the calculation in.
   *
   * @param string $units
   *   The name of the units constant to be used or string representation of it.
   */
  public function setUnits($units);

  /**
   * Get the current units.
   *
   * @return string
   *   The name of the units constant to be used or string representation of it.
   */
  public function getUnits();

  /**
   * Sets view handler which uses this proximity plugin.
   *
   * @param \Drupal\views\Plugin\views\HandlerBase $view_handler
   *   The view handler which uses this proximity plugin.
   */
  public function setViewHandler(HandlerBase $view_handler);

  /**
   * Get the calculated proximity.
   *
   * @param float $lat
   *   The current point latitude.
   * @param float $lon
   *   The current point longitude.
   *
   * @return float
   *   The calculated proximity.
   *
   * @throws \Drupal\geofield\Exception\InvalidPointException;
   *   If the proximity cannot be created, due to incorrect point coordinates
   *   definition.
   *
   * @throws \Drupal\geofield\Exception\ProximityUnavailableException;
   *   If any other case the proximity value cannot be created correctly.
   */
  public function getProximity($lat, $lon);

  /**
   * Gets the haversine options.
   *
   * @return array
   *   The haversine options.
   *
   * @throws \Drupal\geofield\Exception\HaversineUnavailableException;
   *   If the haversine is unavailable, due to incorrect setup definitions.
   */
  public function getHaversineOptions();

  /**
   * Gets the proximity distance origin.
   *
   * @return array
   *   The proximity distance origin.
   */
  public function getOrigin();

  /**
   * Sets the proximity distance origin.
   *
   * @param array $origin
   *   The proximity distance origin.
   */
  public function setOrigin(array $origin);

}

Members

Namesort descending Modifiers Type Description Overrides
GeofieldProximitySourceInterface::buildOptionsForm public function Builds the specific form elements for the geofield proximity plugin. 1
GeofieldProximitySourceInterface::getHaversineOptions public function Gets the haversine options. 1
GeofieldProximitySourceInterface::getOrigin public function Gets the proximity distance origin. 1
GeofieldProximitySourceInterface::getProximity public function Get the calculated proximity. 1
GeofieldProximitySourceInterface::getUnits public function Get the current units. 1
GeofieldProximitySourceInterface::isEmptyLocation public function Check if Location is empty. 1
GeofieldProximitySourceInterface::isValidLocation public function Check for a valid couple of latitude and longitude. 1
GeofieldProximitySourceInterface::setOrigin public function Sets the proximity distance origin. 1
GeofieldProximitySourceInterface::setUnits public function Set the units to perform the calculation in. 1
GeofieldProximitySourceInterface::setViewHandler public function Sets view handler which uses this proximity plugin. 1
GeofieldProximitySourceInterface::validateOptionsForm public function Validates the options form for the geofield proximity plugin. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2