From 2570d6c86d37d62355008abb7473f169df0abc34 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Mon, 19 Dec 2016 12:34:59 -0500 Subject: [PATCH] Fix issue processwire/processwire-issues#121 --- wire/core/WireHooks.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/wire/core/WireHooks.php b/wire/core/WireHooks.php index 47816c9c..6d1f0233 100644 --- a/wire/core/WireHooks.php +++ b/wire/core/WireHooks.php @@ -276,13 +276,27 @@ class WireHooks { protected function isHookedOrParents($class, $method, $type = 'either') { $property = ''; - $className = is_object($class) ? wireClassName($class) : $class; + if(is_object($class)) { + $className = wireClassName($class); + $object = $class; + } else { + $className = $class; + $object = null; + } + if($object) { + // first check local hooks attached to this instance + $localHooks = $object->getLocalHooks(); + if(!empty($localHooks[rtrim($method, '()')])) { + return true; + } + } + if($type == 'method' || $type == 'either') { if(strpos($method, '(') === false) $method .= '()'; if($type == 'either') $property = rtrim($method, '()'); } - + if($type == 'method') { if(!isset($this->hookMethodCache[$method])) return false; // not hooked for any class $hooked = isset($this->hookClassMethodCache["$className::$method"]);