function MigrateFieldPluginManager::getPluginIdFromFieldType
Same name in other branches
- 8.9.x core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager::getPluginIdFromFieldType()
- 10 core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager::getPluginIdFromFieldType()
- 11.x core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager::getPluginIdFromFieldType()
Get the plugin ID from the field type.
This method determines which field plugin should be used for a given field type and Drupal core version, returning the lowest weighted plugin supporting the provided core version, and which matches the field type either by plugin ID, or in the type_map annotation keys.
Parameters
string $field_type: The field type being migrated.
array $configuration: (optional) An array of configuration relevant to the plugin instance.
\Drupal\migrate\Plugin\MigrationInterface $migration: (optional) The current migration instance.
Return value
string The ID of the plugin for the field type if available.
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException If the plugin cannot be determined, such as if the field type is invalid.
Overrides MigrateFieldPluginManagerInterface::getPluginIdFromFieldType
See also
\Drupal\migrate_drupal\Annotation\MigrateField
File
-
core/
modules/ migrate_drupal/ src/ Plugin/ MigrateFieldPluginManager.php, line 53
Class
- MigrateFieldPluginManager
- Plugin manager for migrate field plugins.
Namespace
Drupal\migrate_drupal\PluginCode
public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL) {
$core = static::DEFAULT_CORE_VERSION;
if (!empty($configuration['core'])) {
$core = $configuration['core'];
}
elseif (!empty($migration->getPluginDefinition()['migration_tags'])) {
foreach ($migration->getPluginDefinition()['migration_tags'] as $tag) {
if ($tag == 'Drupal 7') {
$core = 7;
}
}
}
$definitions = $this->getDefinitions();
foreach ($definitions as $plugin_id => $definition) {
if (in_array($core, $definition['core'])) {
if (array_key_exists($field_type, $definition['type_map']) || $field_type === $plugin_id) {
return $plugin_id;
}
}
}
throw new PluginNotFoundException($field_type);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.