public function D7CourseDeriver::getDerivativeDefinitions in Course 3.x
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverBase::getDerivativeDefinitions
See also
getDerivativeDefinition()
File
- modules/
course_migrate/ src/ Plugin/ migrate/ D7CourseDeriver.php, line 64
Class
- D7CourseDeriver
- Deriver for Drupal 7 Course migrations based on Course types.
Namespace
Drupal\course_migrate\Plugin\migrateCode
public function getDerivativeDefinitions($base_plugin_definition) {
$type_source_plugin = static::getSourcePlugin('d7_course_type');
try {
$type_source_plugin
->checkRequirements();
} catch (RequirementsException $e) {
// If the d7_couirse_type requirements failed, that means we do not
// have a Drupal source database configured - there is nothing to
// generate.
return $this->derivatives;
}
try {
foreach ($type_source_plugin as $row) {
$bundle = $row
->getSourceProperty('type');
$values = $base_plugin_definition;
$values['label'] = $this
->t('@label (@type)', [
'@label' => $values['label'],
'@type' => $row
->getSourceProperty('name'),
]);
$values['source']['bundle'] = $bundle;
$values['destination']['default_bundle'] = $bundle;
/** @var Migration $migration */
$migration = Drupal::service('plugin.manager.migration')
->createStubMigration($values);
$this->fieldDiscovery
->addBundleFieldProcesses($migration, 'node', $bundle);
$this->derivatives[$bundle] = $migration
->getPluginDefinition();
}
} catch (DatabaseExceptionWrapper $e) {
// Once we begin iterating the source plugin it is possible that the
// source tables will not exist. This can happen when the
// MigrationPluginManager gathers up the migration definitions but we do
// not actually have a Drupal 7 source database.
}
return $this->derivatives;
}