public function MigrationGroup::delete in Migrate Plus 8.2
Same name and namespace in other branches
- 8.5 src/Entity/MigrationGroup.php \Drupal\migrate_plus\Entity\MigrationGroup::delete()
- 8 src/Entity/MigrationGroup.php \Drupal\migrate_plus\Entity\MigrationGroup::delete()
- 8.3 src/Entity/MigrationGroup.php \Drupal\migrate_plus\Entity\MigrationGroup::delete()
- 8.4 src/Entity/MigrationGroup.php \Drupal\migrate_plus\Entity\MigrationGroup::delete()
Deletes an entity permanently.
Throws
\Drupal\Core\Entity\EntityStorageException In case of failures an exception is thrown.
Overrides EntityBase::delete
File
- src/
Entity/ MigrationGroup.php, line 44
Class
- MigrationGroup
- Defines the Migration Group entity.
Namespace
Drupal\migrate_plus\EntityCode
public function delete() {
// Delete all migrations contained in this group.
$query = \Drupal::entityQuery('migration')
->condition('migration_group', $this
->id());
$names = $query
->execute();
// Order the migrations according to their dependencies.
/** @var MigrationInterface[] $migrations */
$migrations = \Drupal::entityTypeManager()
->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();
}