TestProvider.php in Geocoder 8.2
File
modules/geocoder_geofield/tests/modules/geocoder_geofield_test/src/Plugin/Geocoder/Provider/TestProvider.php
View source
<?php
namespace Drupal\geocoder_geofield_test\Plugin\Geocoder\Provider;
use Drupal\geocoder\ProviderBase;
use Geocoder\Model\AddressFactory;
class TestProvider extends ProviderBase {
protected $addressFactory;
protected function doGeocode($source) {
switch ($source) {
case 'Gotham City':
return $this
->getAddressFactory()
->createFromArray([
[
'latitude' => 20,
'longitude' => 40,
],
]);
default:
return FALSE;
}
}
public function doReverse($latitude, $longitude) {
return FALSE;
}
protected function getAddressFactory() {
if (!isset($this->addressFactory)) {
$this->addressFactory = new AddressFactory();
}
return $this->addressFactory;
}
}
Classes
Name |
Description |
TestProvider |
Provides a geocoding provider for testing purposes. |