Created
September 22, 2020 12:33
-
-
Save achraf-jeday/fcef5deaf936a60a52774928efd9da5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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