MigrateIdMapInterface
interface MigrateIdMapInterface implements Iterator, PluginInspectionInterface (View source)
Defines an interface for migrate ID mappings.
Migrate ID mappings maintain a relation between source ID and destination ID for audit and rollback purposes. The keys used in the migrate_map table are of the form sourceidN and destidN for the source and destination values respectively.
The mappings are stored in a migrate_map table with properties:
- source_ids_hash: A hash of the source IDs.
- sourceidN: Any number of source IDs defined by a source plugin, where N starts at 1, for example, sourceid1, sourceid2 ... sourceidN.
- destidN: Any number of destination IDs defined by a destination plugin, where N starts at 1, for example, destid1, destid2 ... destidN.
- source_row_status: Indicates current status of the source row, valid values are self::STATUS_IMPORTED, self::STATUS_NEEDS_UPDATE, self::STATUS_IGNORED or self::STATUS_FAILED.
- rollback_action: Flag indicating what to do for this item on rollback. This property is set in destination plugins. Valid values are self::ROLLBACK_DELETE and self::ROLLBACK_PRESERVE.
- last_imported: UNIX timestamp of the last time the row was imported.
- hash: A hash of the source row data that is used to detect changes in the source data.
Constants
| STATUS_IMPORTED |
Indicates that the import of the row was successful. |
| STATUS_NEEDS_UPDATE |
Indicates that the row needs to be updated. |
| STATUS_IGNORED |
Indicates that the import of the row was ignored. |
| STATUS_FAILED |
Indicates that the import of the row failed. |
| ROLLBACK_DELETE |
Indicates that the data for the row is to be deleted. |
| ROLLBACK_PRESERVE |
Indicates that the data for the row is to be preserved. Rows that refer to entities that already exist on the destination and are being updated are preserved. |
Methods
Gets the definition of the plugin implementation.
Saves a mapping from the source identifiers to the destination identifiers.
Saves a message related to a source record in the migration message table.
Retrieves a traversable object of messages related to source records.
Retrieves an iterator over messages relate to source records.
Prepares to run a full update.
Returns the number of processed items in the map.
Returns the number of imported items in the map.
Returns a count of items which are marked as needing update.
Returns the number of items that failed to import.
Returns the number of messages saved.
Deletes the map and message entries for a given source record.
Deletes the map and message table entries for a given destination row.
Clears all messages from the map.
Retrieves a row from the map table based on source identifier values.
Retrieves a row by the destination identifiers.
Retrieves an array of map rows marked as needing update.
Looks up the source identifier.
Looks up the destination identifier corresponding to a source key.
Looks up the destination identifiers corresponding to a source key.
Looks up the destination identifier currently being iterated.
Looks up the source identifier(s) currently being iterated.
Removes any persistent storage used by this map.
Gets the qualified map table.
Sets a specified record to be updated, if it exists.
Details
string
getPluginId()
Gets the plugin_id of the plugin instance.
array
getPluginDefinition()
Gets the definition of the plugin implementation.
saveIdMapping(Row $row, array $destination_id_values, int $status = self::STATUS_IMPORTED, int $rollback_action = self::ROLLBACK_DELETE)
Saves a mapping from the source identifiers to the destination identifiers.
Called upon import of one row, we record a mapping from the source ID to the destination ID. Also may be called, setting the third parameter to NEEDS_UPDATE, to signal an existing record should be re-migrated.
saveMessage(array $source_id_values, string $message, int $level = MigrationInterface::MESSAGE_ERROR)
Saves a message related to a source record in the migration message table.
Traversable
getMessages(array $source_id_values = [], int $level = NULL)
Retrieves a traversable object of messages related to source records.
Iterator
getMessageIterator(array $source_id_values = [], int $level = NULL)
deprecated
deprecated
Retrieves an iterator over messages relate to source records.
prepareUpdate()
Prepares to run a full update.
Prepares this migration to run as an update - that is, in addition to unmigrated content (source records not in the map table) being imported, previously-migrated content will also be updated in place by marking all previously-imported content as ready to be re-imported.
int
processedCount()
Returns the number of processed items in the map.
int
importedCount()
Returns the number of imported items in the map.
int
updateCount()
Returns a count of items which are marked as needing update.
int
errorCount()
Returns the number of items that failed to import.
int
messageCount()
Returns the number of messages saved.
delete(array $source_id_values, bool $messages_only = FALSE)
Deletes the map and message entries for a given source record.
deleteDestination(array $destination_id_values)
Deletes the map and message table entries for a given destination row.
clearMessages()
Clears all messages from the map.
array
getRowBySource(array $source_id_values)
Retrieves a row from the map table based on source identifier values.
array
getRowByDestination(array $destination_id_values)
Retrieves a row by the destination identifiers.
array
getRowsNeedingUpdate(int $count)
Retrieves an array of map rows marked as needing update.
array
lookupSourceId(array $destination_id_values)
Looks up the source identifier.
Given a (possibly multi-field) destination identifier value, return the (possibly multi-field) source identifier value mapped to it.
array
lookupDestinationId(array $source_id_values)
deprecated
deprecated
Looks up the destination identifier corresponding to a source key.
Given a (possibly multi-field) source identifier value, return the (possibly multi-field) destination identifier value it is mapped to.
array
lookupDestinationIds(array $source_id_values)
Looks up the destination identifiers corresponding to a source key.
This can look up a subset of source keys if only some are provided, and will return all destination keys that match.
array
currentDestination()
Looks up the destination identifier currently being iterated.
array
currentSource()
Looks up the source identifier(s) currently being iterated.
destroy()
Removes any persistent storage used by this map.
For example, remove the map and message tables.
getQualifiedMapTableName()
Gets the qualified map table.
setMessage(MigrateMessageInterface $message)
Sets the migrate message service.
setUpdate(array $source_id_values)
Sets a specified record to be updated, if it exists.