You are here

public function Raw::getParsedInput in Search API Location 8

Returns the parsed user input.

Parameters

array $input: The text entered by the user, contains either "value" or "lat"+"lng" as keys.

Return value

mixed Returns a string with "latitude,longitude" if we can find a location. NULL otherwise.

Overrides LocationInputInterface::getParsedInput

File

src/Plugin/search_api_location/location_input/Raw.php, line 22

Class

Raw
Represents the Raw Location Input.

Namespace

Drupal\search_api_location\Plugin\search_api_location\location_input

Code

public function getParsedInput(array $input) {
  if (empty($input['value'])) {
    throw new \InvalidArgumentException('Input doesn\'t contain a location value.');
  }
  $input['value'] = trim($input['value']);
  return preg_match('/^[+-]?[0-9]+(?:\\.[0-9]+)?,[+-]?[0-9]+(?:\\.[0-9]+)?$/', $input['value']) ? $input['value'] : NULL;
}