Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-10-15 09:52:09 +0400
committermattab <matthieu.aubry@gmail.com>2013-10-15 09:52:09 +0400
commit631c3f1074c43265847971c25e6a4c6980cd23de (patch)
tree2fb59b6f30426aa81a82dbe5eda8653f9e50b213 /core/Plugin/ConsoleCommand.php
parentc10d8cba3679b2c9f45640f1f3d04296d6e3299d (diff)
Renaming Command to Plugin\ConsoleCommand
Diffstat (limited to 'core/Plugin/ConsoleCommand.php')
-rw-r--r--core/Plugin/ConsoleCommand.php49
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('');
+ }
+}