You are here

public function ProximityField::query in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/views/field/ProximityField.php \Drupal\geolocation\Plugin\views\field\ProximityField::query()
  2. 8.2 src/Plugin/views/field/ProximityField.php \Drupal\geolocation\Plugin\views\field\ProximityField::query()

Called to add the field to a query.

Overrides FieldPluginBase::query

1 method overrides ProximityField::query()
GeoProximityField::query in modules/geolocation_geometry/src/Plugin/views/field/GeoProximityField.php
Called to add the field to a query.

File

src/Plugin/views/field/ProximityField.php, line 109

Class

ProximityField
Field handler for geolocation field.

Namespace

Drupal\geolocation\Plugin\views\field

Code

public function query() {

  /** @var \Drupal\views\Plugin\views\query\Sql $query */
  $query = $this->query;
  $center = $this
    ->getCenter();
  if (empty($center)) {
    return;
  }

  // Build the query expression.
  $expression = self::getProximityQueryFragment($this
    ->ensureMyTable(), $this->realField, $center['lat'], $center['lng']);

  // Get a placeholder for this query and save the field_alias for it.
  // Remove the initial ':' from the placeholder and avoid collision with
  // original field name.
  $this->field_alias = $query
    ->addField(NULL, $expression, substr($this
    ->placeholder(), 1));
}