diff -u b/core/modules/migrate/config/schema/migrate.schema.yml b/core/modules/migrate/config/schema/migrate.schema.yml --- b/core/modules/migrate/config/schema/migrate.schema.yml +++ b/core/modules/migrate/config/schema/migrate.schema.yml @@ -58,6 +58,9 @@ label: type: label label: 'Label' + module: + type: string + label: 'Dependent module' shared_configuration: type: sequence label: 'Shared migration configuration' diff -u b/core/modules/migrate/src/Entity/MigrationGroup.php b/core/modules/migrate/src/Entity/MigrationGroup.php --- b/core/modules/migrate/src/Entity/MigrationGroup.php +++ b/core/modules/migrate/src/Entity/MigrationGroup.php @@ -46,2 +46,41 @@ + /** + * {@inheritdoc} + */ + public function delete() { + dpm("deleting group ".$this->id); + // Delete all migrations contained in this group. + $query = \Drupal::entityQuery('migration') + ->condition('active_group', $this->id()); + $names = $query->execute(); + + // Order the migrations according to their dependencies. + /** @var MigrationInterface[] $migrations */ + $migrations = \Drupal::entityManager()->getStorage('migration')->loadMultiple($names); + + // Delete in reverse order, so dependencies are never violated. + $migrations = array_reverse($migrations); + + foreach ($migrations as $migration) { + $migration->delete(); + } + + // Finally, delete the group itself. + parent::delete(); + } + + /** + * {@inheritdoc} + */ + public function calculateDependencies() { + dpm('calculateDependencies: '.$this->id); + parent::calculateDependencies(); + if ($provider = $this->get('module')) { + dpm("provider=$provider"); + $this->addDependency('module', $provider); + } + dpm($this->dependencies); + return $this->dependencies; + } + }