public function ProximityArgument::getParsedReferenceLocation 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::getParsedReferenceLocation()
- 8 src/Plugin/views/argument/ProximityArgument.php \Drupal\geolocation\Plugin\views\argument\ProximityArgument::getParsedReferenceLocation()
Processes the passed argument into an array of relevant geolocation data.
Return value
array|bool The calculated values.
1 call to ProximityArgument::getParsedReferenceLocation()
- ProximityArgument::getFormula in src/
Plugin/ views/ argument/ ProximityArgument.php
2 methods override ProximityArgument::getParsedReferenceLocation()
- EntityArgument::getParsedReferenceLocation in src/
Plugin/ views/ argument/ EntityArgument.php - Processes the passed argument into an array of relevant geolocation data.
- GeocoderArgument::getParsedReferenceLocation in src/
Plugin/ views/ argument/ GeocoderArgument.php - Processes the passed argument into an array of relevant geolocation data.
File
- src/
Plugin/ views/ argument/ ProximityArgument.php, line 91
Class
- ProximityArgument
- Argument handler for geolocation proximity.
Namespace
Drupal\geolocation\Plugin\views\argumentCode
public function getParsedReferenceLocation() {
// Cache the vales so this only gets processed once.
static $values;
if (!isset($values)) {
// Process argument values into an array.
preg_match('/^([0-9\\-.]+),+([0-9\\-.]+)([<>=]+)([0-9.]+)(.*$)/', $this
->getValue(), $values);
// Validate and return the passed argument.
$values = is_array($values) ? [
'lat' => isset($values[1]) && is_numeric($values[1]) && $values[1] >= -90 && $values[1] <= 90 ? floatval($values[1]) : FALSE,
'lng' => isset($values[2]) && is_numeric($values[2]) && $values[2] >= -180 && $values[2] <= 180 ? floatval($values[2]) : FALSE,
'operator' => isset($values[3]) && in_array($values[3], [
'<>',
'=',
'>=',
'<=',
'>',
'<',
]) ? $values[3] : '<=',
'distance' => isset($values[4]) ? floatval($values[4]) : FALSE,
'unit' => isset($values[5]) ? $values[5] : 'km',
] : FALSE;
}
return $values;
}