3 namespace Drupal\migrate\Plugin;
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\migrate\Row;
9 * Defines an interface for Migration Destination classes.
11 * Destinations are responsible for persisting source data into the destination
14 * @see \Drupal\migrate\Plugin\destination\DestinationBase
15 * @see \Drupal\migrate\Plugin\MigrateDestinationPluginManager
16 * @see \Drupal\migrate\Annotation\MigrateDestination
21 interface MigrateDestinationInterface extends PluginInspectionInterface {
24 * Gets the destination IDs.
26 * To support MigrateIdMap maps, derived destination classes should return
27 * field definition(s) corresponding to the primary key of the destination
28 * being implemented. These are used to construct the destination key fields
29 * of the map table for a migration using this destination.
32 * An associative array of field definitions keyed by field ID. Values are
33 * associative arrays with a structure that contains the field type ('type'
34 * key). The other keys are the field storage settings as they are returned
35 * by FieldStorageDefinitionInterface::getSettings(). As an example, for a
36 * composite destination primary key that is defined by an integer and a
37 * string, the returned value might look like:
41 * 'type' => 'integer',
42 * 'unsigned' => FALSE,
52 * If 'type' points to a field plugin with multiple columns and needs to
53 * refer to a column different than 'value', the key of that column will be
54 * appended as a suffix to the plugin name, separated by dot ('.'). Example:
58 * 'type' => 'text.format',
62 * Additional custom keys/values, that are not part of field storage
63 * definition, can be passed in definitions:
67 * 'type' => 'integer',
68 * 'custom_setting' => 'some_value',
73 * @see \Drupal\Core\Field\FieldStorageDefinitionInterface::getSettings()
74 * @see \Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem
75 * @see \Drupal\Core\Field\Plugin\Field\FieldType\StringItem
76 * @see \Drupal\text\Plugin\Field\FieldType\TextItem
78 public function getIds();
81 * Returns an array of destination fields.
83 * Derived classes must implement fields(), returning a list of available
86 * @param \Drupal\migrate\Plugin\MigrationInterface $migration
87 * Unused, will be removed before Drupal 9.0.x. Defaults to NULL.
90 * - Keys: machine names of the fields
91 * - Values: Human-friendly descriptions of the fields.
93 public function fields(MigrationInterface $migration = NULL);
98 * Derived classes must implement import(), to construct one new object
99 * (pre-populated) using ID mappings in the Migration.
101 * @param \Drupal\migrate\Row $row
103 * @param array $old_destination_id_values
104 * (optional) The old destination IDs. Defaults to an empty array.
107 * The entity ID or an indication of success.
109 public function import(Row $row, array $old_destination_id_values = []);
112 * Delete the specified destination object from the target Drupal.
114 * @param array $destination_identifier
115 * The ID of the destination object to delete.
117 public function rollback(array $destination_identifier);
120 * Whether the destination can be rolled back or not.
123 * TRUE if rollback is supported, FALSE if not.
125 public function supportsRollback();
128 * The rollback action for the last imported item.
131 * The MigrateIdMapInterface::ROLLBACK_ constant indicating how an imported
132 * item should be handled on rollback.
134 public function rollbackAction();