diff options
Diffstat (limited to 'core/AssetManager/UIAssetFetcher.php')
-rw-r--r-- | core/AssetManager/UIAssetFetcher.php | 33 |
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); + } } } |