summaryrefslogtreecommitdiffstats
path: root/system/core/Hooks.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-03-05 23:28:55 +0100
committerAndrey Andreev <narf@devilix.net>2014-03-05 23:28:55 +0100
commit8351404ee1698076192317fd39f093c1f52bf48f (patch)
treeb814be909e78ed252d41c39147dd432216fc3d34 /system/core/Hooks.php
parent18767e31711656e9e2648fbe051b74ebbefd3f2e (diff)
Add support for simpler (Callable) hooks (issue #2917)
Diffstat (limited to 'system/core/Hooks.php')
-rw-r--r--system/core/Hooks.php11
1 files changed, 10 insertions, 1 deletions
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;
}