Skip to content

Commit

Permalink
Update Mgrate batch executable class to handle source url correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
LOBsTerr committed Jan 14, 2022
1 parent 3e56f9b commit 31bc44a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/MigrateBatchExecutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class MigrateBatchExecutable extends MigrateExecutable {
*/
protected $checkDependencies = 0;

/**
* Source URL.
*
* @var string
*/
protected $sourceUrl = '';

/**
* The current batch context.
*
Expand Down Expand Up @@ -129,7 +136,7 @@ public function batchImport() {
*/
protected function batchOperations(array $migrations, $operation, array $options = []) {
$operations = [];
foreach ($migrations as $id => $migration) {
foreach ($migrations as $migration) {

if (!empty($options['update'])) {
$migration->getIdMap()->prepareUpdate();
Expand All @@ -148,7 +155,7 @@ protected function batchOperations(array $migrations, $operation, array $options
$dependencies = $migration->getMigrationDependencies();
if (!empty($dependencies['required'])) {
$required_migrations = $this->migrationPluginManager->createInstances($dependencies['required']);
// For dependent migrations will need to be migrate all items.
// For dependent migrations will need to be migrated all items.
$operations = array_merge($operations, $this->batchOperations($required_migrations, $operation, [
'limit' => 0,
'update' => $options['update'],
Expand All @@ -158,7 +165,7 @@ protected function batchOperations(array $migrations, $operation, array $options
}

$operations[] = [
'\Drupal\migrate_tools\MigrateBatchExecutable::batchProcessImport',
'\Drupal\newsroom_connector\MigrateBatchExecutable::batchProcessImport',
[$migration->id(), $options],
];
}
Expand Down Expand Up @@ -196,6 +203,12 @@ public static function batchProcessImport($migration_id, array $options, &$conte
$options['limit'] = $options['limit'] - $context['results'][$migration->id()]['@numitems'];
}

if (!empty($options['source_url'])) {
$source = $migration->getSourceConfiguration();
$source['urls'] = $options['source_url'];
$migration->set('source', $source);
}

$executable = new MigrateBatchExecutable($migration, $message, $options);

if (empty($context['sandbox']['total'])) {
Expand Down

0 comments on commit 31bc44a

Please sign in to comment.