3 namespace Drupal\migrate_plus\Entity;
5 use Drupal\Core\Config\Entity\ConfigEntityBase;
8 * Defines the Migration Group entity.
10 * The migration group entity is used to group active migrations, as well as to
11 * store shared migration configuration.
14 * id = "migration_group",
15 * label = @Translation("Migration Group"),
16 * module = "migrate_plus",
25 class MigrationGroup extends ConfigEntityBase implements MigrationGroupInterface {
28 * The migration group ID (machine name).
35 * The human-readable label for the migration group.
44 public function delete() {
45 // Delete all migrations contained in this group.
46 $query = \Drupal::entityQuery('migration')
47 ->condition('migration_group', $this->id());
48 $names = $query->execute();
50 // Order the migrations according to their dependencies.
51 /** @var MigrationInterface[] $migrations */
52 $migrations = \Drupal::entityTypeManager()->getStorage('migration')->loadMultiple($names);
54 // Delete in reverse order, so dependencies are never violated.
55 $migrations = array_reverse($migrations);
57 foreach ($migrations as $migration) {
61 // Finally, delete the group itself.
68 public function calculateDependencies() {
69 parent::calculateDependencies();
70 // Make sure we save any explicit module dependencies.
71 if ($provider = $this->get('module')) {
72 $this->addDependency('module', $provider);
74 return $this->dependencies;