You are here

public function GeofieldProximityField::getValue in Geofield 8

Gets the value that's supposed to be rendered.

This api exists so that other modules can easy set the values of the field without having the need to change the render method as well.

Parameters

\Drupal\views\ResultRow $values: An object containing all retrieved values.

string $field: Optional name of the field where the value is stored.

Overrides FieldPluginBase::getValue

1 call to GeofieldProximityField::getValue()
GeofieldProximityField::render in src/Plugin/views/field/GeofieldProximityField.php
Renders the field.

File

src/Plugin/views/field/GeofieldProximityField.php, line 133

Class

GeofieldProximityField
Field handler to render a Geofield proximity in Views.

Namespace

Drupal\geofield\Plugin\views\field

Code

public function getValue(ResultRow $values, $field = NULL) {
  try {
    $this->sourcePlugin = $this->proximitySourceManager
      ->createInstance($this->options['source'], $this->options['source_configuration']);
    $this->sourcePlugin
      ->setViewHandler($this);
    $this->sourcePlugin
      ->setUnits($this->options['units']);
    return $this->sourcePlugin
      ->getProximity($values->{$this->aliases['latitude']}, $values->{$this->aliases['longitude']});
  } catch (\Exception $e) {
    watchdog_exception('geofield', $e);
    return NULL;
  }
}