diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2019-01-30 03:28:01 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2019-01-30 03:28:01 +0300 |
commit | faa8c3892b93b37cb358b4efae5ee387317982a1 (patch) | |
tree | 33c1701d8bb86faba6a6467d59cda43cdcd5fb4a /core/Twig.php | |
parent | cec026c1dc1a77a3e714ee85c601301cd298b43f (diff) |
Don't hardcode plugins directory (#14043)
* do not hard code plugins directory
* remove method that is not needed for now
* use plugins directory in more places
Diffstat (limited to 'core/Twig.php')
-rw-r--r-- | core/Twig.php | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/core/Twig.php b/core/Twig.php index f2279ab35f..4b5f1e51ea 100644 --- a/core/Twig.php +++ b/core/Twig.php @@ -12,6 +12,7 @@ use Exception; use Piwik\Container\StaticContainer; use Piwik\DataTable\Filter\SafeDecodeLabel; use Piwik\Metrics\Formatter; +use Piwik\Plugin\Manager; use Piwik\Tracker\GoalManager; use Piwik\View\RenderTokenParser; use Piwik\Visualization\Sparkline; @@ -313,7 +314,7 @@ class Twig private function getDefaultThemeLoader() { $themeLoader = new Twig_Loader_Filesystem(array( - sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, \Piwik\Plugin\Manager::DEFAULT_THEME) + sprintf("%s%s/templates/", Manager::getPluginsDirectory(), \Piwik\Plugin\Manager::DEFAULT_THEME) ), PIWIK_DOCUMENT_ROOT.DIRECTORY_SEPARATOR); return $themeLoader; @@ -326,11 +327,12 @@ class Twig */ protected function getCustomThemeLoader(Plugin $theme) { - if (!file_exists(sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, $theme->getPluginName()))) { + $pluginsDir = Manager::getPluginsDirectory(); + if (!file_exists(sprintf("%s%s/templates/", $pluginsDir, $theme->getPluginName()))) { return false; } $themeLoader = new Twig_Loader_Filesystem(array( - sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, $theme->getPluginName()) + sprintf("%s%s/templates/", $pluginsDir, $theme->getPluginName()) ), PIWIK_DOCUMENT_ROOT.DIRECTORY_SEPARATOR); return $themeLoader; @@ -519,10 +521,12 @@ class Twig { $pluginManager = \Piwik\Plugin\Manager::getInstance(); $plugins = $pluginManager->getAllPluginsNames(); + + $pluginsDir = Manager::getPluginsDirectory(); foreach ($plugins as $name) { - $path = sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, $name); + $path = sprintf("%s%s/templates/", $pluginsDir, $name); if (is_dir($path)) { - $loader->addPath(PIWIK_INCLUDE_PATH . '/plugins/' . $name . '/templates', $name); + $loader->addPath($pluginsDir . $name . '/templates', $name); } } } @@ -536,10 +540,13 @@ class Twig { $pluginManager = \Piwik\Plugin\Manager::getInstance(); $plugins = $pluginManager->getAllPluginsNames(); + + $pluginsDir = Manager::getPluginsDirectory(); + foreach ($plugins as $name) { - $path = sprintf("%s/plugins/%s/templates/plugins/%s/", PIWIK_INCLUDE_PATH, $pluginName, $name); + $path = sprintf("%s%s/templates/plugins/%s/", $pluginsDir, $pluginName, $name); if (is_dir($path)) { - $loader->addPath(PIWIK_INCLUDE_PATH . '/plugins/' . $pluginName . '/templates/plugins/'. $name, $name); + $loader->addPath($pluginsDir . $pluginName . '/templates/plugins/'. $name, $name); } } } |