From 67d937b081e680c90952427d2b51fa95a8a055ab Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 29 Jul 2022 11:35:04 -0400 Subject: [PATCH] Add $hookable option to wireMethodExists() function, enabling it to detect cases where the method may exist in a ___hookable() variation --- wire/core/Functions.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wire/core/Functions.php b/wire/core/Functions.php index f6cd7574..32dada8f 100644 --- a/wire/core/Functions.php +++ b/wire/core/Functions.php @@ -986,14 +986,17 @@ function wireClassExists($className, $autoload = true) { * * #pw-group-class-helpers * - * @param string $className - * @param string $method + * @param string $className Class name or object + * @param string $method Method name + * @param bool $hookable Also return true if "method" exists in a hookable format "___method"? (default=false) 3.0.204+ * @return bool * */ -function wireMethodExists($className, $method) { +function wireMethodExists($className, $method, $hookable = false) { if(!is_object($className)) $className = wireClassName($className, true); - return method_exists($className, $method); + $exists = method_exists($className, $method); + if(!$exists && $hookable) $exists = method_exists($className, "___$method"); + return $exists; } /**