mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
Merge branch 'MDL-63131-master' of https://github.com/sammarshallou/moodle
This commit is contained in:
commit
13b4a1f4bb
2 changed files with 40 additions and 5 deletions
|
@ -221,11 +221,28 @@ class external_api {
|
||||||
$params = call_user_func($callable,
|
$params = call_user_func($callable,
|
||||||
$externalfunctioninfo->parameters_desc,
|
$externalfunctioninfo->parameters_desc,
|
||||||
$args);
|
$args);
|
||||||
|
$params = array_values($params);
|
||||||
|
|
||||||
// Execute - gulp!
|
// Allow any Moodle plugin a chance to override this call. This is a convenient spot to
|
||||||
$callable = array($externalfunctioninfo->classname, $externalfunctioninfo->methodname);
|
// make arbitrary behaviour customisations. The overriding plugin could call the 'real'
|
||||||
$result = call_user_func_array($callable,
|
// function first and then modify the results, or it could do a completely separate
|
||||||
array_values($params));
|
// thing.
|
||||||
|
$callbacks = get_plugins_with_function('override_webservice_execution');
|
||||||
|
$result = false;
|
||||||
|
foreach ($callbacks as $plugintype => $plugins) {
|
||||||
|
foreach ($plugins as $plugin => $callback) {
|
||||||
|
$result = $callback($externalfunctioninfo, $params);
|
||||||
|
if ($result !== false) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the function was not overridden, call the real one.
|
||||||
|
if ($result === false) {
|
||||||
|
$callable = array($externalfunctioninfo->classname, $externalfunctioninfo->methodname);
|
||||||
|
$result = call_user_func_array($callable, $params);
|
||||||
|
}
|
||||||
|
|
||||||
// Validate the return parameters.
|
// Validate the return parameters.
|
||||||
if ($externalfunctioninfo->returns_desc !== null) {
|
if ($externalfunctioninfo->returns_desc !== null) {
|
||||||
|
|
|
@ -1392,9 +1392,27 @@ abstract class webservice_base_server extends webservice_server {
|
||||||
protected function execute() {
|
protected function execute() {
|
||||||
// validate params, this also sorts the params properly, we need the correct order in the next part
|
// validate params, this also sorts the params properly, we need the correct order in the next part
|
||||||
$params = call_user_func(array($this->function->classname, 'validate_parameters'), $this->function->parameters_desc, $this->parameters);
|
$params = call_user_func(array($this->function->classname, 'validate_parameters'), $this->function->parameters_desc, $this->parameters);
|
||||||
|
$params = array_values($params);
|
||||||
|
|
||||||
|
// Allow any Moodle plugin a chance to override this call. This is a convenient spot to
|
||||||
|
// make arbitrary behaviour customisations, for example to affect the mobile app behaviour.
|
||||||
|
// The overriding plugin could call the 'real' function first and then modify the results,
|
||||||
|
// or it could do a completely separate thing.
|
||||||
|
$callbacks = get_plugins_with_function('override_webservice_execution');
|
||||||
|
foreach ($callbacks as $plugintype => $plugins) {
|
||||||
|
foreach ($plugins as $plugin => $callback) {
|
||||||
|
$result = $callback($this->function, $params);
|
||||||
|
if ($result !== false) {
|
||||||
|
// If the callback returns anything other than false, we assume it replaces the
|
||||||
|
// real function.
|
||||||
|
$this->returns = $result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// execute - yay!
|
// execute - yay!
|
||||||
$this->returns = call_user_func_array(array($this->function->classname, $this->function->methodname), array_values($params));
|
$this->returns = call_user_func_array(array($this->function->classname, $this->function->methodname), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue