By quietone on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.2.x
Introduced in version:
11.2.0
Issue links:
Description:
Methods \Drupal\migrate\Plugin\Migration::addRequiredDependencies()and \Drupal\migrate\Plugin\Migration::addOptionalDependencies() are added to simplify adding dependencies to migration plugins.
Both methods have one argument: an array of migration IDs. They both return the migration object, so they can be chained with other methods.
Examples
addRequiredDependencies
$migration->addRequiredDependencies(['my_project_users', 'my_project_categories']);
addOptionalDependencies()
$migration->addOptionalDependencies(['my_project_block', 'my_project_menu']);
With these new methods, we can now simplify some code:
Before Drupal 11.2.0
$migration_dependencies = $migration->getMigrationDependencies();
array_push($migration_dependencies['required'], $this->getEntityTypeMigrationId());
$migration_dependencies['required'] = array_unique($migration_dependencies['required']);
$migration->set('migration_dependencies', $migration_dependencies);
Starting with Drupal 11.2.0
$migration->addRequiredDependencies([$this->getEntityTypeMigrationId()]);
Impacts:
Module developers