summaryrefslogtreecommitdiffstats
path: root/system/core/Hooks.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-01-08 12:55:35 +0100
committerAndrey Andreev <narf@devilix.net>2014-01-08 12:55:35 +0100
commita7522cc04b315dde1f468334aaeb7cee9f43b349 (patch)
treeeb78f02d7945e036e219b90673374f937fe8555b /system/core/Hooks.php
parentda8c7a5bb92b928c19918632d8cb8a06d0ea747d (diff)
parentbdfef073585d5267f2d568be6de3ffcde773e13b (diff)
Merge pull request #2800 from marcossffilho/develop
Store Hooks objects
Diffstat (limited to 'system/core/Hooks.php')
-rw-r--r--system/core/Hooks.php35
1 files changed, 29 insertions, 6 deletions
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index aa7ac1e5d..9bcc23a65 100644
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -54,6 +54,13 @@ class CI_Hooks {
public $hooks = array();
/**
+ * Array with class objects to use hooks methods
+ *
+ * @var array
+ */
+ protected $_objects = array();
+
+ /**
* In progress flag
*
* Determines whether hook is in progress, used to prevent infinte loops
@@ -195,15 +202,31 @@ class CI_Hooks {
// Call the requested class and/or function
if ($class !== FALSE)
{
- class_exists($class, FALSE) OR require_once($filepath);
-
- if ( ! class_exists($class, FALSE) OR ! method_exists($class, $function))
+ // The object is stored?
+ if (isset($this->_objects[$class]))
{
- return $this->_in_progress = FALSE;
+ if (method_exists($this->_objects[$class], $function))
+ {
+ $this->_objects[$class]->$function($params);
+ }
+ else
+ {
+ return $this->_in_progress = FALSE;
+ }
}
+ else
+ {
+ class_exists($class, FALSE) OR require_once($filepath);
- $HOOK = new $class();
- $HOOK->$function($params);
+ if ( ! class_exists($class, FALSE) OR ! method_exists($class, $function))
+ {
+ return $this->_in_progress = FALSE;
+ }
+
+ // Store the object and execute the method
+ $this->_objects[$class] = new $class();
+ $this->_objects[$class]->$function($params);
+ }
}
else
{