function FieldDiscovery::getFieldPlugin

Same name in other branches
  1. 9 core/modules/migrate_drupal/src/FieldDiscovery.php \Drupal\migrate_drupal\FieldDiscovery::getFieldPlugin()
  2. 8.9.x core/modules/migrate_drupal/src/FieldDiscovery.php \Drupal\migrate_drupal\FieldDiscovery::getFieldPlugin()
  3. 11.x core/modules/migrate_drupal/src/FieldDiscovery.php \Drupal\migrate_drupal\FieldDiscovery::getFieldPlugin()

Returns the appropriate field plugin for a given field type.

Parameters

string $field_type: The field type.

\Drupal\migrate\Plugin\MigrationInterface $migration: The migration to retrieve the plugin for.

Return value

\Drupal\migrate_drupal\Plugin\MigrateFieldInterface|bool The appropriate field plugin to process this field type.

Throws

\Drupal\Component\Plugin\Exception\PluginException

\InvalidArgumentException

2 calls to FieldDiscovery::getFieldPlugin()
FieldDiscovery::addBundleFieldProcesses in core/modules/migrate_drupal/src/FieldDiscovery.php
FieldDiscoveryTestClass::getFieldPlugin in core/modules/migrate_drupal/tests/modules/field_discovery_test/src/FieldDiscoveryTestClass.php
Returns the appropriate field plugin for a given field type.
1 method overrides FieldDiscovery::getFieldPlugin()
FieldDiscoveryTestClass::getFieldPlugin in core/modules/migrate_drupal/tests/modules/field_discovery_test/src/FieldDiscoveryTestClass.php
Returns the appropriate field plugin for a given field type.

File

core/modules/migrate_drupal/src/FieldDiscovery.php, line 180

Class

FieldDiscovery
Provides field discovery for Drupal 6 & 7 migrations.

Namespace

Drupal\migrate_drupal

Code

protected function getFieldPlugin($field_type, MigrationInterface $migration) {
    $core = $this->getCoreVersion($migration);
    if (!isset($this->fieldPluginCache[$core][$field_type])) {
        try {
            $plugin_id = $this->fieldPluginManager
                ->getPluginIdFromFieldType($field_type, [
                'core' => $core,
            ], $migration);
            $plugin = $this->fieldPluginManager
                ->createInstance($plugin_id, [
                'core' => $core,
            ], $migration);
        } catch (PluginNotFoundException $ex) {
            $plugin = FALSE;
        }
        $this->fieldPluginCache[$core][$field_type] = $plugin;
    }
    return $this->fieldPluginCache[$core][$field_type];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.