1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-15 11:14:12 +02:00

Add optional support for an executeUnknown() method to Process modules. This method is called when an unknown method is requested. It is not enabled by default, unless you add an executeUnknown() method to the Process module.

This commit is contained in:
Ryan Cramer
2019-06-12 15:34:18 -04:00
parent 2ba96d3f2b
commit d977cabb82
2 changed files with 23 additions and 6 deletions

View File

@@ -151,6 +151,19 @@ abstract class Process extends WireData implements Module {
*/
public function ___executed($method) { }
/*
* Add this method to your Process module if you want a catch-all fallback
*
* It should check $input->urlSegment1 for the method that was requested.
* This is commented out here since it is not used by Process modules unless manually added.
*
* @since 3.0.133
* @return string|array
*
public function ___executeUnknown() {
}
*/
/**
* Get a value stored in this Process
*

View File

@@ -291,12 +291,16 @@ class ProcessController extends Wire {
}
}
if($forceFail) return '';
if($method === 'executed') return '';
if(method_exists($process, $method)) return $method;
if(method_exists($process, "___$method")) return $method;
if($process->hasHook($method . '()')) return $method;
if(!$forceFail) {
if($method === 'executed') return '';
if(method_exists($process, $method)) return $method;
if(method_exists($process, "___$method")) return $method;
if($process->hasHook($method . '()')) return $method;
}
// fallback to the unknown, if there is an unknown (you never know)
$method = 'executeUnknown';
if(method_exists($process, $method) || method_exists($process, "___$method")) return $method;
return '';
}