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:
authorMichał Gaździk <m.gazdzik@clearcode.cc>2014-10-27 12:47:16 +0300
committerMichał Gaździk <m.gazdzik@clearcode.cc>2014-10-27 12:47:16 +0300
commit1f0d4a019fe3b6fc01dd80c9ba4ff371ffb52936 (patch)
tree6da2670cd8ac1421e8940abe8257770e3c5db994 /plugins/CoreConsole
parentf4dbc61263d401a003c300847af19cf4b1f5db13 (diff)
added example archiver for ExamplePlugin and command for generating archiver
Diffstat (limited to 'plugins/CoreConsole')
-rw-r--r--plugins/CoreConsole/Commands/GenerateArchiver.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/CoreConsole/Commands/GenerateArchiver.php b/plugins/CoreConsole/Commands/GenerateArchiver.php
new file mode 100644
index 0000000000..ad4a32e6f0
--- /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 GenerateApi 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 API 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' => $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 adding API 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);
+ }
+
+}