You are here

interface MigrateIdMapInterface in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/src/Plugin/MigrateIdMapInterface.php \Drupal\migrate\Plugin\MigrateIdMapInterface

Defines an interface for migrate ID mappings.

Migrate ID mappings maintain a relation between source ID and destination ID for audit and rollback purposes.

Hierarchy

Expanded class hierarchy of MigrateIdMapInterface

All classes that implement MigrateIdMapInterface

23 files declare their use of MigrateIdMapInterface
DestinationBase.php in core/modules/migrate/src/Plugin/migrate/destination/DestinationBase.php
Contains \Drupal\migrate\Plugin\migrate\destination\DestinationBase.
EntityConfigBase.php in core/modules/migrate/src/Plugin/migrate/destination/EntityConfigBase.php
Contains \Drupal\migrate\Plugin\migrate\destination\EntityConfigBase.
EntityContentBase.php in core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
Contains \Drupal\migrate\Plugin\migrate\destination\EntityContentBase.
EntityContentBaseTest.php in core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php
Contains \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityContentBaseTest
MigrateException.php in core/modules/migrate/src/MigrateException.php
Contains \Drupal\migrate\MigrateException.

... See full list

File

core/modules/migrate/src/Plugin/MigrateIdMapInterface.php, line 21
Contains \Drupal\migrate\Plugin\MigrateIdMapInterface.

Namespace

Drupal\migrate\Plugin
View source
interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {

  /**
   * Codes reflecting the current status of a map row.
   */
  const STATUS_IMPORTED = 0;
  const STATUS_NEEDS_UPDATE = 1;
  const STATUS_IGNORED = 2;
  const STATUS_FAILED = 3;

  /**
   * Codes reflecting how to handle the destination item on rollback.
   */
  const ROLLBACK_DELETE = 0;
  const ROLLBACK_PRESERVE = 1;

  /**
   * 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.
   *
   * @param \Drupal\migrate\Row $row
   *   The raw source data. We use the ID map derived from the source object
   *   to get the source identifier values.
   * @param array $destination_id_values
   *   An array of destination identifier values.
   * @param int $status
   *   Status of the source row in the map.
   * @param int $rollback_action
   *   How to handle the destination object on rollback.
   */
  public function saveIdMapping(Row $row, array $destination_id_values, $status = self::STATUS_IMPORTED, $rollback_action = self::ROLLBACK_DELETE);

  /**
   * Saves a message related to a source record in the migration message table.
   *
   * @param array $source_id_values
   *   The source identifier keyed values of the record, e.g. ['nid' => 5].
   * @param string $message
   *   The message to record.
   * @param int $level
   *   Optional message severity (defaults to MESSAGE_ERROR).
   */
  public function saveMessage(array $source_id_values, $message, $level = MigrationInterface::MESSAGE_ERROR);

  /**
   * Retrieves an iterator over messages relate to source records.
   *
   * @param array $source_id_values
   *   (optional) The source identifier keyed values of the record, e.g. ['nid' => 5].
   *   If empty, all messages are retrieved.
   * @param int $level
   *   (optional) Message severity. If NULL, retrieve messages of all severities.
   *
   * @return \Iterator
   *   Retrieves an iterator over the message rows.
   */
  public function getMessageIterator(array $source_id_values = [], $level = NULL);

  /**
   * 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.
   */
  public function prepareUpdate();

  /**
   * Returns the number of processed items in the map.
   *
   * @return int
   *   The count of records in the map table.
   */
  public function processedCount();

  /**
   * Returns the number of imported items in the map.
   *
   * @return int
   *   The number of imported items.
   */
  public function importedCount();

  /**
   * Returns a count of items which are marked as needing update.
   *
   * @return int
   *   The number of items which need updating.
   */
  public function updateCount();

  /**
   * Returns the number of items that failed to import.
   *
   * @return int
   *   The number of items that errored out.
   */
  public function errorCount();

  /**
   * Returns the number of messages saved.
   *
   * @return int
   *   The number of messages.
   */
  public function messageCount();

  /**
   * Deletes the map and message entries for a given source record.
   *
   * @param array $source_id_values
   *   The source identifier keyed values of the record, e.g. ['nid' => 5].
   * @param bool $messages_only
   *   TRUE to only delete the migrate messages.
   */
  public function delete(array $source_id_values, $messages_only = FALSE);

  /**
   * Deletes the map and message table entries for a given destination row.
   *
   * @param array $destination_id_values
   *   The destination identifier key value pairs we should do the deletes for.
   */
  public function deleteDestination(array $destination_id_values);

  /**
   * Clears all messages from the map.
   */
  public function clearMessages();

  /**
   * Retrieves a row from the map table based on source identifier values.
   *
   * @param array $source_id_values
   *   The source identifier keyed values of the record, e.g. ['nid' => 5].
   *
   * @return array
   *   The raw row data as an associative array.
   */
  public function getRowBySource(array $source_id_values);

  /**
   * Retrieves a row by the destination identifiers.
   *
   * @param array $destination_id_values
   *   The destination identifier keyed values of the record, e.g. ['nid' => 5].
   *
   * @return array
   *   The row(s) of data.
   */
  public function getRowByDestination(array $destination_id_values);

  /**
   * Retrieves an array of map rows marked as needing update.
   *
   * @param int $count
   *   The maximum number of rows to return.
   *
   * @return array
   *   Array of map row objects that need updating.
   */
  public function getRowsNeedingUpdate($count);

  /**
   * Looks up the source identifier.
   *
   * Given a (possibly multi-field) destination identifier value, return the
   * (possibly multi-field) source identifier value mapped to it.
   *
   * @param array $destination_id_values
   *   The destination identifier keyed values of the record, e.g. ['nid' => 5].
   *
   * @return array
   *   The source identifier keyed values of the record, e.g. ['nid' => 5], or
   *   an empty array on failure.
   */
  public function lookupSourceID(array $destination_id_values);

  /**
   * 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.
   *
   * @param array $source_id_values
   *   The source identifier keyed values of the record, e.g. ['nid' => 5].
   *
   * @return array
   *   The destination identifier values of the record, or NULL on failure.
   */
  public function lookupDestinationId(array $source_id_values);

  /**
   * Looks up the destination identifier currently being iterated.
   *
   * @return array
   *   The destination identifier values of the record, or NULL on failure.
   */
  public function currentDestination();

  /**
   * Removes any persistent storage used by this map.
   *
   * For example, remove the map and message tables.
   */
  public function destroy();

  /**
   * Gets the qualified map table.
   *
   * @todo Remove this as this is SQL only and so doesn't belong to the interface.
   */
  public function getQualifiedMapTableName();

  /**
   * Sets the migrate message.
   *
   * @param \Drupal\migrate\MigrateMessageInterface $message
   *   The message to display.
   */
  public function setMessage(MigrateMessageInterface $message);

  /**
   * Sets a specified record to be updated, if it exists.
   *
   * @param array $source_id_values
   *   The source identifier values of the record.
   */
  public function setUpdate(array $source_id_values);

}

