diff options
-rw-r--r-- | composer.lock | 16 | ||||
-rw-r--r-- | core/Container/ContainerFactory.php | 28 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestingEnvironmentManipulator.php | 9 | ||||
-rw-r--r-- | tests/PHPUnit/bootstrap.php | 4 |
4 files changed, 49 insertions, 8 deletions
diff --git a/composer.lock b/composer.lock index 0e57d9dbad..8cd7b810d7 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "composer/ca-bundle", - "version": "1.2.10", + "version": "1.2.11", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "9fdb22c2e97a614657716178093cd1da90a64aa8" + "reference": "0b072d51c5a9c6f3412f7ea3ab043d6603cb2582" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/9fdb22c2e97a614657716178093cd1da90a64aa8", - "reference": "9fdb22c2e97a614657716178093cd1da90a64aa8", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/0b072d51c5a9c6f3412f7ea3ab043d6603cb2582", + "reference": "0b072d51c5a9c6f3412f7ea3ab043d6603cb2582", "shasum": "" }, "require": { @@ -29,7 +29,7 @@ "phpstan/phpstan": "^0.12.55", "psr/log": "^1.0", "symfony/phpunit-bridge": "^4.2 || ^5", - "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0" + "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0" }, "type": "library", "extra": { @@ -64,7 +64,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.2.10" + "source": "https://github.com/composer/ca-bundle/tree/1.2.11" }, "funding": [ { @@ -80,7 +80,7 @@ "type": "tidelift" } ], - "time": "2021-06-07T13:58:28+00:00" + "time": "2021-09-25T20:32:43+00:00" }, { "name": "composer/semver", @@ -4597,5 +4597,5 @@ "platform-overrides": { "php": "7.2.9" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.0.0" } diff --git a/core/Container/ContainerFactory.php b/core/Container/ContainerFactory.php index e556b721ae..80bb02906c 100644 --- a/core/Container/ContainerFactory.php +++ b/core/Container/ContainerFactory.php @@ -118,6 +118,11 @@ class ContainerFactory // add plugin environment configs $plugins = $this->pluginList->getActivatedPlugins(); + + if ($this->shouldSortPlugins()) { + $plugins = $this->sortPlugins($plugins); + } + foreach ($plugins as $plugin) { $baseDir = Manager::getPluginDirectory($plugin); @@ -132,6 +137,10 @@ class ContainerFactory { $plugins = $this->pluginList->getActivatedPlugins(); + if ($this->shouldSortPlugins()) { + $plugins = $this->sortPlugins($plugins); + } + foreach ($plugins as $plugin) { $baseDir = Manager::getPluginDirectory($plugin); @@ -142,6 +151,25 @@ class ContainerFactory } } + /** + * This method is required for Matomo Cloud to allow for custom sorting of plugin order + * + * @return bool + */ + private function shouldSortPlugins() + { + return isset($GLOBALS['MATOMO_SORT_PLUGINS']) && is_callable($GLOBALS['MATOMO_SORT_PLUGINS']); + } + + /** + * @param array $plugins + * @return array + */ + private function sortPlugins(array $plugins) + { + return call_user_func($GLOBALS['MATOMO_SORT_PLUGINS'], $plugins); + } + private function isDevelopmentModeEnabled() { $section = $this->settings->getSection('Development'); diff --git a/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php b/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php index 8a836b0e39..a7c36567cb 100644 --- a/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php +++ b/tests/PHPUnit/Framework/TestingEnvironmentManipulator.php @@ -33,6 +33,15 @@ class FakePluginList extends PluginList $section['Plugins'] = $this->plugins; $globalSettingsProvider->setSection('Plugins', $section); } + + public function sortPlugins(array $plugins) + { + if (isset($GLOBALS['MATOMO_SORT_PLUGINS']) && is_callable($GLOBALS['MATOMO_SORT_PLUGINS'])) { + return call_user_func($GLOBALS['MATOMO_SORT_PLUGINS'], parent::sortPlugins($plugins)); + } + + return parent::sortPlugins($plugins); + } } /** diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php index f74696e954..17e57c7837 100644 --- a/tests/PHPUnit/bootstrap.php +++ b/tests/PHPUnit/bootstrap.php @@ -25,6 +25,10 @@ if (!defined('PIWIK_INCLUDE_PATH')) { define('PIWIK_INCLUDE_PATH', PIWIK_PATH_TEST_TO_ROOT); } +if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) { + require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php'; +} + if (!defined('PIWIK_INCLUDE_SEARCH_PATH')) { define('PIWIK_INCLUDE_SEARCH_PATH', get_include_path() . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/vendor/bin' |