diff --git a/core/lib/Thelia/Command/BaseModuleGenerate.php b/core/lib/Thelia/Command/BaseModuleGenerate.php new file mode 100644 index 000000000..e160f9dd2 --- /dev/null +++ b/core/lib/Thelia/Command/BaseModuleGenerate.php @@ -0,0 +1,55 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Command; + + + abstract class BaseModuleGenerate extends ContainerAwareCommand { + + protected $module; + protected $moduleDirectory; + + protected $reservedKeyWords = array( + "thelia" + ); + + protected $neededDirectories = array( + "Config", + "Model", + "Loop" + ); + + protected function verifyExistingModule() + { + if (file_exists($this->moduleDirectory)) { + throw new \RuntimeException(sprintf("%s module already exists", $this->module)); + } + } + + protected function formatModuleName($name) + { + if (in_array(strtolower($name), $this->reservedKeyWords)) { + throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name)); + } + return ucfirst($name); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Command/ModuleGenerateCommand.php b/core/lib/Thelia/Command/ModuleGenerateCommand.php index 5edcd4d97..8329b84e1 100644 --- a/core/lib/Thelia/Command/ModuleGenerateCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateCommand.php @@ -28,20 +28,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; -class ModuleGenerateCommand extends ContainerAwareCommand { +class ModuleGenerateCommand extends BaseModuleGenerate { - protected $module; - protected $moduleDirectory; - private $reservedKeyWords = array( - "thelia" - ); - - private $neededDirectories = array( - "Config", - "Model", - "Loop" - ); protected function configure() { @@ -64,13 +53,16 @@ class ModuleGenerateCommand extends ContainerAwareCommand { $this->createDirectories(); $this->createFiles(); + if(method_exists($this, "renderBlock")) { + //impossible to change output class in CommandTester... + $output->renderBlock(array( + '', + sprintf("module %s create with success", $this->module), + "You can now configure your module and complete plugin.xml file", + '' + ), "bg=green;fg=black"); + } - $output->renderBlock(array( - '', - sprintf("module %s create with success", $this->module), - "You can now configure your module and complete plugin.xml file", - '' - ), "bg=green;fg=black"); } private function createDirectories() @@ -107,18 +99,5 @@ class ModuleGenerateCommand extends ContainerAwareCommand { } - private function verifyExistingModule() - { - if (file_exists($this->moduleDirectory)) { - throw new \RuntimeException(sprintf("%s module already exists", $this->module)); - } - } - private function formatModuleName($name) - { - if (in_array(strtolower($name), $this->reservedKeyWords)) { - throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name)); - } - return ucfirst($name); - } } \ No newline at end of file diff --git a/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php b/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php index ad40c6dbd..aa0a8a1e7 100644 --- a/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php +++ b/core/lib/Thelia/Command/Output/TheliaConsoleOutput.php @@ -1,5 +1,25 @@ . */ +/* */ +/*************************************************************************************/ namespace Thelia\Command\Output;