aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-06-16 16:51:59 +0000
committermistic100 <mistic@piwigo.org>2013-06-16 16:51:59 +0000
commit0a98109a9eb6baa735fe9df2c48dc25e3390e969 (patch)
tree84b499e224818b108556089e9b134198273d4825
parent5671287801351faaede86b1849a6496a56e891e2 (diff)
feature:2926 add option to hide API methods to reflection.getMethodList
git-svn-id: http://piwigo.org/svn/trunk@23261 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--include/ws_core.inc.php34
1 files changed, 20 insertions, 14 deletions
diff --git a/include/ws_core.inc.php b/include/ws_core.inc.php
index e72c7d57a..39720baa1 100644
--- a/include/ws_core.inc.php
+++ b/include/ws_core.inc.php
@@ -303,15 +303,18 @@ Request format: ".@$this->_requestFormat." Response format: ".@$this->_responseF
* @param methodName string - the name of the method as seen externally
* @param callback mixed - php method to be invoked internally
* @param params array - map of allowed parameter names with optional default
- * values and parameter flags. Example of $params:
- * array( 'param1' => array('default'=>523, 'flags'=>WS_PARAM_FORCE_ARRAY) ) .
- * Possible parameter flags are:
- * WS_PARAM_ALLOW_ARRAY - this parameter can be an array
- * WS_PARAM_FORCE_ARRAY - if this parameter is scalar, force it to an array
- * before invoking the method
+ * values and parameter flags. Example of $params:
+ * array( 'param1' => array('default'=>523, 'flags'=>WS_PARAM_FORCE_ARRAY) ).
+ * Possible parameter flags are:
+ * WS_PARAM_ALLOW_ARRAY - this parameter can be an array
+ * WS_PARAM_FORCE_ARRAY - if this parameter is scalar, force it to an array
+ * before invoking the method
* @param description string - a description of the method.
+ * @param include_file string - a file to be included befaore the callback is executed
+ * @param options array - Available options are:
+ * hidden - if true, this method won't be visible by reflection.getMethodList
*/
- function addMethod($methodName, $callback, $params=array(), $description, $include_file='')
+ function addMethod($methodName, $callback, $params=array(), $description, $include_file='', $options=array())
{
if (!is_array($params))
{
@@ -323,21 +326,21 @@ Request format: ".@$this->_requestFormat." Response format: ".@$this->_responseF
$params = array_flip($params);
}
- foreach( $params as $param=>$options)
+ foreach( $params as $param=>$data)
{
- if ( !is_array($options) )
+ if ( !is_array($data) )
{
$params[$param] = array('flags'=>0);
}
else
{
- $flags = isset($options['flags']) ? $options['flags'] : 0;
- if ( array_key_exists('default', $options) )
+ $flags = isset($data['flags']) ? $data['flags'] : 0;
+ if ( array_key_exists('default', $data) )
{
$flags |= WS_PARAM_OPTIONAL;
}
- $options['flags'] = $flags;
- $params[$param] = $options;
+ $data['flags'] = $flags;
+ $params[$param] = $data;
}
}
@@ -346,6 +349,7 @@ Request format: ".@$this->_requestFormat." Response format: ".@$this->_responseF
'description' => $description,
'signature' => $params,
'include' => $include_file,
+ 'options' => $options,
);
}
@@ -461,7 +465,9 @@ Request format: ".@$this->_requestFormat." Response format: ".@$this->_responseF
*/
static function ws_getMethodList($params, &$service)
{
- return array('methods' => new PwgNamedArray( array_keys($service->_methods),'method' ) );
+ $methods = array_filter($service->_methods,
+ create_function('$m', 'return empty($m["options"]["hidden"]) || !$m["options"]["hidden"];'));
+ return array('methods' => new PwgNamedArray( array_keys($methods),'method' ) );
}
/**