Add refresh command
This commit is contained in:
57
core/lib/Thelia/Command/ModuleRefreshCommand.php
Normal file
57
core/lib/Thelia/Command/ModuleRefreshCommand.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* This file is part of the Thelia package. */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : dev@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||||
|
/* file that was distributed with this source code. */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Thelia\Module\ModuleManagement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ModuleRefreshCommand
|
||||||
|
* Refresh modules list
|
||||||
|
*
|
||||||
|
* @package Thelia\Command
|
||||||
|
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||||
|
*
|
||||||
|
* 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'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user