public function BoundaryArgument::getParsedBoundary in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/views/argument/BoundaryArgument.php \Drupal\geolocation\Plugin\views\argument\BoundaryArgument::getParsedBoundary()
Processes the passed argument into an array of relevant geolocation data.
Return value
array|bool The calculated values.
1 call to BoundaryArgument::getParsedBoundary()
- BoundaryArgument::query in src/
Plugin/ views/ argument/ BoundaryArgument.php - Set up the query for this argument.
File
- src/
Plugin/ views/ argument/ BoundaryArgument.php, line 72
Class
- BoundaryArgument
- Argument handler for geolocation boundary.
Namespace
Drupal\geolocation\Plugin\views\argumentCode
public function getParsedBoundary() {
// 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\\-.]+),+([0-9\\-.]+)(.*$)/', $this
->getValue(), $values);
// Validate and return the passed argument.
$values = is_array($values) ? [
'lat_north_east' => isset($values[1]) && is_numeric($values[1]) && $values[1] >= -90 && $values[1] <= 90 ? floatval($values[1]) : FALSE,
'lng_north_east' => isset($values[2]) && is_numeric($values[2]) && $values[2] >= -180 && $values[2] <= 180 ? floatval($values[2]) : FALSE,
'lat_south_west' => isset($values[2]) && is_numeric($values[3]) && $values[3] >= -90 && $values[3] <= 90 ? floatval($values[3]) : FALSE,
'lng_south_west' => isset($values[2]) && is_numeric($values[4]) && $values[4] >= -180 && $values[4] <= 180 ? floatval($values[4]) : FALSE,
] : FALSE;
}
return $values;
}