You are here

public function DummyGeocoderController::getGeocodedResults in Geolocation Field 8

Same name and namespace in other branches
  1. 8.3 tests/modules/geolocation_dummy_geocoder/src/Controller/DummyGeocoderController.php \Drupal\geolocation_dummy_geocoder\Controller\DummyGeocoderController::getGeocodedResults()
  2. 8.2 tests/modules/geolocation_dummy_geocoder/src/Controller/DummyGeocoderController.php \Drupal\geolocation_dummy_geocoder\Controller\DummyGeocoderController::getGeocodedResults()

Getgeocodedresults.

Parameters

string $address: Address to geocode.

Return value

\Symfony\Component\HttpFoundation\JsonResponse A JSON response containing autocomplete suggestions.

1 string reference to 'DummyGeocoderController::getGeocodedResults'
geolocation_dummy_geocoder.routing.yml in tests/modules/geolocation_dummy_geocoder/geolocation_dummy_geocoder.routing.yml
tests/modules/geolocation_dummy_geocoder/geolocation_dummy_geocoder.routing.yml

File

tests/modules/geolocation_dummy_geocoder/src/Controller/DummyGeocoderController.php, line 23

Class

DummyGeocoderController
Class DummyGeocoderController.

Namespace

Drupal\geolocation_dummy_geocoder\Controller

Code

public function getGeocodedResults($address = '') {
  if (empty($address)) {
    return new JsonResponse([]);
  }
  if (empty(Dummy::$targets[$address])) {
    return new JsonResponse([]);
  }
  return new JsonResponse([
    'location' => Dummy::$targets[$address],
  ]);
}