Members

Namesort descending Modifiers Type Description Overrides
MigrateIdMapInterface::clearMessages public function Clears all messages from the map. 1
MigrateIdMapInterface::currentDestination public function Looks up the destination identifier currently being iterated. 1
MigrateIdMapInterface::delete public function Deletes the map and message entries for a given source record. 1
MigrateIdMapInterface::deleteDestination public function Deletes the map and message table entries for a given destination row. 1
MigrateIdMapInterface::destroy public function Removes any persistent storage used by this map. 1
MigrateIdMapInterface::errorCount public function Returns the number of items that failed to import. 1
MigrateIdMapInterface::getMessageIterator public function Retrieves an iterator over messages relate to source records. 1
MigrateIdMapInterface::getQualifiedMapTableName public function Gets the qualified map table. 1
MigrateIdMapInterface::getRowByDestination public function Retrieves a row by the destination identifiers. 1
MigrateIdMapInterface::getRowBySource public function Retrieves a row from the map table based on source identifier values. 1
MigrateIdMapInterface::getRowsNeedingUpdate public function Retrieves an array of map rows marked as needing update. 1
MigrateIdMapInterface::importedCount public function Returns the number of imported items in the map. 1
MigrateIdMapInterface::lookupDestinationId public function Looks up the destination identifier corresponding to a source key. 1
MigrateIdMapInterface::lookupSourceID public function Looks up the source identifier. 1
MigrateIdMapInterface::messageCount public function Returns the number of messages saved. 1
MigrateIdMapInterface::prepareUpdate public function Prepares to run a full update. 1
MigrateIdMapInterface::processedCount public function Returns the number of processed items in the map. 1
MigrateIdMapInterface::ROLLBACK_DELETE constant Codes reflecting how to handle the destination item on rollback.
MigrateIdMapInterface::ROLLBACK_PRESERVE constant
MigrateIdMapInterface::saveIdMapping public function Saves a mapping from the source identifiers to the destination identifiers. 1
MigrateIdMapInterface::saveMessage public function Saves a message related to a source record in the migration message table. 1
MigrateIdMapInterface::setMessage public function Sets the migrate message. 1
MigrateIdMapInterface::setUpdate public function Sets a specified record to be updated, if it exists. 1
MigrateIdMapInterface::STATUS_FAILED constant
MigrateIdMapInterface::STATUS_IGNORED constant
MigrateIdMapInterface::STATUS_IMPORTED constant Codes reflecting the current status of a map row.
MigrateIdMapInterface::STATUS_NEEDS_UPDATE constant
MigrateIdMapInterface::updateCount public function Returns a count of items which are marked as needing update. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 2
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2