From 496a3e95f4a25af5eef6cc0448b774ed6bec56cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D?= Date: Wed, 8 Jan 2020 18:19:47 +0100 Subject: [PATCH] * [FIX] Avoid warning message on non-existing plugins directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rubén D --- lib/SP/Plugin/PluginManager.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/SP/Plugin/PluginManager.php b/lib/SP/Plugin/PluginManager.php index 335df5fb..834259e9 100644 --- a/lib/SP/Plugin/PluginManager.php +++ b/lib/SP/Plugin/PluginManager.php @@ -109,28 +109,32 @@ final class PluginManager */ public static function getPlugins() { - $dir = dir(PLUGINS_PATH); - $plugins = []; + if (is_dir(PLUGINS_PATH)) { + $dir = dir(PLUGINS_PATH); + $plugins = []; - if ($dir) { - while (false !== ($entry = $dir->read())) { - $pluginDir = PLUGINS_PATH . DIRECTORY_SEPARATOR . $entry; - $pluginFile = $pluginDir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Plugin.php'; + if ($dir) { + while (false !== ($entry = $dir->read())) { + $pluginDir = PLUGINS_PATH . DIRECTORY_SEPARATOR . $entry; + $pluginFile = $pluginDir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Plugin.php'; - if (strpos($entry, '.') === false - && is_dir($pluginDir) - && file_exists($pluginFile) - ) { - logger(sprintf('Plugin found: %s', $pluginDir)); + if (strpos($entry, '.') === false + && is_dir($pluginDir) + && file_exists($pluginFile) + ) { + logger(sprintf('Plugin found: %s', $pluginDir)); - $plugins[$entry] = require $pluginDir . DIRECTORY_SEPARATOR . 'base.php'; + $plugins[$entry] = require $pluginDir . DIRECTORY_SEPARATOR . 'base.php'; + } } + + $dir->close(); } - $dir->close(); + return $plugins; } - return $plugins; + return []; } /**