diff --git a/CHANGELOG.md b/CHANGELOG.md index 1af10d62a659c1d7c6843a4f3d7a8595c49ba174..e25f611c3814e03484816f00c199e205d22696c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This is a changelog for Piwik platform developers. All changes for our HTTP API' ## Piwik 2.11.0 +### Breaking Changes +* The event `User.getLanguage` has been removed. + ### Deprecations * The following methods have been deprecated in favor of the new `Piwik\Intl` component: * `Piwik\Common::getContinentsList()`: use `RegionDataProvider::getContinentList()` instead @@ -11,14 +14,8 @@ This is a changelog for Piwik platform developers. All changes for our HTTP API' * `Piwik\Common::getLanguagesList()`: use `LanguageDataProvider::getLanguageList()` instead * `Piwik\Common::getLanguageToCountryList()`: use `LanguageDataProvider::getLanguageToCountryList()` instead * `Piwik\Metrics\Formatter::getCurrencyList()`: use `CurrencyDataProvider::getCurrencyList()` instead - -## Piwik 2.11.0 - -### Breaking Changes -* The event `User.getLanguage` has been removed. - -### Deprecations * The `Piwik\Translate` class has been deprecated in favor of `Piwik\Translation\Translator`. +* The `core:plugin` console has been deprecated in favor of the new `plugin:list`, `plugin:activate` and `plugin:deactivate` commands ## Piwik 2.10.0 diff --git a/plugins/CoreConsole/Commands/ManagePlugin.php b/plugins/CoreConsole/Commands/ManagePlugin.php index 00dcd29c0a7eea07454231214f13958ccfc12c8b..1c2a4de0b7c26962b51bb2e67aead772ba330a82 100644 --- a/plugins/CoreConsole/Commands/ManagePlugin.php +++ b/plugins/CoreConsole/Commands/ManagePlugin.php @@ -9,7 +9,10 @@ namespace Piwik\Plugins\CoreConsole\Commands; use Piwik\Plugin\ConsoleCommand; -use Piwik\Plugin\Manager; +use Piwik\Plugins\CorePluginsAdmin\Commands\ActivatePlugin; +use Piwik\Plugins\CorePluginsAdmin\Commands\DeactivatePlugin; +use Piwik\Plugins\CorePluginsAdmin\Commands\ListPlugins; +use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -17,6 +20,8 @@ use Symfony\Component\Console\Output\OutputInterface; /** * core:plugin console command. + * + * @deprecated This command has been replaced with `plugin:*` commands. */ class ManagePlugin extends ConsoleCommand { @@ -72,27 +77,32 @@ class ManagePlugin extends ConsoleCommand private function activatePlugin(InputInterface $input, OutputInterface $output, $plugin) { - Manager::getInstance()->activatePlugin($plugin, $input, $output); + $output->writeln('<comment>Warning: the command core:plugin is deprecated, use plugin:activate instead.</comment>'); - $output->writeln("Activated plugin <info>$plugin</info>"); + $command = new ActivatePlugin(); + $input = new ArrayInput(array( + 'plugin' => $plugin, + )); + return $command->run($input, $output); } private function deactivatePlugin(InputInterface $input, OutputInterface $output, $plugin) { - Manager::getInstance()->deactivatePlugin($plugin, $input, $output); + $output->writeln('<comment>Warning: the command core:plugin is deprecated, use plugin:deactivate instead.</comment>'); - $output->writeln("Deactivated plugin <info>$plugin</info>"); + $command = new DeactivatePlugin(); + $input = new ArrayInput(array( + 'plugin' => $plugin, + )); + return $command->run($input, $output); } - private function listPlugins(InputInterface $input, OutputInterface $output, $plugin) + private function listPlugins(InputInterface $input, OutputInterface $output) { - $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>"); - }; + $output->writeln('<comment>Warning: the command core:plugin is deprecated, use plugin:list instead.</comment>'); + + $command = new ListPlugins(); + $input = new ArrayInput(array()); + return $command->run($input, $output); } } \ No newline at end of file diff --git a/plugins/CorePluginsAdmin/Commands/ActivatePlugin.php b/plugins/CorePluginsAdmin/Commands/ActivatePlugin.php new file mode 100644 index 0000000000000000000000000000000000000000..7ef3c9bbeb06116551eb869103b12e5eccc26c77 --- /dev/null +++ b/plugins/CorePluginsAdmin/Commands/ActivatePlugin.php @@ -0,0 +1,44 @@ +<?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\CorePluginsAdmin\Commands; + +use Piwik\Plugin\ConsoleCommand; +use Piwik\Plugin\Manager; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * plugin:activate console command. + */ +class ActivatePlugin extends ConsoleCommand +{ + protected function configure() + { + $this->setName('plugin:activate'); + $this->setDescription('Activate a plugin.'); + $this->addArgument('plugin', InputArgument::REQUIRED, 'The plugin name.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $pluginManager = Manager::getInstance(); + + $plugin = $input->getArgument('plugin'); + + if ($pluginManager->isPluginActivated($plugin)) { + $output->writeln('<comment>The plugin is already activated.</comment>'); + return; + } + + $pluginManager->activatePlugin($plugin); + + $output->writeln("Activated plugin <info>$plugin</info>"); + } +} diff --git a/plugins/CorePluginsAdmin/Commands/DeactivatePlugin.php b/plugins/CorePluginsAdmin/Commands/DeactivatePlugin.php new file mode 100644 index 0000000000000000000000000000000000000000..33f5671e48ea67dbe486db4b565bee977994f1a3 --- /dev/null +++ b/plugins/CorePluginsAdmin/Commands/DeactivatePlugin.php @@ -0,0 +1,44 @@ +<?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\CorePluginsAdmin\Commands; + +use Piwik\Plugin\ConsoleCommand; +use Piwik\Plugin\Manager; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * plugin:deactivate console command. + */ +class DeactivatePlugin extends ConsoleCommand +{ + protected function configure() + { + $this->setName('plugin:deactivate'); + $this->setDescription('Deactivate a plugin.'); + $this->addArgument('plugin', InputArgument::REQUIRED, 'The plugin name.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $pluginManager = Manager::getInstance(); + + $plugin = $input->getArgument('plugin'); + + if (!$pluginManager->isPluginActivated($plugin)) { + $output->writeln('<comment>The plugin is already deactivated.</comment>'); + return; + } + + $pluginManager->deactivatePlugin($plugin); + + $output->writeln("Deactivated plugin <info>$plugin</info>"); + } +} diff --git a/plugins/CorePluginsAdmin/Commands/ListPlugins.php b/plugins/CorePluginsAdmin/Commands/ListPlugins.php new file mode 100644 index 0000000000000000000000000000000000000000..0fc132e589bf0bfa0a2ff892827cdd9475172b0c --- /dev/null +++ b/plugins/CorePluginsAdmin/Commands/ListPlugins.php @@ -0,0 +1,54 @@ +<?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\CorePluginsAdmin\Commands; + +use Piwik\Plugin\ConsoleCommand; +use Piwik\Plugin\Manager; +use Symfony\Component\Console\Helper\Table; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * plugin:list console command. + */ +class ListPlugins extends ConsoleCommand +{ + protected function configure() + { + $this->setName('plugin:list'); + $this->setDescription('List installed plugins.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $pluginManager = Manager::getInstance(); + + $plugins = $pluginManager->getInstalledPluginsName(); + + $plugins = array_map(function ($plugin) use ($pluginManager) { + return array( + '<info>' . $plugin . '</info>', + $pluginManager->isPluginBundledWithCore($plugin) ? 'Core' : 'Optional', + $pluginManager->isPluginActivated($plugin) ? 'Activated' : '<comment>Not activated</comment>', + ); + }, $plugins); + + // Sort Core plugins first + usort($plugins, function ($a, $b) { + return strcmp($a[1], $b[1]); + }); + + $table = new Table($output); + $table + ->setHeaders(array('Plugin', 'Core or optional?', 'Status')) + ->setRows($plugins) + ; + $table->render(); + } +}