You are here

function drush_wbm2cm_migrate in Workbench Moderation to Content Moderation 8.2

File

./wbm2cm.drush.inc, line 23

Code

function drush_wbm2cm_migrate() {
  drush_wbm2cm_save();
  drush_wbm2cm_clear(FALSE);
  $fields = \Drupal::service('wbm2cm.migration_controller')
    ->getOverriddenFields();
  if ($fields) {
    drush_print('It looks like you have overridden the moderation_state base field. These overrides will be reverted because they are incompatible with Content Moderation. You will also need to delete these from your exported config.');

    /** @var \Drupal\Core\Field\Entity\BaseFieldOverride $field */
    foreach ($fields as $field) {
      $field
        ->delete();
      $message = sprintf('Reverted %s. Delete %s.yml from your exported config.', $field
        ->id(), $field
        ->getConfigDependencyName());
      drush_print($message);
    }
  }
  drush_print('Installing Content Moderation...');

  /** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
  $module_installer = \Drupal::service('module_installer');
  $module_installer
    ->uninstall([
    'workbench_moderation',
  ]);
  $module_installer
    ->install([
    'content_moderation',
  ]);
  drush_wbm2cm_restore();
  drush_print('Yay! You have been migrated to Content Moderation.');
}