dataSetupFactory = $dataSetupFactory; $this->deploymentConfig = $deploymentConfig; $this->writer = $writer; $this->loader = $loader; } /** * Removes module from setup_module table * * @param OutputInterface $output * @param string[] $modules * @return void */ public function removeModulesFromDb(OutputInterface $output, array $modules) { $output->writeln( 'Removing ' . implode(', ', $modules) . ' from module registry in database' ); /** @var \Magento\Framework\Setup\ModuleDataSetupInterface $setup */ $setup = $this->dataSetupFactory->create(); foreach ($modules as $module) { $setup->deleteTableRow('setup_module', 'module', $module); } } /** * Removes module from deployment configuration * * @param OutputInterface $output * @param string[] $modules * @return void */ public function removeModulesFromDeploymentConfig(OutputInterface $output, array $modules) { $output->writeln( 'Removing ' . implode(', ', $modules) . ' from module list in deployment configuration' ); $configuredModules = $this->deploymentConfig->getConfigData( \Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES ); $existingModules = $this->loader->load($modules); $newModules = []; foreach (array_keys($existingModules) as $module) { $newModules[$module] = isset($configuredModules[$module]) ? $configuredModules[$module] : 0; } $this->writer->saveConfig( [ \Magento\Framework\Config\File\ConfigFilePool::APP_CONFIG => [\Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES => $newModules] ], true ); } }