/** * @see Console\Command\Command */ protected function execute(InputInterface $input, OutputInterface $output) { $module = $input->getArgument('module'); $modules = $this->moduleManager->getModules(); $path = "{$this->modulesDir}/{$module}-module"; if (isset($modules[$module])) { $output->writeln("<error>Module '{$module}' already exists.</error>"); return; } if (file_exists($path)) { $output->writeln("<error>Path '" . $path . "' exists.</error>"); return; } if (!is_writable(dirname($path))) { $output->writeln("<error>Path '" . dirname($path) . "' is not writable.</error>"); return; } umask(00); mkdir($path, 0777, TRUE); file_put_contents($path . '/Module.php', $this->getModuleFile($module)); file_put_contents($path . '/composer.json', $this->getComposerFile($module)); file_put_contents($path . '/readme.md', $this->getReadmeFile($module)); mkdir($path . '/Resources/config', 0777, TRUE); mkdir($path . '/Resources/public', 0777, TRUE); mkdir($path . '/Resources/translations', 0777, TRUE); mkdir($path . '/Resources/layouts', 0777, TRUE); mkdir($path . '/' . ucfirst($module) . 'Module', 0777, TRUE); }
/** * @return array */ protected function getModules() { $ret = array(); foreach ($this->moduleManager->getModules() as $name => $module) { $ret[$name] = '@' . $name . 'Module'; } return $ret; }
/** * @see Console\Command\Command */ protected function execute(InputInterface $input, OutputInterface $output) { try { $this->moduleManager->update(); $output->writeln('Modules have been updated.'); } catch (InvalidArgumentException $e) { $output->writeln("<error>{$e->getMessage()}</error>"); } }
/** * @see Console\Command\Command */ protected function execute(InputInterface $input, OutputInterface $output) { try { $this->moduleManager->register($this->moduleManager->createInstance($input->getArgument('module'))); $output->writeln("Module '{$input->getArgument('module')}' has been registered."); } catch (InvalidArgumentException $e) { $output->writeln("<error>{$e->getMessage()}</error>"); } }
/** * @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) { try { foreach ($this->moduleManager->findModules() as $module) { $configVersion = $this->container->parameters['modules'][$module->getName()][ModuleManager::MODULE_VERSION]; if ($configVersion == $module->getVersion()) { $version = $module->getVersion(); } else { $version = $module->getVersion() . ' (needs upgrade from: ' . $configVersion . ')'; } $output->writeln(sprintf('<info>%25s</info> | status: <comment>%-12s</comment> | version: <comment>%s</comment>', $module->getName(), $this->moduleManager->getStatus($module), $version)); } } catch (InvalidArgumentException $e) { $output->writeln("<error>{$e->getMessage()}</error>"); } }
/** * @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->testUpgrade($module); } catch (InvalidArgumentException $e) { $output->writeln("<error>{$e->getMessage()}</error>"); return; } if (!$input->getOption('noconfirm') && count($problem->getSolutions()) > 0) { $output->writeln("<info>upgrade : {$module->getName()}</info>"); foreach ($problem->getSolutions() as $job) { $output->writeln("<info>{$job->getAction()} : {$job->getModule()->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->upgrade($module); $output->writeln("Module '{$input->getArgument('module')}' has been upgraded."); } catch (InvalidArgumentException $e) { $output->writeln("<error>{$e->getMessage()}</error>"); } }