Skip to content

Instantly share code, notes, and snippets.

@achraf-jeday
Created September 22, 2020 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achraf-jeday/fcef5deaf936a60a52774928efd9da5b to your computer and use it in GitHub Desktop.
Save achraf-jeday/fcef5deaf936a60a52774928efd9da5b to your computer and use it in GitHub Desktop.
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
/**
* Implements hook_cron().
*/
function migrate_tools_cron() {
$manager = Drupal::service('plugin.manager.migration');
$migration_ids = ['drupal_planet_rss_importer'];
foreach ($migration_ids as $migration_id) {
$migration = $manager->createInstance($migration_id);
// update existing entity imported.
$migration->getIdMap()->prepareUpdate();
$executable = new MigrateExecutable($migration, new MigrateMessage());
try {
// Run the migration.
$executable->import();
}
catch (\Exception $e) {
$migration->setStatus(MigrationInterface::STATUS_IDLE);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment