From f6aa0ed7da1b067cf0fc093ae6663a48ac621ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81ro=CC=82me=20Billiras?= Date: Tue, 10 Jun 2014 10:33:47 +0200 Subject: [PATCH] Add refresh command --- .../Thelia/Command/ModuleRefreshCommand.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 core/lib/Thelia/Command/ModuleRefreshCommand.php diff --git a/core/lib/Thelia/Command/ModuleRefreshCommand.php b/core/lib/Thelia/Command/ModuleRefreshCommand.php new file mode 100644 index 000000000..ea71acec4 --- /dev/null +++ b/core/lib/Thelia/Command/ModuleRefreshCommand.php @@ -0,0 +1,57 @@ + + * + * Date: 2014-06-06 + * Time: 17:00 + */ +class ModuleRefreshCommand extends ContainerAwareCommand +{ + protected function configure() + { + $this + ->setName('module:refresh') + ->setDescription('Refresh modules list'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + $moduleManagement = new ModuleManagement; + $moduleManagement->updateModules(); + } catch (\Exception $e) { + throw new \RuntimeException(sprintf('Refresh modules list fail with Exception : [%d] %s', $e->getCode(), $e->getMessage())); + } + + if (method_exists($output, 'renderBlock')) { + $output->renderBlock([ + '', + 'Modules list successfully refreshed', + '' + ], + 'bg=green;fg=black' + ); + } + } +}