Changeset 9616
- Timestamp:
- 06/17/08 16:54:52 (3 months ago)
- Files:
-
- plugins/ckWebServicePlugin/branches/1.0/README (modified) (5 diffs)
- plugins/ckWebServicePlugin/branches/1.0/data/tasks/ckWebServiceWsdlBuildTask.php (modified) (6 diffs)
- plugins/ckWebServicePlugin/branches/1.0/lib/ckSoapParameterFilter.class.php (modified) (1 diff)
- plugins/ckWebServicePlugin/branches/1.0/lib/controller/ckWebServiceController.class.php (modified) (4 diffs)
- plugins/ckWebServicePlugin/branches/1.0/lib/util (added)
- plugins/ckWebServicePlugin/branches/1.0/lib/util/ckString.class.php (added)
- plugins/ckWebServicePlugin/branches/1.0/package.xml (modified) (2 diffs)
- plugins/ckWebServicePlugin/trunk/README (modified) (1 diff)
- plugins/ckWebServicePlugin/trunk/lib/controller/ckWebServiceController.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/ckWebServicePlugin/branches/1.0/README
r8904 r9616 1 1 = ckWebService plugin = 2 2 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! ''' 4 4 5 5 The `ckWebServicePlugin` is a symfony plugin that let you expose your modules and actions as a webservice. … … 52 52 result_callback: getSoapResult 53 53 # 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: 55 55 encoding: utf-8 56 56 soap_version: %SOAP_1_2% … … 59 59 === module.yml === 60 60 61 ''' Some of the configuration described here is done by the WSDL Generator!'''61 '''The configuration described here is done by the WSDL Generator! ''' 62 62 63 63 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 84 79 }}} 85 80 … … 247 242 # your enviroment for web service mode 248 243 soap: 249 soap_parameter_map: 250 index: 251 - foo 252 - bar 244 index: 245 enable: true 246 parameter: [foo, bar] 253 247 }}} 254 248 … … 258 252 259 253 * add support for soap headers 260 * merge changes to configuration model in symfony 1.1 compatible version back261 254 * decide how to handle redirects 262 255 * write tests plugins/ckWebServicePlugin/branches/1.0/data/tasks/ckWebServiceWsdlBuildTask.php
r8142 r9616 75 75 } 76 76 77 if(!is _array($yml[$sf_env]))77 if(!isset($yml[$sf_env]) || !is_array($yml[$sf_env])) 78 78 { 79 79 $yml[$sf_env] = array(); 80 80 } 81 81 82 $yml[$sf_env]['soap_parameter_map'] = array();83 84 82 foreach($class->getMethods() as $method) 85 83 { 86 84 $name = $method->getName(); 87 85 88 if( substr($name,0,7)=='execute'&& strlen($name)>7)86 if(ckString::startsWith($name, 'execute') && strlen($name)>7) 89 87 { 90 $action = strtolower(substr($name, 7, 1)).substr($name, 8);88 $action = ckString::lcfirst(substr($name, 7)); 91 89 $name = $module_dir.'_'.$action; 92 90 … … 95 93 if($param_return == null) 96 94 { 95 $yml[$sf_env][$action] = array('enable' => false); 96 97 97 continue; 98 98 } … … 100 100 pake_echo_action('method+', $name); 101 101 102 $yml[$sf_env][ 'soap_parameter_map'][$action] = array();102 $yml[$sf_env][$action] = array('enable'=>true, 'parameter'=>array(), 'result'=>null, 'render'=>false); 103 103 104 104 $ws_method = new WsdlMethod(); … … 112 112 foreach($param_return['param'] as $param) 113 113 { 114 $yml[$sf_env][ 'soap_parameter_map'][$action][] = $param['name'];114 $yml[$sf_env][$action]['parameter'][] = $param['name']; 115 115 116 116 $ws_method->addParameter($param['type'], $param['name'], $param['desc']); … … 124 124 125 125 //only save if we added something to the configuration 126 if(!empty($yml[$sf_env] ['soap_parameter_map']))126 if(!empty($yml[$sf_env])) 127 127 { 128 128 pake_echo_action('file+', $module_config); … … 180 180 $line = trim($line); 181 181 182 if( substr($line, 0, 2) == '* '&& substr($line, 2, 1) == '@')182 if(ckString::startsWith($line, '* ') && substr($line, 2, 1) == '@') 183 183 { 184 184 $parts = explode(' ', substr($line, 3), 4); plugins/ckWebServicePlugin/branches/1.0/lib/ckSoapParameterFilter.class.php
r8064 r9616 30 30 $request = $this->getContext()->getRequest(); 31 31 $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())); 33 33 34 34 if(is_array($param) && is_array($map)) plugins/ckWebServicePlugin/branches/1.0/lib/controller/ckWebServiceController.class.php
r8402 r9616 19 19 class ckWebServiceController extends sfController 20 20 { 21 /**22 * Makes a string's first character lowercase.23 *24 * @param string $str A string25 *26 * @return string The string with first character lowercased27 */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 38 21 protected $soap_server = null; 39 22 … … 69 52 $result = sfConfig::get('app_ck_web_service_plugin_render', false); 70 53 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 73 56 return $result; 74 57 } … … 149 132 public function invokeSoapEnabledAction($moduleName, $actionName, $parameters) 150 133 { 151 $moduleName = self::lcfirst($moduleName);152 $actionName = self::lcfirst($actionName);134 $moduleName = ckString::lcfirst($moduleName); 135 $actionName = ckString::lcfirst($actionName); 153 136 154 137 $request = $this->getContext()->getRequest(); … … 221 204 { 222 205 //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 225 208 //if there is only one var stored we return it 226 209 if(count($vars) == 1) plugins/ckWebServicePlugin/branches/1.0/package.xml
r8753 r9616 13 13 <date>2008-04-10</date> 14 14 <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> 17 17 </version> 18 18 <stability> … … 34 34 <dir name="controller"> 35 35 <file role="data" name="ckWebServiceController.class.php" /> 36 </dir> 37 <dir name="util"> 38 <file role="data" name="ckString.class.php" /> 36 39 </dir> 37 40 <dir name="vendor"> plugins/ckWebServicePlugin/trunk/README
r9602 r9616 46 46 result_callback: getSoapResult 47 47 # 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: 49 49 encoding: utf-8 50 50 soap_version: %SOAP_1_2% plugins/ckWebServicePlugin/trunk/lib/controller/ckWebServiceController.class.php
r9601 r9616 20 20 { 21 21 const DEFAULT_RESULT_CALLBACK = 'defaultResultCallback'; 22 22 23 23 protected $soap_server = null; 24 24