diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-03 16:09:23 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-03 16:09:23 +0000 |
commit | 9b68fd46b224cb26e592fc977b0019b01bee3d23 (patch) | |
tree | 86f84b2cf562903ac01549951ce8788c44433f8c /core/helpers | |
parent | 0408a0096acbbeac7439878654ecbbf191e5ddb6 (diff) |
Add the ability for modules to define hooks. The challenge is that
when the hooks are run, we haven't added all the installed modules to
the path, So if a module defines a hook it will never be run.
This change runs any module defined hooks as part of the gallery initialization.
Diffstat (limited to 'core/helpers')
-rw-r--r-- | core/helpers/module.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/helpers/module.php b/core/helpers/module.php index d5dea099..49f0fdea 100644 --- a/core/helpers/module.php +++ b/core/helpers/module.php @@ -165,13 +165,27 @@ class module_Core { } try { + $hooks = array(); foreach ($modules as $module) { self::$module_names[$module->name] = $module->name; self::$modules[$module->name] = $module; $kohana_modules[] = MODPATH . $module->name; + $module_path = MODPATH . $module->name; + $kohana_modules[] = $module_path; + if (file_exists("$module_path/hooks") && + ($hook_files = glob("$module_path/hooks/*.php")) !== false) { + $hooks = array_merge($hooks, $hook_files); + } } Kohana::config_set("core.modules", $kohana_modules); + /* + * Kohana loads the hooks before all the installed module paths are defined, so lets call + * any module hooks now + */ + foreach($hooks as $hook) { + include($hook); + } } catch (Exception $e) { self::$module_names = array(); self::$modules = array(); |