interface MigrateDestinationInterface implements PluginInspectionInterface (View source)

Defines an interface for Migration Destination classes.

Destinations are responsible for persisting source data into the destination Drupal.

Methods

string
getPluginId()

Gets the plugin_id of the plugin instance.

array
getPluginDefinition()

Gets the definition of the plugin implementation.

array[]
getIds()

Gets the destination IDs.

array
fields()

Returns an array of destination fields.

array|bool
import(Row $row, array $old_destination_id_values = [])

Import the row.

rollback(array $destination_identifier)

Delete the specified destination object from the target Drupal.

bool
supportsRollback()

Whether the destination can be rolled back or not.

int
rollbackAction()

The rollback action for the last imported item.

string|null
getDestinationModule()

Gets the destination module handling the destination data.

Details

string getPluginId()

Gets the plugin_id of the plugin instance.

Return Value

string

The plugin_id of the plugin instance.

array getPluginDefinition()

Gets the definition of the plugin implementation.

Return Value

array

The plugin definition, as returned by the discovery object used by the plugin manager.

array[] getIds()

Gets the destination IDs.

To support MigrateIdMap maps, derived destination classes should return field definition(s) corresponding to the primary key of the destination being implemented. These are used to construct the destination key fields of the map table for a migration using this destination.

Return Value

array[]

An associative array of field definitions keyed by field ID. Values are associative arrays with a structure that contains the field type ('type' key). The other keys are the field storage settings as they are returned by FieldStorageDefinitionInterface::getSettings(). As an example, for a composite destination primary key that is defined by an integer and a string, the returned value might look like: @code return [ 'id' => [ 'type' => 'integer', 'unsigned' => FALSE, 'size' => 'big', ], 'version' => [ 'type' => 'string', 'max_length' => 64, 'is_ascii' => TRUE, ], ]; @endcode If 'type' points to a field plugin with multiple columns and needs to refer to a column different than 'value', the key of that column will be appended as a suffix to the plugin name, separated by dot ('.'). Example: @code return [ 'format' => [ 'type' => 'text.format', ], ]; @endcode Additional custom keys/values, that are not part of field storage definition, can be passed in definitions: @code return [ 'nid' => [ 'type' => 'integer', 'custom_setting' => 'some_value', ], ]; @endcode

See also

FieldStorageDefinitionInterface::getSettings
IntegerItem
StringItem
TextItem

array fields()

Returns an array of destination fields.

Derived classes must implement fields(), returning a list of available destination fields.

Return Value

array
  • Keys: machine names of the fields
  • Values: Human-friendly descriptions of the fields.

array|bool import(Row $row, array $old_destination_id_values = [])

Import the row.

Derived classes must implement import(), to construct one new object (pre-populated) using ID mappings in the Migration.

Parameters

Row $row

The row object.

array $old_destination_id_values

(optional) The old destination IDs. Defaults to an empty array.

Return Value

array|bool

An indexed array of destination IDs in the same order as defined in the plugin's getIds() method if the plugin wants to save the IDs to the ID map, TRUE to indicate success without saving IDs to the ID map, or FALSE to indicate a failure.

rollback(array $destination_identifier)

Delete the specified destination object from the target Drupal.

Parameters

array $destination_identifier

The ID of the destination object to delete.

bool supportsRollback()

Whether the destination can be rolled back or not.

Return Value

bool

TRUE if rollback is supported, FALSE if not.

int rollbackAction()

The rollback action for the last imported item.

Return Value

int

The MigrateIdMapInterface::ROLLBACK_ constant indicating how an imported item should be handled on rollback.

string|null getDestinationModule()

Gets the destination module handling the destination data.

Return Value

string|null

The destination module or NULL if not found.