mirror of
https://github.com/processwire/processwire.git
synced 2025-08-17 04:04:13 +02:00
Update WireHooks to allow for (and ignore) an empty argument string "()" after hook definition (first argument) in addHook() methods.
This commit is contained in:
@@ -546,7 +546,13 @@ class WireHooks {
|
||||
}
|
||||
|
||||
$argOpen = strpos($method, '(');
|
||||
if($argOpen && strpos($method, ')') > $argOpen+1) {
|
||||
if($argOpen) {
|
||||
// arguments to match may be specified in method name
|
||||
$argClose = strpos($method, ')');
|
||||
if($argClose === $argOpen+1) {
|
||||
// method just has a "()" which can be discarded
|
||||
$method = rtrim($method, '() ');
|
||||
} else if($argClose > $argOpen+1) {
|
||||
// extract argument selector match string(s), arg 0: Something::something(selector_string)
|
||||
// or: Something::something(1:selector_string, 3:selector_string) matches arg 1 and 3.
|
||||
list($method, $argMatch) = explode('(', $method, 2);
|
||||
@@ -576,6 +582,7 @@ class WireHooks {
|
||||
}
|
||||
if(count($argMatch)) $options['argMatch'] = $argMatch;
|
||||
}
|
||||
}
|
||||
|
||||
$localHooks = $object->getLocalHooks();
|
||||
|
||||
|
Reference in New Issue
Block a user