(eg: Winter.Blog)} {--f|force : Force the operation to run and ignore production warnings and confirmation questions.} {--r|no-rollback : Skip the rollback of the plugin migrations.}'; /** * @var string The console command description. */ protected $description = 'Removes an existing plugin.'; /** * Execute the console command. */ public function handle(): int { $pluginName = $this->getPluginIdentifier(); $pluginManager = PluginManager::instance(); if ( !$pluginManager->hasPlugin($pluginName) && !VersionManager::instance()->getDatabaseHistory($pluginName) ) { $this->error(sprintf('Plugin "%s" could not be found.', $pluginName)); return 1; } $confirmQuestion = sprintf('This will remove the files for the "%s" plugin.', $pluginName); if (!$this->option('no-rollback')) { $confirmQuestion = sprintf('This will remove the database tables and files for the "%s" plugin.', $pluginName); } if (!$this->confirmWithInput( $confirmQuestion, $pluginName )) { return 1; } if (!$this->option('no-rollback')) { /* * Rollback plugin */ $manager = UpdateManager::instance()->setNotesOutput($this->output); $manager->rollbackPlugin($pluginName); } /* * Delete from file system */ if ($pluginPath = $pluginManager->getPluginPath($pluginName)) { File::deleteDirectory($pluginPath); $this->output->writeln(sprintf('Deleted: %s', $pluginPath)); } return 0; } }