public function ProximityArgument::getFormula in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/views/argument/ProximityArgument.php \Drupal\geolocation\Plugin\views\argument\ProximityArgument::getFormula()
- 8 src/Plugin/views/argument/ProximityArgument.php \Drupal\geolocation\Plugin\views\argument\ProximityArgument::getFormula()
Overrides Formula::getFormula
1 call to ProximityArgument::getFormula()
- ProximityArgument::query in src/
Plugin/ views/ argument/ ProximityArgument.php - Build the query based upon the formula
File
- src/
Plugin/ views/ argument/ ProximityArgument.php, line 38
Class
- ProximityArgument
- Argument handler for geolocation proximity.
Namespace
Drupal\geolocation\Plugin\views\argumentCode
public function getFormula() {
// Parse argument for reference location.
$values = $this
->getParsedReferenceLocation();
// Make sure we have enough information to start with.
if (!empty($values) && isset($values['lat']) && isset($values['lng']) && isset($values['distance'])) {
$distance = self::convertDistance((double) $values['distance'], $values['unit']);
// Build a formula for the where clause.
$formula = self::getProximityQueryFragment($this->tableAlias, $this->realField, $values['lat'], $values['lng']);
// Set the operator and value for the query.
$this->operator = $values['operator'];
$this->distance = $distance;
return !empty($formula) ? str_replace('***table***', $this->tableAlias, $formula) : FALSE;
}
else {
return FALSE;
}
}