class FieldDiscovery implements FieldDiscoveryInterface (View source)

Provides field discovery for Drupal 6 & 7 migrations.

Properties

protected MigrateCckFieldPluginManagerInterface $cckPluginManager

The CCK plugin manager.

protected array $fieldPluginCache

An array of already discovered field plugin information.

protected MigrateFieldPluginManagerInterface $fieldPluginManager

The field plugin manager.

protected MigrationPluginManagerInterface $migrationPluginManager

The migration plugin manager.

protected LoggerInterface $logger

The logger channel service.

protected array $discoveredFieldsCache

A cache of discovered fields.

protected array $bundleKeys

An array of bundle keys, keyed by drupal core version.

protected array $sourcePluginIds

An array of source plugin ids, keyed by Drupal core version.

protected array $supportedCoreVersions

An array of supported Drupal core versions.

Methods

__construct(MigrateFieldPluginManagerInterface $field_plugin_manager, MigrationPluginManagerInterface $migration_plugin_manager, LoggerInterface $logger)

Constructs a FieldDiscovery object.

addAllFieldProcesses(MigrationInterface $migration)

Adds the field processes to a migration.

addEntityFieldProcesses(MigrationInterface $migration, string $entity_type_id)

Adds the field processes for an entity to a migration.

addBundleFieldProcesses(MigrationInterface $migration, string $entity_type_id, string $bundle)

Adds the field processes for a bundle to a migration.

getFieldPlugin(string $field_type, MigrationInterface $migration)

Returns the appropriate field plugin for a given field type.

array
getAllFields(string $core)

Gets all field information related to this migration.

array
getEntityFields(string $core, string $entity_type_id)

Gets all field information for a particular entity type.

array
getBundleFields(string $core, string $entity_type_id, string $bundle)

Gets all field information for a particular entity type and bundle.

getCckPluginManager()

Gets the deprecated CCK Plugin Manager service as a BC shim.

getSourcePlugin(string $core)

Gets the source plugin to use to gather field information.

array
getFieldInstanceStubMigrationDefinition(string $core)

Provides the stub migration definition for a given Drupal core version.

string|bool
getCoreVersion(MigrationInterface $migration)

Finds the core version of a Drupal migration.

Details

__construct(MigrateFieldPluginManagerInterface $field_plugin_manager, MigrationPluginManagerInterface $migration_plugin_manager, LoggerInterface $logger)

Constructs a FieldDiscovery object.

Parameters

MigrateFieldPluginManagerInterface $field_plugin_manager

The field plugin manager.

MigrationPluginManagerInterface $migration_plugin_manager

The migration plugin manager.

LoggerInterface $logger

The logger channel service.

addAllFieldProcesses(MigrationInterface $migration)

Adds the field processes to a migration.

This method is used in field migrations to execute the migration process alter method specified by the 'field_plugin_method' key of the migration for all field plugins applicable to this Drupal to Drupal migration. This method is used internally for field, field instance, widget, and formatter migrations to allow field plugins to alter the process for these migrations.

Parameters

MigrationInterface $migration

The migration to add process plugins to.

Exceptions

InvalidArgumentException

addEntityFieldProcesses(MigrationInterface $migration, string $entity_type_id)

Adds the field processes for an entity to a migration.

This method is used in field migrations to execute the migration process alter method specified by the 'field_plugin_method' key of the migration for all field plugins applicable to this Drupal to Drupal migration. This method is used internally for field, field instance, widget, and formatter migrations to allow field plugins to alter the process for these migrations.

Parameters

MigrationInterface $migration

The migration to add processes to.

string $entity_type_id

The legacy entity type to add processes for.

Exceptions

InvalidArgumentException

addBundleFieldProcesses(MigrationInterface $migration, string $entity_type_id, string $bundle)

Adds the field processes for a bundle to a migration.

Parameters

MigrationInterface $migration

The migration to add processes to.

string $entity_type_id

The legacy entity type to add processes for.

string $bundle

The legacy bundle (or content_type) to add processes for.

Exceptions

InvalidArgumentException

protected MigrateCckFieldInterface|MigrateFieldInterface|bool getFieldPlugin(string $field_type, MigrationInterface $migration)

Returns the appropriate field plugin for a given field type.

Parameters

string $field_type

The field type.

MigrationInterface $migration

The migration to retrieve the plugin for.

Return Value

MigrateCckFieldInterface|MigrateFieldInterface|bool

The appropriate field or cck plugin to process this field type.

Exceptions

PluginException
InvalidArgumentException

protected array getAllFields(string $core)

Gets all field information related to this migration.

Parameters

string $core

The Drupal core version to get fields for.

Return Value

array

A multidimensional array of source data from the relevant field instance migration, keyed first by entity type, then by bundle and finally by field name.

protected array getEntityFields(string $core, string $entity_type_id)

Gets all field information for a particular entity type.

Parameters

string $core

The Drupal core version.

string $entity_type_id

The legacy entity type ID.

Return Value

array

A multidimensional array of source data from the relevant field instance migration for the entity type, keyed first by bundle and then by field name.

protected array getBundleFields(string $core, string $entity_type_id, string $bundle)

Gets all field information for a particular entity type and bundle.

Parameters

string $core

The Drupal core version.

string $entity_type_id

The legacy entity type ID.

string $bundle

The legacy bundle (or content_type).

Return Value

array

An array of source data from the relevant field instance migration for the bundle, keyed by field name.

protected MigrateCckFieldPluginManagerInterface getCckPluginManager()

Gets the deprecated CCK Plugin Manager service as a BC shim.

We don't inject this service directly because it is deprecated, and we don't want to instantiate the plugin manager unless we have to, to avoid triggering deprecation errors.

Return Value

MigrateCckFieldPluginManagerInterface

The CCK Plugin Manager.

protected array|MigrateSourceInterface getSourcePlugin(string $core)

Gets the source plugin to use to gather field information.

Parameters

string $core

The Drupal core version.

Return Value

array|MigrateSourceInterface

The source plugin, or an empty array if none can be found that meets requirements.

protected array getFieldInstanceStubMigrationDefinition(string $core)

Provides the stub migration definition for a given Drupal core version.

Parameters

string $core

The Drupal core version.

Return Value

array

The stub migration definition.

protected string|bool getCoreVersion(MigrationInterface $migration)

Finds the core version of a Drupal migration.

Parameters

MigrationInterface $migration

The migration.

Return Value

string|bool

A string representation of the Drupal version, or FALSE.

Exceptions

InvalidArgumentException