You are here

abstract class MigrateDestination in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 includes/destination.inc \MigrateDestination

Abstract base class for destination handling.

Derived classes are expected to define __toString(), returning a string describing the type of destination and significant options. See MigrateDestinationEntity for an example.

Hierarchy

Expanded class hierarchy of MigrateDestination

File

includes/destination.inc, line 15
Defines base for migration destinations.

View source
abstract class MigrateDestination {

  /**
   * To support MigrateSQLMap maps, derived destination classes should return
   * schema 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.
   *
   * abstract static public function getKeySchema()
   */

  /**
   * Derived classes must implement __toString().
   *
   * @return string
   *  Description of the destination being migrated into
   */
  public abstract function __toString();

  /**
   * Derived classes must implement fields(), returning a list of available
   * destination fields.
   *
   * @return array
   *  Keys: machine names of the fields (to be passed to addFieldMapping)
   *  Values: Human-friendly descriptions of the fields.
   */
  public abstract function fields();

  /**
   * Derived classes must implement either bulkRollback or rollback() according to
   * the signatures below, to rollback (usually by deletion) previously-migrated
   * items.
   *
   * $ids is an array of single-field keys to be deleted
   * abstract public function bulkRollback(array $ids);
   *
   * $key is an array of fields keying a single entry to delete
   * abstract public function rollback(array $key);
   */

  /**
   * Derived classes must implement import(), to construct one new object (pre-pppulated
   * using field mappings in the Migration). It is expected to call prepare and
   * complete handlers, passing them $row (the raw data from the source).
   */
  public abstract function import(stdClass $object, stdClass $row);

  /**
   * Derived classes may implement preImport() and/or postImport(), to do any
   * processing they need done before or after looping over all source rows.
   * Similarly, preRollback() or postRollback() may be implemented.
   *
   * abstract public function preImport();
   * abstract public function postImport();
   * abstract public function preRollback();
   * abstract public function postRollback();
   */

  /**
   * Maintain stats on the number of destination objects created or updated.
   *
   * @var int
   */
  protected $numCreated = 0;
  public function getCreated() {
    return $this->numCreated;
  }
  protected $numUpdated = 0;
  public function getUpdated() {
    return $this->numUpdated;
  }

  /**
   * Reset numCreated and numUpdated back to 0.
   */
  public function resetStats() {
    $this->numCreated = 0;
    $this->numUpdated = 0;
  }

  /**
   * Null constructor
   */
  public function __construct() {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MigrateDestination::$numCreated protected property Maintain stats on the number of destination objects created or updated.
MigrateDestination::$numUpdated protected property
MigrateDestination::fields abstract public function Derived classes must implement fields(), returning a list of available destination fields. 6
MigrateDestination::getCreated public function
MigrateDestination::getUpdated public function
MigrateDestination::import abstract public function Derived classes must implement import(), to construct one new object (pre-pppulated using field mappings in the Migration). It is expected to call prepare and complete handlers, passing them $row (the raw data from the source). 6
MigrateDestination::resetStats public function Reset numCreated and numUpdated back to 0.
MigrateDestination::__construct public function Null constructor 3
MigrateDestination::__toString abstract public function Derived classes must implement __toString(). 3