Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FieldDiscovery.php

function 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.

1 call to FieldDiscovery::getSourcePlugin()
FieldDiscovery::getAllFields in core/modules/migrate_drupal/src/FieldDiscovery.php
Gets all field information related to this migration.

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal