You are here

public function GeocoderFieldPluginManager::getPluginByFieldType in Geocoder 8.3

Same name and namespace in other branches
  1. 8.2 modules/geocoder_field/src/GeocoderFieldPluginManager.php \Drupal\geocoder_field\GeocoderFieldPluginManager::getPluginByFieldType()

Returns the first plugin that handles a specific field type.

Parameters

string $field_type: The type of field for which to find a plugin.

Return value

\Drupal\geocoder_field\GeocoderFieldPluginInterface|null The plugin instance or NULL, if no plugin handles this field type.

Throws

\Drupal\Component\Plugin\Exception\PluginException

File

modules/geocoder_field/src/GeocoderFieldPluginManager.php, line 108

Class

GeocoderFieldPluginManager
The Geocoder Field Plugin manager.

Namespace

Drupal\geocoder_field

Code

public function getPluginByFieldType($field_type) {
  foreach ($this
    ->getDefinitions() as $definition) {
    if (in_array($field_type, $definition['field_types'])) {

      /* @var \Drupal\geocoder_field\GeocoderFieldPluginInterface $geocoder_field_plugin */
      $geocoder_field_plugin = $this
        ->createInstance($definition['id']);
      return $geocoder_field_plugin;
    }
  }
  return NULL;
}