Development

Changeset 9616

You must first sign up to be able to contribute.

Changeset 9616

Show
Ignore:
Timestamp:
06/17/08 16:54:52 (3 months ago)
Author:
chrisk
Message:

[ckWebServicePlugin] implemented new configuration model in sf10 version; fixed error in README for sf10 and sf11 version

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/ckWebServicePlugin/branches/1.0/README

    r8904 r9616  
    11= ckWebService plugin = 
    22 
    3 '''This is the documentation for the symfony 1.0 compatible plugin version!''' 
     3'''This is the documentation for the symfony 1.0 compatible plugin version! ''' 
    44 
    55The `ckWebServicePlugin` is a symfony plugin that let you expose your modules and actions as a webservice. 
     
    5252        result_callback: getSoapResult 
    5353        # the options array, which is passed to the `SoapServer` constructor, is the same as described in the php soap documentation [optional] 
    54         options: 
     54        soap_options: 
    5555          encoding: utf-8 
    5656          soap_version: %SOAP_1_2% 
     
    5959=== module.yml === 
    6060 
    61   '''Some of the configuration described here is done by the WSDL Generator!''' 
     61  '''The configuration described here is done by the WSDL Generator! ''' 
    6262   
    6363  The plugin allows per action configuration of parameters passed by the soap call so you can use them like request parameters. 
    64   Also you can configure per action in which action member the result is stored, if not set ''result'' is assumed. 
    65  
    66   {{{ 
    67     # your enviroment for web service mode 
    68     soap: 
    69       # the following part is done by the WSDL Generator, you only have to configure this if you don't use the generator 
    70       soap_parameter_map: 
    71         # the action name [mandatory] 
    72         test: 
    73           # the name of the first action parameter 
    74           - test 
    75           # the name of the second, third, ... action parameter 
    76           - second 
    77           - ... 
    78       # set for each action wether or not action views should be rendered as normal, if this isn't set for an action the value from `ck_web_service_plugin: render` in `app.yml` is used 
    79       soap_render_map: 
    80         # the action name [mandatory] 
    81         test: on 
    82       # the name of the action member, which contains the result [optional] 
    83       soap_return_key: result_key 
     64  Also you can configure per action in which action member the result is stored, if not set ''result'' is assumed, and wether or not to render the view as result. 
     65 
     66  {{{ 
     67    # your enviroment for web service mode 
     68    soap: 
     69      # the following part added by the WSDL Generator for each action, you only have to configure this if you don't use the generator 
     70      action_name: 
     71        # enable the action to be called from ckWebServiceController, should prevent malicious calls to actions through manipulated soap messages [mandatory] 
     72        enable: true 
     73        # ordered list of the parameters [optional] 
     74        parameter: [first_param, second_param] 
     75        # the name of the action member, which contains the result, if `render` is true this has no effect [optional] 
     76        result: null 
     77        # set wether or not the view should be rendered as normal, if this isn't set the value from `ck_web_service_plugin: render` in `app.yml` is used [optional] 
     78        render: false 
    8479  }}} 
    8580 
     
    247242    # your enviroment for web service mode 
    248243    soap: 
    249       soap_parameter_map: 
    250         index: 
    251           - foo 
    252           - bar 
     244      index: 
     245        enable: true 
     246        parameter: [foo, bar] 
    253247  }}} 
    254248   
     
    258252 
    259253  * add support for soap headers 
    260   * merge changes to configuration model in symfony 1.1 compatible version back 
    261254  * decide how to handle redirects 
    262255  * write tests 
  • plugins/ckWebServicePlugin/branches/1.0/data/tasks/ckWebServiceWsdlBuildTask.php

    r8142 r9616  
    7575      } 
    7676 
    77       if(!is_array($yml[$sf_env])) 
     77      if(!isset($yml[$sf_env]) || !is_array($yml[$sf_env])) 
    7878      { 
    7979        $yml[$sf_env] = array(); 
    8080      } 
    8181 
    82       $yml[$sf_env]['soap_parameter_map'] = array(); 
    83  
    8482      foreach($class->getMethods() as $method) 
    8583      { 
    8684        $name = $method->getName(); 
    8785 
    88         if(substr($name,0,7)=='execute' && strlen($name)>7) 
     86        if(ckString::startsWith($name, 'execute') && strlen($name)>7) 
    8987        { 
    90           $action = strtolower(substr($name, 7, 1)).substr($name, 8); 
     88          $action = ckString::lcfirst(substr($name, 7)); 
    9189          $name = $module_dir.'_'.$action; 
    9290 
     
    9593          if($param_return == null) 
    9694          { 
     95            $yml[$sf_env][$action] = array('enable' => false); 
     96             
    9797            continue; 
    9898          } 
     
    100100          pake_echo_action('method+', $name); 
    101101 
    102           $yml[$sf_env]['soap_parameter_map'][$action] = array(); 
     102          $yml[$sf_env][$action] = array('enable'=>true, 'parameter'=>array(), 'result'=>null, 'render'=>false); 
    103103 
    104104          $ws_method = new WsdlMethod(); 
     
    112112          foreach($param_return['param'] as $param) 
    113113          { 
    114             $yml[$sf_env]['soap_parameter_map'][$action][] = $param['name']; 
     114            $yml[$sf_env][$action]['parameter'][] = $param['name']; 
    115115 
    116116            $ws_method->addParameter($param['type'], $param['name'], $param['desc']); 
     
    124124 
    125125      //only save if we added something to the configuration 
    126       if(!empty($yml[$sf_env]['soap_parameter_map'])) 
     126      if(!empty($yml[$sf_env])) 
    127127      { 
    128128        pake_echo_action('file+', $module_config); 
     
    180180    $line = trim($line); 
    181181 
    182     if(substr($line, 0, 2) == '* ' && substr($line, 2, 1) == '@') 
     182    if(ckString::startsWith($line, '* ') && substr($line, 2, 1) == '@') 
    183183    { 
    184184      $parts = explode(' ', substr($line, 3), 4); 
  • plugins/ckWebServicePlugin/branches/1.0/lib/ckSoapParameterFilter.class.php

    r8064 r9616  
    3030      $request = $this->getContext()->getRequest(); 
    3131      $param   = $request->getParameter('param', null, 'ckWebServicePlugin'); 
    32       $map     = sfConfig::get('mod_'.$this->getContext()->getModuleName().'_soap_parameter_map_'.$this->getContext()->getActionName()); 
     32      $map     = sfConfig::get(sprintf('mod_%s_%s_parameter', $this->getContext()->getModuleName(), $this->getContext()->getActionName())); 
    3333 
    3434      if(is_array($param) && is_array($map)) 
  • plugins/ckWebServicePlugin/branches/1.0/lib/controller/ckWebServiceController.class.php

    r8402 r9616  
    1919class ckWebServiceController extends sfController 
    2020{ 
    21   /** 
    22    * Makes a string's first character lowercase. 
    23    * 
    24    * @param  string $str A string 
    25    * 
    26    * @return string      The string with first character lowercased 
    27    */ 
    28   protected static function lcfirst($str) 
    29   { 
    30     if(is_string($str) && strlen($str) > 0) 
    31     { 
    32       $str[0] = strtolower($str[0]); 
    33     } 
    34  
    35     return $str; 
    36   } 
    37  
    3821  protected $soap_server = null; 
    3922 
     
    6952    $result = sfConfig::get('app_ck_web_service_plugin_render', false); 
    7053 
    71     $result = sfConfig::get('mod_'.$this->getContext()->getModuleName().'_soap_render_map_'.$this->getContext()->getActionName(), $result); 
    72  
     54    $result = sfConfig::get(sprintf('mod_%s_%s_render', $this->context->getModuleName(), $this->context->getActionName()), $result); 
     55     
    7356    return $result; 
    7457  } 
     
    149132  public function invokeSoapEnabledAction($moduleName, $actionName, $parameters) 
    150133  { 
    151     $moduleName = self::lcfirst($moduleName); 
    152     $actionName = self::lcfirst($actionName); 
     134    $moduleName = ckString::lcfirst($moduleName); 
     135    $actionName = ckString::lcfirst($actionName); 
    153136 
    154137    $request = $this->getContext()->getRequest(); 
     
    221204    { 
    222205      //get the default result array key 
    223       $default_key = sfConfig::get('mod_'.$actionInstance->getModuleName().'_soap_return_key_'.$actionInstance->getActionName(), 'result'); 
    224  
     206      $default_key = sfConfig::get(sprintf('mod_%s_%s_result', $actionInstance->getModuleName(), $actionInstance->getActionName()), 'result'); 
     207       
    225208      //if there is only one var stored we return it 
    226209      if(count($vars) == 1) 
  • plugins/ckWebServicePlugin/branches/1.0/package.xml

    r8753 r9616  
    1313 <date>2008-04-10</date> 
    1414 <version> 
    15   <release>1.2.0</release> 
    16   <api>1.2.0</api> 
     15  <release>1.3.0</release> 
     16  <api>1.3.0</api> 
    1717 </version> 
    1818 <stability> 
     
    3434    <dir name="controller"> 
    3535     <file role="data" name="ckWebServiceController.class.php" /> 
     36    </dir> 
     37    <dir name="util"> 
     38     <file role="data" name="ckString.class.php" /> 
    3639    </dir> 
    3740    <dir name="vendor"> 
  • plugins/ckWebServicePlugin/trunk/README

    r9602 r9616  
    4646        result_callback: getSoapResult 
    4747        # the options array, which is passed to the `SoapServer` constructor, is the same as described in the php soap documentation [optional] 
    48         options: 
     48        soap_options: 
    4949          encoding: utf-8 
    5050          soap_version: %SOAP_1_2% 
  • plugins/ckWebServicePlugin/trunk/lib/controller/ckWebServiceController.class.php

    r9601 r9616  
    2020 
    2121  const DEFAULT_RESULT_CALLBACK = 'defaultResultCallback'; 
    22    
     22     
    2323  protected $soap_server = null; 
    2424