Permalink
Browse files

feature(web_services): filter method output with a plugin hook

execute_method() now filters the result with a plugin hook. Hook will receive
all parameters available to the method via $params.
  • Loading branch information...
hypeJunction committed Jun 27, 2015
1 parent 8f5dd5e commit 5ff308c53f130d0319e4b168972aaaba172d82ec
Showing with 5 additions and 0 deletions.
  1. +3 −0 docs/guides/web-services.rst
  2. +2 −0 mod/web_services/lib/web_services.php
@@ -66,6 +66,9 @@ and you should see xml data like this:
<result>testing</result>
</elgg>
+Plugins can filter the output of individual API methods by registering a handler
+for ``'rest:output',$method`` plugin hook.
+
Response formats
~~~~~~~~~~~~~~~~
@@ -100,6 +100,8 @@ function execute_method($method) {
// @todo remove the need for eval()
$result = eval("return $function($serialised_parameters);");
+ $result = elgg_trigger_plugin_hook('rest:output', $method, $parameters, $result);
+
// Sanity check result
// If this function returns an api result itself, just return it
if ($result instanceof GenericResult) {

0 comments on commit 5ff308c

Please sign in to comment.