Changeset 23261


Ignore:
Timestamp:
Jun 16, 2013, 6:51:59 PM (11 years ago)
Author:
mistic100
Message:

feature:2926 add option to hide API methods to reflection.getMethodList

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_core.inc.php

    r22729 r23261  
    304304   * @param callback mixed - php method to be invoked internally
    305305   * @param params array - map of allowed parameter names with optional default
    306    * values and parameter flags. Example of $params:
    307    * array( 'param1' => array('default'=>523, 'flags'=>WS_PARAM_FORCE_ARRAY) ) .
    308    * Possible parameter flags are:
    309    * WS_PARAM_ALLOW_ARRAY - this parameter can be an array
    310    * WS_PARAM_FORCE_ARRAY - if this parameter is scalar, force it to an array
    311    *  before invoking the method
     306   *   values and parameter flags. Example of $params:
     307   *     array( 'param1' => array('default'=>523, 'flags'=>WS_PARAM_FORCE_ARRAY) ).
     308   *   Possible parameter flags are:
     309   *     WS_PARAM_ALLOW_ARRAY - this parameter can be an array
     310   *     WS_PARAM_FORCE_ARRAY - if this parameter is scalar, force it to an array
     311   *       before invoking the method
    312312   * @param description string - a description of the method.
    313    */
    314   function addMethod($methodName, $callback, $params=array(), $description, $include_file='')
     313   * @param include_file string - a file to be included befaore the callback is executed
     314   * @param options array - Available options are:
     315   *   hidden - if true, this method won't be visible by reflection.getMethodList
     316   */
     317  function addMethod($methodName, $callback, $params=array(), $description, $include_file='', $options=array())
    315318  {
    316319    if (!is_array($params))
     
    324327    }
    325328
    326     foreach( $params as $param=>$options)
    327     {
    328       if ( !is_array($options) )
     329    foreach( $params as $param=>$data)
     330    {
     331      if ( !is_array($data) )
    329332      {
    330333        $params[$param] = array('flags'=>0);
     
    332335      else
    333336      {
    334         $flags = isset($options['flags']) ? $options['flags'] : 0;
    335         if ( array_key_exists('default', $options) )
     337        $flags = isset($data['flags']) ? $data['flags'] : 0;
     338        if ( array_key_exists('default', $data) )
    336339        {
    337340          $flags |= WS_PARAM_OPTIONAL;
    338341        }
    339         $options['flags'] = $flags;
    340         $params[$param] = $options;
     342        $data['flags'] = $flags;
     343        $params[$param] = $data;
    341344      }
    342345    }
     
    347350      'signature'   => $params,
    348351      'include'     => $include_file,
     352      'options'     => $options,
    349353      );
    350354  }
     
    462466  static function ws_getMethodList($params, &$service)
    463467  {
    464     return array('methods' => new PwgNamedArray( array_keys($service->_methods),'method' ) );
     468    $methods = array_filter($service->_methods,
     469            create_function('$m', 'return empty($m["options"]["hidden"]) || !$m["options"]["hidden"];'));
     470    return array('methods' => new PwgNamedArray( array_keys($methods),'method' ) );
    465471  }
    466472
Note: See TracChangeset for help on using the changeset viewer.