function crm_core_data_import_register_migration in CRM Core 7
Register CRM Core data migration.
1 call to crm_core_data_import_register_migration()
- _crm_core_data_import_build_entity_operations in modules/
crm_core_data_import/ crm_core_data_import.admin.inc - Build operations for queue of import.
File
- modules/
crm_core_data_import/ crm_core_data_import.module, line 320 - Provides basic functionality for a CRM Core Data Import.
Code
function crm_core_data_import_register_migration($importer_id, $entity_type, $entity_bundle, $bundle_delta) {
/** @var CRMCoreDataImport $importer */
$importer = crm_core_data_import_load_importer($importer_id);
$linked_imports = $importer
->getLinkedImports();
$machine_name = _crm_core_data_import_migration_machine_name($importer->id, $entity_type, $entity_bundle, $bundle_delta);
$arguments = array(
'importer' => $importer,
'entity_type' => $entity_type,
'entity_bundle' => $entity_bundle,
'delta' => $bundle_delta,
);
if ($linked_imports) {
$dependencies = array();
foreach ($linked_imports as $key => $primary_field) {
$linked_importer = crm_core_data_import_load_importer($key);
foreach ($linked_importer
->getMigrationInstances() as $migration) {
/** @var Migration $migration */
if (!array_search($migration
->getMachineName(), $dependencies)) {
$dependencies[] = $migration
->getMachineName();
}
}
}
$arguments['soft_dependencies'] = $dependencies;
}
Migration::registerMigration('MigrationDataImport', $machine_name, $arguments);
// Save registered migration.
// This allows rollback and remove registered migrations.
$registered_migrations = variable_get('crm_core_data_import_migrations_' . $importer_id, array());
if (!in_array($machine_name, $registered_migrations)) {
$registered_migrations[] = $machine_name;
variable_set('crm_core_data_import_migrations_' . $importer_id, $registered_migrations);
}
}