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 /core/AssetManager/UIAssetFetcher.php
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 'core/AssetManager/UIAssetFetcher.php')
-rw-r--r--core/AssetManager/UIAssetFetcher.php33
1 files changed, 32 insertions, 1 deletions
diff --git a/core/AssetManager/UIAssetFetcher.php b/core/AssetManager/UIAssetFetcher.php
index 0b8e9b3a55..c9086b0e71 100644
--- a/core/AssetManager/UIAssetFetcher.php
+++ b/core/AssetManager/UIAssetFetcher.php
@@ -9,6 +9,7 @@
namespace Piwik\AssetManager;
use Piwik\AssetManager\UIAsset\OnDiskUIAsset;
+use Piwik\Plugin\Manager;
use Piwik\Theme;
abstract class UIAssetFetcher
@@ -89,9 +90,39 @@ abstract class UIAssetFetcher
private function populateCatalog()
{
+ $pluginBaseDir = Manager::getPluginsDirectory();
+ $pluginWebDirectories = Manager::getAlternativeWebRootDirectories();
+ $matomoRootDir = $this->getBaseDirectory();
+
foreach ($this->fileLocations as $fileLocation) {
+ $fileAbsolute = $matomoRootDir . '/' . $fileLocation;
+
$newUIAsset = new OnDiskUIAsset($this->getBaseDirectory(), $fileLocation);
- $this->catalog->addUIAsset($newUIAsset);
+ if ($newUIAsset->exists()) {
+ $this->catalog->addUIAsset($newUIAsset);
+ continue;
+ }
+
+ $found = false;
+
+ if (strpos($fileAbsolute, $pluginBaseDir) === 0) {
+ // we iterate over all custom plugin directories only for plugin files, not libs files (not needed there)
+ foreach ($pluginWebDirectories as $pluginDirectory => $relative) {
+ $fileTest = str_replace($pluginBaseDir, $pluginDirectory, $fileAbsolute);
+ $newFileRelative = str_replace($pluginDirectory, '', $fileTest);
+ $testAsset = new OnDiskUIAsset($pluginDirectory, $newFileRelative, $relative);
+ if ($testAsset->exists()) {
+ $this->catalog->addUIAsset($testAsset);
+ $found = true;
+ break;
+ }
+ }
+ }
+
+ if (!$found) {
+ // we add it anyway so it'll trigger an error about the missing file
+ $this->catalog->addUIAsset($newUIAsset);
+ }
}
}