/** * @secured(privilege="edit") */ public function handleUninstall($name, $confirm = false) { $this->invalidateControl('content'); $module = $this->moduleManager->createInstance($name); try { $problem = $this->moduleManager->testUninstall($module); } catch (InvalidArgumentException $e) { $this->flashMessage($e->getMessage(), 'warning'); $this->redirect('this'); } if (!$confirm && count($problem->getSolutions()) > 0) { $this->template->solutions = $problem->getSolutions(); $this->template->solutionAction = 'uninstall'; $this->template->solutionModule = $name; return; } try { foreach ($problem->getSolutions() as $job) { $this->moduleManager->doAction($job->getAction(), $job->getModule()); $this->flashMessage($this->translator->translate('Module \'%name%\' has been uninstalled.', NULL, array('name' => $job->getModule()->getName())), 'success'); } $this->moduleManager->uninstall($module); $this->flashMessage($this->translator->translate('Module \'%name%\' has been uninstalled.', NULL, array('name' => $name)), 'success'); } catch (InvalidArgumentException $e) { $this->flashMessage($e->getMessage(), 'warning'); } $this->redirect('this'); }
/** * @see Console\Command\Command */ protected function execute(InputInterface $input, OutputInterface $output) { /** @var $module IModule */ $module = $this->moduleManager->createInstance($input->getArgument('module')); try { /** @var $problem Problem */ $problem = $this->moduleManager->testUninstall($module); } catch (InvalidArgumentException $e) { $output->writeln("<error>{$e->getMessage()}</error>"); return; } if (!$input->getOption('noconfirm') && count($problem->getSolutions()) > 0) { foreach ($problem->getSolutions() as $job) { $output->writeln("<info>{$job->getAction()} : {$job->getModule()->getName()}</info>"); } $output->writeln("<info>uninstall : {$module->getName()}</info>"); $dialog = $this->getHelperSet()->get('dialog'); if (!$dialog->askConfirmation($output, '<question>Continue with this actions? [y/N]</question> ', FALSE)) { return; } } try { foreach ($problem->getSolutions() as $job) { $this->moduleManager->doAction($job->getAction(), $job->getModule()); if ($job->getAction() === Job::ACTION_INSTALL) { $output->writeln("Module '{$job->getModule()->getName()}' has been installed."); } else { if ($job->getAction() === Job::ACTION_UNINSTALL) { $output->writeln("Module '{$job->getModule()->getName()}' has been uninstalled."); } else { if ($job->getAction() === Job::ACTION_UPGRADE) { $output->writeln("Module '{$job->getModule()->getName()}' has been upgraded."); } } } } $this->moduleManager->uninstall($module); $output->writeln("Module '{$input->getArgument('module')}' has been uninstalled."); } catch (InvalidArgumentException $e) { $output->writeln("<error>{$e->getMessage()}</error>"); } }