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:
authorMatthieu Napoli <matthieu@mnapoli.fr>2014-11-14 01:21:21 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2014-11-14 01:21:21 +0300
commit90129349049e9d9c941b7b69000998b588aa9f66 (patch)
treee299c056b842a2966bec74a93b017610a516225e /plugins/CoreConsole
parenta10ac7c953196313ee6391db3a20a4507cd53c50 (diff)
parent04b435910ca020a6034b38925afb05322f0fdb26 (diff)
Merge branch 'master' into tmp-path
Diffstat (limited to 'plugins/CoreConsole')
-rw-r--r--plugins/CoreConsole/Commands/GenerateArchiver.php59
-rw-r--r--plugins/CoreConsole/Commands/ManagePlugin.php34
2 files changed, 91 insertions, 2 deletions
diff --git a/plugins/CoreConsole/Commands/GenerateArchiver.php b/plugins/CoreConsole/Commands/GenerateArchiver.php
new file mode 100644
index 0000000000..bbbdb85dfc
--- /dev/null
+++ b/plugins/CoreConsole/Commands/GenerateArchiver.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+
+namespace Piwik\Plugins\CoreConsole\Commands;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ */
+class GenerateArchiver extends GeneratePluginBase
+{
+ protected function configure()
+ {
+ $this->setName('generate:archiver')
+ ->setDescription('Adds an Archiver to an existing plugin')
+ ->addOption('pluginname', null, InputOption::VALUE_REQUIRED, 'The name of an existing plugin which does not have an Archiver yet');
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $pluginName = $this->getPluginName($input, $output);
+ $this->checkAndUpdateRequiredPiwikVersion($pluginName, $output);
+
+ $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $replace = array('ExamplePlugin' => ucfirst($pluginName), 'EXAMPLEPLUGIN' => strtoupper($pluginName));
+ $whitelistFiles = array('/Archiver.php');
+
+ $this->copyTemplateToPlugin($exampleFolder, $pluginName, $replace, $whitelistFiles);
+
+ $this->writeSuccessMessage($output, array(
+ sprintf('Archiver.php for %s generated.', $pluginName),
+ 'You can now start implementing Archiver methods',
+ 'Enjoy!'
+ ));
+ }
+
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ * @return array
+ * @throws \RuntimeException
+ */
+ protected function getPluginName(InputInterface $input, OutputInterface $output)
+ {
+ $pluginNames = $this->getPluginNamesHavingNotSpecificFile('Archiver.php');
+ $invalidName = 'You have to enter the name of an existing plugin which does not already have an Archiver';
+
+ return $this->askPluginNameAndValidate($input, $output, $pluginNames, $invalidName);
+ }
+
+}
diff --git a/plugins/CoreConsole/Commands/ManagePlugin.php b/plugins/CoreConsole/Commands/ManagePlugin.php
index 0ceacbef3b..00dcd29c0a 100644
--- a/plugins/CoreConsole/Commands/ManagePlugin.php
+++ b/plugins/CoreConsole/Commands/ManagePlugin.php
@@ -26,12 +26,13 @@ class ManagePlugin extends ConsoleCommand
{
$this->setName('core:plugin');
$this->setDescription("Perform various actions regarding one or more plugins.");
- $this->addArgument("operation", InputArgument::REQUIRED, "Operation to apply (can be 'activate' or 'deactivate').");
- $this->addArgument("plugins", InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'Plugin name(s) to activate.');
+ $this->addArgument("operation", InputArgument::REQUIRED, "Operation to apply (can be 'activate' or 'deactivate' or 'list').");
+ $this->addArgument("plugins", InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Plugin name(s) to activate.');
$this->addOption('domain', null, InputOption::VALUE_REQUIRED, "The domain to activate the plugin for.");
$this->operations['activate'] = 'activatePlugin';
$this->operations['deactivate'] = 'deactivatePlugin';
+ $this->operations['list'] = 'listPlugins';
}
/**
@@ -47,6 +48,23 @@ class ManagePlugin extends ConsoleCommand
}
$fn = $this->operations[$operation];
+
+
+ if($fn == 'listPlugins') {
+ call_user_func(array($this, $fn), $input, $output);
+ } else {
+ $this->applyOperationToEachPlugin($input, $output, $plugins, $fn);
+ }
+ }
+
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ * @param $plugins
+ * @param $fn
+ */
+ protected function applyOperationToEachPlugin(InputInterface $input, OutputInterface $output, $plugins, $fn)
+ {
foreach ($plugins as $plugin) {
call_user_func(array($this, $fn), $input, $output, $plugin);
}
@@ -65,4 +83,16 @@ class ManagePlugin extends ConsoleCommand
$output->writeln("Deactivated plugin <info>$plugin</info>");
}
+
+ private function listPlugins(InputInterface $input, OutputInterface $output, $plugin)
+ {
+ $plugins = Manager::getInstance()->getPluginsLoadedAndActivated();
+
+ $count = count($plugins);
+ $output->writeln("Listing $count activated plugins:");
+ foreach($plugins as $plugin) {
+ $pluginName = $plugin->getPluginName();
+ $output->writeln("<info>$pluginName</info>");
+ };
+ }
} \ No newline at end of file