You are here

public function MigrationBase::processImport in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 includes/base.inc \MigrationBase::processImport()

Perform an operation during the import phase

Parameters

array $options: List of options provided (usually from a drush command). Specific to the derived class.

File

includes/base.inc, line 1134
Defines the base class for migration processes.

Class

MigrationBase
The base class for all objects representing distinct steps in a migration process. Most commonly these will be Migration objects which actually import data from a source into a Drupal destination, but by deriving classes directly from MigrationBase…

Code

public function processImport(array $options = array()) {
  if ($this->enabled) {
    $return = MigrationBase::RESULT_COMPLETED;
    if (method_exists($this, 'import')) {
      $this->options = $options;
      if (!isset($options['force']) || !$options['force']) {
        if (!$this
          ->dependenciesComplete()) {
          return MigrationBase::RESULT_SKIPPED;
        }
      }
      $this
        ->beginProcess(MigrationBase::STATUS_IMPORTING);
      try {
        $return = $this
          ->import();
      } catch (Exception $exception) {

        // If something bad happened, make sure we clear the semaphore
        $this
          ->endProcess();
        throw $exception;
      }
      if ($return == MigrationBase::RESULT_COMPLETED && isset($this->total_successes)) {
        $time = microtime(TRUE) - $this->starttime;
        if ($time > 0) {
          $overallThroughput = round(60 * $this->total_successes / $time);
        }
        else {
          $overallThroughput = 9999;
        }
      }
      else {
        $overallThroughput = 0;
      }
      $this
        ->endProcess($overallThroughput);
    }
  }
  else {
    $return = MigrationBase::RESULT_DISABLED;
  }
  return $return;
}