You are here

protected function MigrationTaxonomyTermMachineName::postImport in Taxonomy Machine Name 7

Handle deferred terms.

Overrides Migration::postImport

File

./taxonomy_machine_name.migrate.inc, line 30
Taxonomy Machine Name Migrate Module File.

Class

MigrationTaxonomyTermMachineName
Class MigrationTaxonomyTermMachineName

Code

protected function postImport() {

  /* @var $destination MigrateDestinationTermMachineName */
  $destination = $this->destination;

  // Links terms if parent not created before child.
  $limit = 100;

  // Keep going until we have no more orphan terms, or we're stuck in a
  // seemingly infinite loop (only happens with bad data).
  while ($destination
    ->hasDeferredImports() && $limit > 0) {
    $destination
      ->runDeferredImports();
    --$limit;
  }

  // Display an error if we still have orphans left over.
  if ($destination
    ->hasDeferredImports()) {
    drupal_set_message(t('One or more terms could not be imported because their parent terms could not be found: (%terms)', array(
      '%terms' => implode(', ', $destination
        ->getDeferredImportKeys()),
    )), 'warning');
  }
}