function gathercontent_update_8506 in GatherContent 8.5
Refresh all the migrate definitions to the new format.
File
- ./
gathercontent.install, line 323 - Install and uninstall script for GatherContent module.
Code
function gathercontent_update_8506() {
$mapping_ids = \Drupal::entityQuery('gathercontent_mapping')
->execute();
if (empty($mapping_ids)) {
throw new Exception("Operation failed: Template not mapped.");
}
$migrationDefinitionCreator = \Drupal::service('gathercontent.migration_creator');
foreach ($mapping_ids as $mapping_id) {
$mapping = Mapping::load($mapping_id);
$mapping
->setUpdatedDrupal(time());
$mapping
->save();
$mapping_data = unserialize($mapping
->getData());
if (!empty($mapping_data)) {
$migrationDefinitionCreator
->setMapping($mapping)
->setMappingData($mapping_data)
->createMigrationDefinition();
}
}
}