コード例 #1
0
 public function testRemoveModulesFromDeploymentConfig()
 {
     $this->output->expects($this->atLeastOnce())->method('writeln');
     $this->deploymentConfig->expects($this->once())->method('getConfigData')->willReturn(['moduleA' => 1, 'moduleB' => 1, 'moduleC' => 1, 'moduleD' => 1]);
     $this->loader->expects($this->once())->method('load')->willReturn(['moduleC' => [], 'moduleD' => []]);
     $this->writer->expects($this->once())->method('saveConfig')->with([ConfigFilePool::APP_CONFIG => [ConfigOptionsListConstants::KEY_MODULES => ['moduleC' => 1, 'moduleD' => 1]]]);
     $this->moduleRegistryUninstaller->removeModulesFromDeploymentConfig($this->output, ['moduleA', 'moduleB']);
 }
コード例 #2
0
 /**
  * Perform setup side uninstall
  *
  * @param OutputInterface $output
  * @param string $componentName
  * @param bool $dataOption
  * @return void
  */
 public function uninstall(OutputInterface $output, $componentName, $dataOption)
 {
     $packageInfo = $this->packageInfoFactory->create();
     // convert to module name
     $moduleName = $packageInfo->getModuleName($componentName);
     if ($dataOption) {
         $this->moduleUninstaller->uninstallData($output, [$moduleName]);
     }
     $this->moduleRegistryUninstaller->removeModulesFromDb($output, [$moduleName]);
     $this->moduleRegistryUninstaller->removeModulesFromDeploymentConfig($output, [$moduleName]);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$this->deploymentConfig->isAvailable()) {
         $output->writeln('<error>You cannot run this command because the Magento application is not installed.</error>');
         // we must have an exit code higher than zero to indicate something was wrong
         return \Magento\Framework\Console\Cli::RETURN_FAILURE;
     }
     $modules = $input->getArgument(self::INPUT_KEY_MODULES);
     // validate modules input
     $messages = $this->validate($modules);
     if (!empty($messages)) {
         $output->writeln($messages);
         // we must have an exit code higher than zero to indicate something was wrong
         return \Magento\Framework\Console\Cli::RETURN_FAILURE;
     }
     // check dependencies
     $dependencyMessages = $this->checkDependencies($modules);
     if (!empty($dependencyMessages)) {
         $output->writeln($dependencyMessages);
         // we must have an exit code higher than zero to indicate something was wrong
         return \Magento\Framework\Console\Cli::RETURN_FAILURE;
     }
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion('You are about to remove code and/or database tables. Are you sure?[y/N]', false);
     if (!$helper->ask($input, $output, $question) && $input->isInteractive()) {
         return \Magento\Framework\Console\Cli::RETURN_FAILURE;
     }
     try {
         $output->writeln('<info>Enabling maintenance mode</info>');
         $this->maintenanceMode->set(true);
         $this->takeBackup($input, $output);
         $dbBackupOption = $input->getOption(self::INPUT_KEY_BACKUP_DB);
         if ($input->getOption(self::INPUT_KEY_REMOVE_DATA)) {
             $this->removeData($modules, $output, $dbBackupOption);
         } else {
             if (!empty($this->collector->collectUninstall())) {
                 $question = new ConfirmationQuestion('You are about to remove a module(s) that might have database data. ' . 'Do you want to remove the data from database?[y/N]', false);
                 if ($helper->ask($input, $output, $question) || !$input->isInteractive()) {
                     $this->removeData($modules, $output, $dbBackupOption);
                 }
             } else {
                 $output->writeln('<info>You are about to remove a module(s) that might have database data. ' . 'Remove the database data manually after uninstalling, if desired.</info>');
             }
         }
         $this->moduleRegistryUninstaller->removeModulesFromDb($output, $modules);
         $this->moduleRegistryUninstaller->removeModulesFromDeploymentConfig($output, $modules);
         $this->moduleUninstaller->uninstallCode($output, $modules);
         $this->cleanup($input, $output);
         $output->writeln('<info>Disabling maintenance mode</info>');
         $this->maintenanceMode->set(false);
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
         $output->writeln('<error>Please disable maintenance mode after you resolved above issues</error>');
         return \Magento\Framework\Console\Cli::RETURN_FAILURE;
     }
 }