function drush_drupalmoduleupgrader_dmu_upgrade in Drupal 7 to 8/9 Module Upgrader 8
Tries to automatically convert a Drupal 7 module to Drupal 8.
Parameters
string $module: The module to upgrade.
File
- ./
drupalmoduleupgrader.drush.inc, line 334 - Declarations for Drush.
Code
function drush_drupalmoduleupgrader_dmu_upgrade($module) {
$target = _dmu_build_target($module);
if (drush_get_option('backup', FALSE)) {
$fs = new Filesystem();
$backup_at = $target
->getBasePath() . '.bak';
$fs
->mirror($target
->getBasePath(), $backup_at);
drush_log(\Drupal::translation()
->translate('Created backup at @path', [
'@path' => $backup_at,
]), 'success');
}
$converters = \Drupal::service('plugin.manager.drupalmoduleupgrader.converter');
foreach (_dmu_plugin_list('converter') as $id) {
/** @var \Drupal\drupalmoduleupgrader\ConverterInterface $converter */
$converter = $converters
->createInstance($id);
if ($converter
->isExecutable($target)) {
drush_log(\Drupal::translation()
->translate('Executing plugin: @plugin_id', [
'@plugin_id' => $id,
]), 'notice');
try {
$converter
->convert($target);
} catch (Exception $e) {
drush_log($e
->getMessage(), 'error');
// Being a notice, the stack trace will only appear in verbose mode.
drush_log($e
->getTraceAsString(), 'notice');
}
}
}
}