protected function MigrateBatchExecutable::batchOperations in Migrate Tools 8.4
Same name and namespace in other branches
- 8.5 src/MigrateBatchExecutable.php \Drupal\migrate_tools\MigrateBatchExecutable::batchOperations()
Helper to generate the batch operations for importing migrations.
Parameters
\Drupal\migrate\Plugin\MigrationInterface[] $migrations: The migrations.
string $operation: The batch operation to perform.
array $options: The migration options.
Return value
array The batch operations to perform.
1 call to MigrateBatchExecutable::batchOperations()
- MigrateBatchExecutable::batchImport in src/
MigrateBatchExecutable.php - Setup batch operations for running the migration.
File
- src/
MigrateBatchExecutable.php, line 124
Class
- MigrateBatchExecutable
- Defines a migrate executable class for batch migrations through UI.
Namespace
Drupal\migrate_toolsCode
protected function batchOperations(array $migrations, $operation, array $options = []) {
$operations = [];
foreach ($migrations as $id => $migration) {
if (!empty($options['update'])) {
$migration
->getIdMap()
->prepareUpdate();
}
if (!empty($options['force'])) {
$migration
->set('requirements', []);
}
else {
$dependencies = $migration
->getMigrationDependencies();
if (!empty($dependencies['required'])) {
$required_migrations = $this->migrationPluginManager
->createInstances($dependencies['required']);
// For dependent migrations will need to be migrate all items.
$dependent_options = $options;
$dependent_options['limit'] = 0;
$operations = array_merge($operations, $this
->batchOperations($required_migrations, $operation, [
'limit' => 0,
'update' => $options['update'],
'force' => $options['force'],
]));
}
}
$operations[] = [
'\\Drupal\\migrate_tools\\MigrateBatchExecutable::batchProcessImport',
[
$migration
->id(),
$options,
],
];
}
return $operations;
}