function D6NodeDeriver::getDerivativeDefinitions
Same name in other branches
- 9 core/modules/node/src/Plugin/migrate/D6NodeDeriver.php \Drupal\node\Plugin\migrate\D6NodeDeriver::getDerivativeDefinitions()
- 8.9.x core/modules/node/src/Plugin/migrate/D6NodeDeriver.php \Drupal\node\Plugin\migrate\D6NodeDeriver::getDerivativeDefinitions()
- 10 core/modules/node/src/Plugin/migrate/D6NodeDeriver.php \Drupal\node\Plugin\migrate\D6NodeDeriver::getDerivativeDefinitions()
Overrides DeriverBase::getDerivativeDefinitions
File
-
core/
modules/ node/ src/ Plugin/ migrate/ D6NodeDeriver.php, line 73
Class
- D6NodeDeriver
- Deriver for Drupal 6 node and node revision migrations based on node types.
Namespace
Drupal\node\Plugin\migrateCode
public function getDerivativeDefinitions($base_plugin_definition) {
if ($base_plugin_definition['id'] == 'd6_node_translation' && !$this->includeTranslations) {
// Refuse to generate anything.
return $this->derivatives;
}
$node_types = static::getSourcePlugin('d6_node_type');
try {
$node_types->checkRequirements();
} catch (RequirementsException) {
// If the d6_node_type requirements failed, that means we do not have a
// Drupal source database configured - there is nothing to generate.
return $this->derivatives;
}
try {
foreach ($node_types as $row) {
$node_type = $row->getSourceProperty('type');
$values = $base_plugin_definition;
$values['label'] = $this->t("@label (@type)", [
'@label' => $values['label'],
'@type' => $node_type,
]);
$values['source']['node_type'] = $node_type;
$values['destination']['default_bundle'] = $node_type;
// If this migration is based on the d6_node_revision migration or
// is for translations of nodes, it should explicitly depend on the
// corresponding d6_node variant.
if (in_array($base_plugin_definition['id'], [
'd6_node_revision',
'd6_node_translation',
])) {
$values['migration_dependencies']['required'][] = 'd6_node:' . $node_type;
}
/** @var \Drupal\migrate\Plugin\Migration $migration */
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($values);
$this->fieldDiscovery
->addBundleFieldProcesses($migration, 'node', $node_type);
$this->derivatives[$node_type] = $migration->getPluginDefinition();
}
} catch (DatabaseExceptionWrapper) {
// 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 6 source database.
}
return $this->derivatives;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.