3 namespace Drupal\migrate_drupal\Plugin;
5 use Drupal\Component\Plugin\Exception\PluginNotFoundException;
6 use Drupal\migrate\Plugin\MigratePluginManager;
7 use Drupal\migrate\Plugin\MigrationInterface;
10 * Plugin manager for migrate field plugins.
12 * @see \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
13 * @see \Drupal\migrate\Annotation\MigrateField
18 class MigrateFieldPluginManager extends MigratePluginManager implements MigrateFieldPluginManagerInterface {
21 * The default version of core to use for field plugins.
23 * These plugins were initially only built and used for Drupal 6 fields.
24 * Having been extended for Drupal 7 with a "core" annotation, we fall back to
25 * Drupal 6 where none exists.
27 const DEFAULT_CORE_VERSION = 6;
32 public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL) {
33 $core = static::DEFAULT_CORE_VERSION;
34 if (!empty($configuration['core'])) {
35 $core = $configuration['core'];
37 elseif (!empty($migration->getPluginDefinition()['migration_tags'])) {
38 foreach ($migration->getPluginDefinition()['migration_tags'] as $tag) {
39 if ($tag == 'Drupal 7') {
45 $definitions = $this->getDefinitions();
46 foreach ($definitions as $plugin_id => $definition) {
47 if (in_array($core, $definition['core'])) {
48 if (array_key_exists($field_type, $definition['type_map']) || $field_type === $plugin_id) {
53 throw new PluginNotFoundException($field_type);