From 8351404ee1698076192317fd39f093c1f52bf48f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 6 Mar 2014 00:28:55 +0200 Subject: Add support for simpler (Callable) hooks (issue #2917) --- system/core/Hooks.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Hooks.php b/system/core/Hooks.php index f6eff4b3f..767dc4cd9 100644 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -154,7 +154,16 @@ class CI_Hooks { */ 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; } -- cgit v1.2.3-24-g4f1b