function FieldDiscovery::getSourcePlugin

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

Gets the source plugin to use to gather field information.

Parameters

string $core: The Drupal core version.

Return value

array|\Drupal\migrate\Plugin\MigrateSourceInterface The source plugin, or an empty array if none can be found that meets requirements.

2 calls to FieldDiscovery::getSourcePlugin()
FieldDiscovery::getAllFields in core/modules/migrate_drupal/src/FieldDiscovery.php
Gets all field information related to this migration.
FieldDiscoveryTestClass::getSourcePlugin in core/modules/migrate_drupal/tests/modules/field_discovery_test/src/FieldDiscoveryTestClass.php
Gets the source plugin to use to gather field information.
1 method overrides FieldDiscovery::getSourcePlugin()
FieldDiscoveryTestClass::getSourcePlugin in core/modules/migrate_drupal/tests/modules/field_discovery_test/src/FieldDiscoveryTestClass.php
Gets the source plugin to use to gather field information.

File

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

Class

FieldDiscovery
Provides field discovery for Drupal 6 & 7 migrations.

Namespace

Drupal\migrate_drupal

Code

protected function getSourcePlugin($core) {
    $definition = $this->getFieldInstanceStubMigrationDefinition($core);
    $source_plugin = $this->migrationPluginManager
        ->createStubMigration($definition)
        ->getSourcePlugin();
    if ($source_plugin instanceof RequirementsInterface) {
        try {
            $source_plugin->checkRequirements();
        } catch (RequirementsException $e) {
            // If checkRequirements() failed, the source database did not support
            // fields (i.e., Field is not installed in D7). Therefore, $fields will
            // be empty and below we'll return an empty array. The migration will
            // proceed without adding fields.
            $this->logger
                ->notice('Field discovery failed for Drupal core version @core. Did this site have the Field module installed? Error: @message', [
                '@core' => $core,
                '@message' => $e->getMessage(),
            ]);
            return [];
        }
    }
    return $source_plugin;
}

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