public function GeocoderCountryFormattingManager::getCountry in Geolocation Field 8.3
Same name and namespace in other branches
- 8.2 src/GeocoderCountryFormattingManager.php \Drupal\geolocation\GeocoderCountryFormattingManager::getCountry()
Return Country plugin by country code.
Parameters
string $country_code: Plugin ID.
string $geocoder_id: Geocoder ID.
Return value
\Drupal\geolocation\GeocoderCountryFormattingInterface|false Geocoder instance.
File
- src/
GeocoderCountryFormattingManager.php, line 42
Class
- GeocoderCountryFormattingManager
- Search plugin manager.
Namespace
Drupal\geolocationCode
public function getCountry($country_code, $geocoder_id) {
$country_code = strtolower($country_code);
foreach ($this
->getDefinitions() as $plugin_id => $definition) {
if (isset($definition['country_code']) && $definition['country_code'] == $country_code && $definition['geocoder'] == $geocoder_id) {
$instance = $this
->createInstance($plugin_id);
break;
}
}
if (empty($instance) && $this
->hasDefinition($geocoder_id . '_standard')) {
$instance = $this
->createInstance($geocoder_id . '_standard');
}
/** @var \Drupal\geolocation\GeocoderCountryFormattingInterface $instance */
return $instance;
}