summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML/Module.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/SimpleSAML/Module.php')
-rw-r--r--lib/SimpleSAML/Module.php31
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