mirror of
https://github.com/Mibew/mibew.git
synced 2025-04-18 04:47:24 +03:00
Statically cache results of Plugin\Utils::discoverPlugins
This commit is contained in:
parent
dca7c2c520
commit
428c592139
@ -37,13 +37,17 @@ class Utils
|
|||||||
*/
|
*/
|
||||||
public static function discoverPlugins()
|
public static function discoverPlugins()
|
||||||
{
|
{
|
||||||
|
static $plugins = null;
|
||||||
|
|
||||||
|
if (is_null($plugins)) {
|
||||||
|
$plugins = array();
|
||||||
|
|
||||||
$pattern = MIBEW_FS_ROOT . str_replace(
|
$pattern = MIBEW_FS_ROOT . str_replace(
|
||||||
'/',
|
'/',
|
||||||
DIRECTORY_SEPARATOR,
|
DIRECTORY_SEPARATOR,
|
||||||
'/plugins/*/Mibew/Plugin/*/Plugin.php'
|
'/plugins/*/Mibew/Plugin/*/Plugin.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
$plugins = array();
|
|
||||||
foreach (glob($pattern) as $plugin_file) {
|
foreach (glob($pattern) as $plugin_file) {
|
||||||
// Build plugin's name and validate it.
|
// Build plugin's name and validate it.
|
||||||
$parts = array_reverse(explode(DIRECTORY_SEPARATOR, $plugin_file));
|
$parts = array_reverse(explode(DIRECTORY_SEPARATOR, $plugin_file));
|
||||||
@ -63,6 +67,7 @@ class Utils
|
|||||||
|
|
||||||
$plugins[] = $plugin_name;
|
$plugins[] = $plugin_name;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $plugins;
|
return $plugins;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user