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:
authorThomas Steur <tsteur@users.noreply.github.com>2019-03-15 01:24:36 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2019-03-15 01:24:36 +0300
commit6395855aa7f3813cc7f413a18d31505ea26ba32a (patch)
tree2a3157954dd3c29cc024bf7093df53b63be94dd6 /plugins/CoreConsole
parentd7c932710e690d87ea62c3ec94ae65fa5bd05b05 (diff)
Support multiple plugin paths (#14051)
* do not hard code plugins directory * remove method that is not needed for now * use plugins directory in more places * some work on supporting multiple plugin directories * use more unique name * couple fixes * and another fix * sort plugins * adjust languagesmanager * adjust more usages * Update Manager.php * adding a plugin to test * more tests * make sure plugin resources can be located in custom directory * adding more tests * rewrite image paths * handle more cases * add tests * make sure to load plugin * trying to fix test * trying it this way * load plugin * fix ui test? * testing if tests succeed this way * another test * load custom dir plugin * load plugin in ui fixture * change the update statement * remove update script * delete column * fix ui test * make it work for tests * fix some tests * Fix merge.
Diffstat (limited to 'plugins/CoreConsole')
-rw-r--r--plugins/CoreConsole/Commands/GenerateAngularComponent.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateAngularDirective.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateApi.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateArchiver.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateCommand.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateController.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateDimension.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateMenu.php3
-rw-r--r--plugins/CoreConsole/Commands/GeneratePlugin.php4
-rw-r--r--plugins/CoreConsole/Commands/GeneratePluginBase.php34
-rw-r--r--plugins/CoreConsole/Commands/GenerateReport.php2
-rw-r--r--plugins/CoreConsole/Commands/GenerateScheduledTask.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateSettings.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateTest.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateUpdate.php2
-rw-r--r--plugins/CoreConsole/Commands/GenerateVisualizationPlugin.php3
-rw-r--r--plugins/CoreConsole/Commands/GenerateWidget.php3
17 files changed, 47 insertions, 34 deletions
diff --git a/plugins/CoreConsole/Commands/GenerateAngularComponent.php b/plugins/CoreConsole/Commands/GenerateAngularComponent.php
index 081da16b00..c5a7de2ef5 100644
--- a/plugins/CoreConsole/Commands/GenerateAngularComponent.php
+++ b/plugins/CoreConsole/Commands/GenerateAngularComponent.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -38,7 +39,7 @@ class GenerateAngularComponent extends GenerateAngularConstructBase
. $pluginName);
}
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExamplePlugin');
$replace = array(
'ExamplePlugin' => $pluginName,
'example-component' => $componentLower,
diff --git a/plugins/CoreConsole/Commands/GenerateAngularDirective.php b/plugins/CoreConsole/Commands/GenerateAngularDirective.php
index c5c0a767c7..605f417dfd 100644
--- a/plugins/CoreConsole/Commands/GenerateAngularDirective.php
+++ b/plugins/CoreConsole/Commands/GenerateAngularDirective.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -39,7 +40,7 @@ class GenerateAngularDirective extends GenerateAngularConstructBase
throw new \Exception('The AngularJS directive ' . $directiveLower . ' already exists in plugin ' . $pluginName);
}
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExamplePlugin');
$replace = array(
'ExamplePlugin' => $pluginName,
'directive-component' => $directiveLower,
diff --git a/plugins/CoreConsole/Commands/GenerateApi.php b/plugins/CoreConsole/Commands/GenerateApi.php
index 9fc3c5b7ae..cbaaa9cdc9 100644
--- a/plugins/CoreConsole/Commands/GenerateApi.php
+++ b/plugins/CoreConsole/Commands/GenerateApi.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -29,7 +30,7 @@ class GenerateApi extends GeneratePluginBase
$pluginName = $this->getPluginName($input, $output);
$this->checkAndUpdateRequiredPiwikVersion($pluginName, $output);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExamplePlugin');
$replace = array('ExamplePlugin' => $pluginName);
$whitelistFiles = array('/API.php');
diff --git a/plugins/CoreConsole/Commands/GenerateArchiver.php b/plugins/CoreConsole/Commands/GenerateArchiver.php
index 29bcee7bb6..18e43c11e8 100644
--- a/plugins/CoreConsole/Commands/GenerateArchiver.php
+++ b/plugins/CoreConsole/Commands/GenerateArchiver.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -29,7 +30,7 @@ class GenerateArchiver extends GeneratePluginBase
$pluginName = $this->getPluginName($input, $output);
$this->checkAndUpdateRequiredPiwikVersion($pluginName, $output);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExamplePlugin');
$replace = array('ExamplePlugin' => $pluginName, 'EXAMPLEPLUGIN' => strtoupper($pluginName));
$whitelistFiles = array('/Archiver.php');
diff --git a/plugins/CoreConsole/Commands/GenerateCommand.php b/plugins/CoreConsole/Commands/GenerateCommand.php
index 9fe95c06d3..243a61dc75 100644
--- a/plugins/CoreConsole/Commands/GenerateCommand.php
+++ b/plugins/CoreConsole/Commands/GenerateCommand.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -32,7 +33,7 @@ class GenerateCommand extends GeneratePluginBase
$commandName = $this->getCommandName($input, $output);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExampleCommand';
+ $exampleFolder = Manager::getPluginDirectory('ExampleCommand');
$replace = array(
'ExampleCommandDescription' => $commandName,
'ExampleCommand' => $pluginName,
diff --git a/plugins/CoreConsole/Commands/GenerateController.php b/plugins/CoreConsole/Commands/GenerateController.php
index d5c3b84078..863c3fe867 100644
--- a/plugins/CoreConsole/Commands/GenerateController.php
+++ b/plugins/CoreConsole/Commands/GenerateController.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -29,7 +30,7 @@ class GenerateController extends GeneratePluginBase
$pluginName = $this->getPluginName($input, $output);
$this->checkAndUpdateRequiredPiwikVersion($pluginName, $output);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExamplePlugin');
$replace = array('ExamplePlugin' => $pluginName);
$whitelistFiles = array('/Controller.php', '/templates', '/templates/index.twig');
diff --git a/plugins/CoreConsole/Commands/GenerateDimension.php b/plugins/CoreConsole/Commands/GenerateDimension.php
index 900b6c0533..bc10670cde 100644
--- a/plugins/CoreConsole/Commands/GenerateDimension.php
+++ b/plugins/CoreConsole/Commands/GenerateDimension.php
@@ -11,6 +11,7 @@ namespace Piwik\Plugins\CoreConsole\Commands;
use Piwik\Common;
use Piwik\DbHelper;
+use Piwik\Plugin\Manager;
use Piwik\Plugin\Report;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -53,7 +54,7 @@ class GenerateDimension extends GeneratePluginBase
$dimensionClassName = $this->getDimensionClassName($dimensionName);
$translatedDimensionName = $this->makeTranslationIfPossible($pluginName, ucfirst($dimensionName));
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExampleTracker';
+ $exampleFolder = Manager::getPluginDirectory('ExampleTracker');
$replace = array('example_action_dimension' => strtolower($columnName),
'example_visit_dimension' => strtolower($columnName),
'example_conversion_dimension' => strtolower($columnName),
diff --git a/plugins/CoreConsole/Commands/GenerateMenu.php b/plugins/CoreConsole/Commands/GenerateMenu.php
index 868a47b8f3..e6539d7c9f 100644
--- a/plugins/CoreConsole/Commands/GenerateMenu.php
+++ b/plugins/CoreConsole/Commands/GenerateMenu.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -29,7 +30,7 @@ class GenerateMenu extends GeneratePluginBase
$pluginName = $this->getPluginName($input, $output);
$this->checkAndUpdateRequiredPiwikVersion($pluginName, $output);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExamplePlugin');
$replace = array('ExamplePlugin' => $pluginName);
$whitelistFiles = array('/Menu.php');
diff --git a/plugins/CoreConsole/Commands/GeneratePlugin.php b/plugins/CoreConsole/Commands/GeneratePlugin.php
index a214a40a5f..ad29a39a94 100644
--- a/plugins/CoreConsole/Commands/GeneratePlugin.php
+++ b/plugins/CoreConsole/Commands/GeneratePlugin.php
@@ -47,7 +47,7 @@ class GeneratePlugin extends GeneratePluginBase
$exampleDescription = $info['description'];
if ($isTheme) {
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExampleTheme';
+ $exampleFolder = Plugin\Manager::getPluginDirectory('ExampleTheme');
$replace = array(
'ExampleTheme' => $pluginName,
$exampleDescription => $description,
@@ -58,7 +58,7 @@ class GeneratePlugin extends GeneratePluginBase
} else {
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Plugin\Manager::getPluginDirectory('ExamplePlugin');
$replace = array(
'ExamplePlugin' => $pluginName,
$exampleDescription => $description,
diff --git a/plugins/CoreConsole/Commands/GeneratePluginBase.php b/plugins/CoreConsole/Commands/GeneratePluginBase.php
index 211dc94db3..6d99e13a7b 100644
--- a/plugins/CoreConsole/Commands/GeneratePluginBase.php
+++ b/plugins/CoreConsole/Commands/GeneratePluginBase.php
@@ -14,6 +14,7 @@ use Piwik\Development;
use Piwik\Filesystem;
use Piwik\Plugin\ConsoleCommand;
use Piwik\Plugin\Dependency;
+use Piwik\Plugin\Manager;
use Piwik\Version;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -27,12 +28,7 @@ abstract class GeneratePluginBase extends ConsoleCommand
public function getPluginPath($pluginName)
{
- return PIWIK_INCLUDE_PATH . $this->getRelativePluginPath($pluginName);
- }
-
- private function getRelativePluginPath($pluginName)
- {
- return '/plugins/' . $pluginName;
+ return Manager::getPluginDirectory($pluginName);
}
private function createFolderWithinPluginIfNotExists($pluginNameOrCore, $folder)
@@ -111,7 +107,7 @@ abstract class GeneratePluginBase extends ConsoleCommand
protected function checkAndUpdateRequiredPiwikVersion($pluginName, OutputInterface $output)
{
$pluginJsonPath = $this->getPluginPath($pluginName) . '/plugin.json';
- $relativePluginJson = $this->getRelativePluginPath($pluginName) . '/plugin.json';
+ $relativePluginJson = Manager::getPluginDirectory($pluginName) . '/plugin.json';
if (!file_exists($pluginJsonPath) || !is_writable($pluginJsonPath)) {
return;
@@ -326,11 +322,13 @@ abstract class GeneratePluginBase extends ConsoleCommand
protected function getPluginNames()
{
- $pluginDirs = \_glob(PIWIK_INCLUDE_PATH . '/plugins/*', GLOB_ONLYDIR);
-
$pluginNames = array();
- foreach ($pluginDirs as $pluginDir) {
- $pluginNames[] = basename($pluginDir);
+ foreach (Manager::getPluginsDirectories() as $pluginsDir) {
+ $pluginDirs = \_glob($pluginsDir . '*', GLOB_ONLYDIR);
+
+ foreach ($pluginDirs as $pluginDir) {
+ $pluginNames[] = basename($pluginDir);
+ }
}
return $pluginNames;
@@ -338,15 +336,17 @@ abstract class GeneratePluginBase extends ConsoleCommand
protected function getPluginNamesHavingNotSpecificFile($filename)
{
- $pluginDirs = \_glob(PIWIK_INCLUDE_PATH . '/plugins/*', GLOB_ONLYDIR);
-
$pluginNames = array();
- foreach ($pluginDirs as $pluginDir) {
- if (!file_exists($pluginDir . '/' . $filename)) {
- $pluginNames[] = basename($pluginDir);
+ foreach (Manager::getPluginsDirectories() as $pluginsDir) {
+ $pluginDirs = \_glob($pluginsDir . '*', GLOB_ONLYDIR);
+
+ foreach ($pluginDirs as $pluginDir) {
+ if (!file_exists($pluginDir . '/' . $filename)) {
+ $pluginNames[] = basename($pluginDir);
+ }
}
- }
+ }
return $pluginNames;
}
diff --git a/plugins/CoreConsole/Commands/GenerateReport.php b/plugins/CoreConsole/Commands/GenerateReport.php
index 1faa1c9dc6..b30ec7d61e 100644
--- a/plugins/CoreConsole/Commands/GenerateReport.php
+++ b/plugins/CoreConsole/Commands/GenerateReport.php
@@ -45,7 +45,7 @@ class GenerateReport extends GeneratePluginBase
$order = $this->getOrder($category);
$apiName = $this->getApiName($reportName);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExampleReport';
+ $exampleFolder = Manager::getPluginDirectory('ExampleReport');
$replace = array('GetExampleReport' => ucfirst($apiName),
'getExampleReport' => lcfirst($apiName),
'getApiReport' => lcfirst($apiName),
diff --git a/plugins/CoreConsole/Commands/GenerateScheduledTask.php b/plugins/CoreConsole/Commands/GenerateScheduledTask.php
index 8337e7146f..2317805aec 100644
--- a/plugins/CoreConsole/Commands/GenerateScheduledTask.php
+++ b/plugins/CoreConsole/Commands/GenerateScheduledTask.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -29,7 +30,7 @@ class GenerateScheduledTask extends GeneratePluginBase
$pluginName = $this->getPluginName($input, $output);
$this->checkAndUpdateRequiredPiwikVersion($pluginName, $output);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExamplePlugin');
$replace = array('ExamplePlugin' => $pluginName);
$whitelistFiles = array('/Tasks.php');
diff --git a/plugins/CoreConsole/Commands/GenerateSettings.php b/plugins/CoreConsole/Commands/GenerateSettings.php
index a5b0c4e077..245446fa6a 100644
--- a/plugins/CoreConsole/Commands/GenerateSettings.php
+++ b/plugins/CoreConsole/Commands/GenerateSettings.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -33,7 +34,7 @@ class GenerateSettings extends GeneratePluginBase
$pluginName = $this->getPluginName($input, $output, $settingsType, $settingsFilename);
$this->checkAndUpdateRequiredPiwikVersion($pluginName, $output);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExampleSettingsPlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExampleSettingsPlugin');
$replace = array('ExampleSettingsPlugin' => $pluginName);
$whitelistFiles = array('/' . $settingsFilename);
diff --git a/plugins/CoreConsole/Commands/GenerateTest.php b/plugins/CoreConsole/Commands/GenerateTest.php
index 95dac4cfbd..b489c74d1d 100644
--- a/plugins/CoreConsole/Commands/GenerateTest.php
+++ b/plugins/CoreConsole/Commands/GenerateTest.php
@@ -10,6 +10,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
use Piwik\Common;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -33,7 +34,7 @@ class GenerateTest extends GeneratePluginBase
$testType = $this->getTestType($input, $output);
$testName = $this->getTestName($input, $output, $testType);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExamplePlugin');
$replace = array(
'ExamplePlugin' => $pluginName,
'SimpleTest' => $testName,
diff --git a/plugins/CoreConsole/Commands/GenerateUpdate.php b/plugins/CoreConsole/Commands/GenerateUpdate.php
index 826448de38..9dffe019f2 100644
--- a/plugins/CoreConsole/Commands/GenerateUpdate.php
+++ b/plugins/CoreConsole/Commands/GenerateUpdate.php
@@ -33,7 +33,7 @@ class GenerateUpdate extends GeneratePluginBase
$namespace = $this->getNamespace($component);
$className = $this->getUpdateClassName($component, $version);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Plugin\Manager::getPluginDirectory('ExamplePlugin');
$replace = array('Piwik\Plugins\ExamplePlugin\Updates' => $namespace,
'ExamplePlugin' => $component,
'Updates_0_0_2' => $className,
diff --git a/plugins/CoreConsole/Commands/GenerateVisualizationPlugin.php b/plugins/CoreConsole/Commands/GenerateVisualizationPlugin.php
index 92a5027716..807646b2c2 100644
--- a/plugins/CoreConsole/Commands/GenerateVisualizationPlugin.php
+++ b/plugins/CoreConsole/Commands/GenerateVisualizationPlugin.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
+use Piwik\Plugin\Manager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -39,7 +40,7 @@ class GenerateVisualizationPlugin extends GeneratePlugin
$this->generatePluginFolder($pluginName);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExampleVisualization';
+ $exampleFolder = Manager::getPluginDirectory('ExampleVisualization');
$replace = array(
'SimpleTable' => $visualizationName,
'simpleTable' => lcfirst($visualizationName),
diff --git a/plugins/CoreConsole/Commands/GenerateWidget.php b/plugins/CoreConsole/Commands/GenerateWidget.php
index 2b603aa1fa..a66efba3c6 100644
--- a/plugins/CoreConsole/Commands/GenerateWidget.php
+++ b/plugins/CoreConsole/Commands/GenerateWidget.php
@@ -10,6 +10,7 @@
namespace Piwik\Plugins\CoreConsole\Commands;
use Piwik\Piwik;
+use Piwik\Plugin\Manager;
use Piwik\Translate;
use Piwik\Widget\WidgetsList;
use Symfony\Component\Console\Input\InputInterface;
@@ -45,7 +46,7 @@ class GenerateWidget extends GeneratePluginBase
$widgetMethod = $this->getWidgetMethodName($widgetName);
$widgetClass = ucfirst($widgetMethod);
- $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin';
+ $exampleFolder = Manager::getPluginDirectory('ExamplePlugin');
$replace = array('ExamplePlugin' => $pluginName,
'MyExampleWidget' => $widgetClass,
'Example Widget Name' => $this->makeTranslationIfPossible($pluginName, $widgetName),