function D7TaxonomyTermDeriver::getDerivativeDefinitions
Same name in other branches
- 9 core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php \Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver::getDerivativeDefinitions()
- 8.9.x core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php \Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver::getDerivativeDefinitions()
- 11.x core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php \Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver::getDerivativeDefinitions()
Overrides DeriverBase::getDerivativeDefinitions
File
-
core/
modules/ taxonomy/ src/ Plugin/ migrate/ D7TaxonomyTermDeriver.php, line 61
Class
- D7TaxonomyTermDeriver
- Deriver for Drupal 7 taxonomy term migrations based on vocabularies.
Namespace
Drupal\taxonomy\Plugin\migrateCode
public function getDerivativeDefinitions($base_plugin_definition) {
$vocabulary_source_plugin = static::getSourcePlugin('d7_taxonomy_vocabulary');
try {
$vocabulary_source_plugin->checkRequirements();
} catch (RequirementsException $e) {
// If the d7_taxonomy_vocabulary requirements failed, that means we do not
// have a Drupal source database configured - there is nothing to
// generate.
return $this->derivatives;
}
try {
foreach ($vocabulary_source_plugin as $row) {
$bundle = $row->getSourceProperty('machine_name');
$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 \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($values);
$this->fieldDiscovery
->addBundleFieldProcesses($migration, 'taxonomy_term', $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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.