diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2008-11-28 21:22:34 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2008-11-28 21:22:34 +0000 |
commit | 6a76d6f747768106f8bccd8b74059371dbac615a (patch) | |
tree | 4075552e99833a5a721ca17f6815bacb7baa0fc4 /core/helpers | |
parent | 8b6ed6c477771e42d43ea0684e5139cf361b6cee (diff) |
Dynamically create the list of available modules. This permits new modules to be added without having to update the config.php file
Diffstat (limited to 'core/helpers')
-rw-r--r-- | core/helpers/module.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/helpers/module.php b/core/helpers/module.php index afba658a..599cc618 100644 --- a/core/helpers/module.php +++ b/core/helpers/module.php @@ -64,4 +64,26 @@ class module_Core { } } } + + public static function available($modules=array()) { + foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) { + if (empty($modules[basename(dirname(dirname($file)))])) { + $modules[basename(dirname(dirname($file)))] = 0; + } + } + + return $modules; + } + + public static function load_modules() { + Kohana::log("debug", "module::load_modules()"); + $modules = Kohana::config('core.modules'); + + foreach (array_keys(self::available()) as $module_name) { + $modules[] = MODPATH . $module_name; + } + Kohana::log("debug", print_r($modules, true)); + + Kohana::config_set('core.modules', $modules); + } } |