diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-10-15 09:52:09 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-10-15 09:52:09 +0400 |
commit | 631c3f1074c43265847971c25e6a4c6980cd23de (patch) | |
tree | 2fb59b6f30426aa81a82dbe5eda8653f9e50b213 /core/Plugin/ConsoleCommand.php | |
parent | c10d8cba3679b2c9f45640f1f3d04296d6e3299d (diff) |
Renaming Command to Plugin\ConsoleCommand
Diffstat (limited to 'core/Plugin/ConsoleCommand.php')
-rw-r--r-- | core/Plugin/ConsoleCommand.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/core/Plugin/ConsoleCommand.php b/core/Plugin/ConsoleCommand.php new file mode 100644 index 0000000000..132009d1bc --- /dev/null +++ b/core/Plugin/ConsoleCommand.php @@ -0,0 +1,49 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + * @category Piwik + * @package Piwik + */ +namespace Piwik\Plugin; + +use Piwik\Common; +use Symfony\Component\Console\Command\Command as SymfonyCommand; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * BaseClass for console commands. + * @package Piwik_Console + */ +class ConsoleCommand extends SymfonyCommand +{ + public function __construct($name = null) + { + if (!Common::isPhpCliMode()) { + throw new \RuntimeException('Only executable in CLI mode'); + } + + parent::__construct($name); + } + + public function writeSuccessMessage(OutputInterface $output, $messages) + { + $lengths = array_map('strlen', $messages); + $maxLen = max($lengths) + 4; + + $separator = str_pad('', $maxLen, '*'); + + $output->writeln(''); + $output->writeln('<info>' . $separator . '</info>'); + + foreach ($messages as $message) { + $output->writeln(' ' . $message . ' '); + } + + $output->writeln('<info>' . $separator . '</info>'); + $output->writeln(''); + } +} |