diff options
author | Olav Morken <olav.morken@uninett.no> | 2008-08-20 09:11:30 +0000 |
---|---|---|
committer | Olav Morken <olav.morken@uninett.no> | 2008-08-20 09:11:30 +0000 |
commit | 4caf8a3b5d987ab262f49929701d22a60e4ea4a2 (patch) | |
tree | 5db2dd5d8f13fd75524f5653c340681f8e45dcc4 /lib/SimpleSAML/Module.php | |
parent | 25e43d4ff7c38806f90acfdc1b6b3b75da5d690d (diff) | |
download | simplesamlphp-4caf8a3b5d987ab262f49929701d22a60e4ea4a2.zip simplesamlphp-4caf8a3b5d987ab262f49929701d22a60e4ea4a2.tar.gz simplesamlphp-4caf8a3b5d987ab262f49929701d22a60e4ea4a2.tar.bz2 |
Add module hook interface.
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@822 44740490-163a-0410-bde0-09ae8108e29a
Diffstat (limited to 'lib/SimpleSAML/Module.php')
-rw-r--r-- | lib/SimpleSAML/Module.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php index 18a332b..9d0f1fd 100644 --- a/lib/SimpleSAML/Module.php +++ b/lib/SimpleSAML/Module.php @@ -146,6 +146,37 @@ class SimpleSAML_Module { return SimpleSAML_Utilities::selfURLhost() . '/' . $config->getBaseURL() . 'module.php/' . $resource; } + + /** + * Call a hook in all enabled modules. + * + * This function iterates over all enabled modules and calls a hook in each module. + * + * @param string $hook The name of the hook. + * @param mixed &$data The data which should be passed to each hook. Will be passed as a reference. + */ + public static function callHooks($hook, &$data = NULL) { + assert('is_string($hook)'); + + foreach (self::getModules() as $module) { + if (!self::isModuleEnabled($module)) { + continue; + } + + $hookfile = self::getModuleDir($module) . '/hooks/hook_' . $hook . '.php'; + if (!file_exists($hookfile)) { + continue; + } + + require_once($hookfile); + + $hookfunc = $module . '_hook_' . $hook; + assert('is_callable($hookfunc)'); + + $hookfunc($data); + } + } + } ?>
\ No newline at end of file |