function forum_migration_plugins_alter
Same name in other branches
- 11.x core/modules/forum/forum.module \forum_migration_plugins_alter()
Implements hook_migration_plugins_alter().
File
-
core/
modules/ forum/ forum.module, line 713
Code
function forum_migration_plugins_alter(array &$migrations) {
// Function to append the forum_vocabulary process plugin.
$merge_forum_vocabulary = function ($process) {
$process[] = [
'plugin' => 'forum_vocabulary',
'machine_name' => 'forums',
];
return $process;
};
$merge_forum_field_name = function ($process) {
$process[] = [
'plugin' => 'forum_vocabulary',
'machine_name' => 'taxonomy_forums',
];
return $process;
};
foreach ($migrations as $migration_id => $migration) {
// Add process for forum_nav_vocabulary.
/** @var \Drupal\migrate\Plugin\migrate\source\SqlBase $source_plugin */
$source_plugin = \Drupal::service('plugin.manager.migration')->createStubMigration($migration)
->getSourcePlugin();
if (is_a($source_plugin, D6Vocabulary::class) || is_a($source_plugin, D6VocabularyPerType::class)) {
if (isset($migration['process']['vid'])) {
$migrations[$migration_id]['process']['vid'] = $merge_forum_vocabulary($migration['process']['vid']);
}
if (isset($migration['process']['field_name'])) {
$migrations[$migration_id]['process']['field_name'] = $merge_forum_field_name($migration['process']['field_name']);
}
}
if (is_a($source_plugin, D7Vocabulary::class) && !is_a($source_plugin, D7VocabularyTranslation::class) && !is_a($source_plugin, D7LanguageContentSettingsTaxonomyVocabulary::class)) {
if (isset($migration['process']['vid'])) {
$process[] = $migrations[$migration_id]['process']['vid'];
$migrations[$migration_id]['process']['vid'] = $merge_forum_vocabulary($process);
}
}
// Add process for forum_container.
if (is_a($source_plugin, D6Term::class) || is_a($source_plugin, D7Term::class) || is_a($source_plugin, TermEntityTranslation::class)) {
$migrations[$migration_id]['process']['forum_container'] = 'is_container';
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.