Add support for simpler (Callable) hooks (issue #2917)
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index f6eff4b..767dc4c 100644
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -154,7 +154,16 @@
*/
protected function _run_hook($data)
{
- if ( ! is_array($data))
+ // Closures/lambda functions and array($object, 'method') callables
+ if (is_callable($data))
+ {
+ is_array($data)
+ ? $data[0]->{$data[1]}()
+ : $data();
+
+ return TRUE;
+ }
+ elseif ( ! is_array($data))
{
return FALSE;
}