Skip to content
Snippets Groups Projects
Commit 95bd36f6 authored by Chris Shantz's avatar Chris Shantz
Browse files

Merge branch 'feature/ISTWCMS-5605-ebremner-migration-clean-up' into '1.0.x'

Feature/istwcms 5605 ebremner migration clean up

See merge request !247
parents 9303de8b b93b6e2a
No related branches found
No related tags found
1 merge request!247Feature/istwcms 5605 ebremner migration clean up
services: services:
uw_cfg_common.commands: uw_cfg_common.commands:
class: Drupal\uw_cfg_common\Commands\UwDrushCommands class: Drupal\uw_cfg_common\Commands\UwDrushCommands
arguments: ['@entity_type.manager', '@uw_cfg_common.missing_blocks', '@config.factory', '@request_stack'] arguments: ['@entity_type.manager', '@uw_cfg_common.missing_blocks', '@config.factory', '@module_handler', '@module_installer']
tags: tags:
- { name: drush.command } - { name: drush.command }
...@@ -4,6 +4,8 @@ namespace Drupal\uw_cfg_common\Commands; ...@@ -4,6 +4,8 @@ namespace Drupal\uw_cfg_common\Commands;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\Core\ProxyClass\Extension\ModuleInstaller;
use Drupal\uw_cfg_common\Service\UWMissingBlocks; use Drupal\uw_cfg_common\Service\UWMissingBlocks;
use Drupal\uw_cfg_common\UwPermissions\UwPermissions; use Drupal\uw_cfg_common\UwPermissions\UwPermissions;
use Drupal\uw_cfg_common\UwRoles\UwRoles; use Drupal\uw_cfg_common\UwRoles\UwRoles;
...@@ -38,13 +40,35 @@ class UwDrushCommands extends DrushCommands { ...@@ -38,13 +40,35 @@ class UwDrushCommands extends DrushCommands {
*/ */
protected $configFactory; protected $configFactory;
/**
* Module handler.
*
* @var \Drupal\Core\Extension\ModuleHandler
*/
protected $moduleHandler;
/**
* Module installer.
*
* @var \Drupal\Core\ProxyClass\Extension\ModuleInstaller
*/
protected $moduleInstaller;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function __construct(EntityTypeManagerInterface $entityTypeManager, UWMissingBlocks $missingBlocks, ConfigFactoryInterface $configFactory) { public function __construct(
EntityTypeManagerInterface $entityTypeManager,
UWMissingBlocks $missingBlocks,
ConfigFactoryInterface $configFactory,
ModuleHandler $moduleHandler,
ModuleInstaller $moduleInstaller
) {
$this->entityTypeManager = $entityTypeManager; $this->entityTypeManager = $entityTypeManager;
$this->missingBlocks = $missingBlocks; $this->missingBlocks = $missingBlocks;
$this->configFactory = $configFactory; $this->configFactory = $configFactory;
$this->moduleHandler = $moduleHandler;
$this->moduleInstaller = $moduleInstaller;
} }
/** /**
...@@ -227,4 +251,36 @@ class UwDrushCommands extends DrushCommands { ...@@ -227,4 +251,36 @@ class UwDrushCommands extends DrushCommands {
return $path; return $path;
} }
/**
* Drush command to cleanup after a migration.
*
* @command mim:cleanup
* @aliases mimcu
* @usage mimcu
*/
public function migrationCleanUp() {
// Modules to uninstall.
$modules = [
'uw_migrate',
'webform_migrate',
'webform_node',
];
// Step through each of the modules, ensure that they
// are enabled, and if enabled, uninstall.
foreach ($modules as $module) {
// If the module is enabled, uninstall it.
if ($this->moduleHandler->moduleExists($module)) {
// Uninstall the module.
$this->moduleInstaller->uninstall([$module]);
// Log to the screen.
$this->logger()->success('Uninstalled: ' . $module);
}
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment