@@ -46,16 +46,14 @@ public function preDispatch()
46
46
$ this ->apiSetup ['apiMethodPrefix ' ] = $ this ->Setting ->getValueByName (API_METHOD_PREFIX_KEY , $ this ->moduleName );
47
47
48
48
$ this ->action = $ actionName = Zend_Controller_Front::getInstance ()->getRequest ()->getActionName ();
49
- switch ($ this ->action ) {
50
- case "rest " :
51
- case "json " :
52
- case "php_serial " :
53
- case "xmlrpc " :
54
- case "soap " :
55
- $ this ->_initApiCommons ();
56
- break ;
57
- default :
58
- break ;
49
+
50
+ if ($ this ->action === 'json ' ) {
51
+ $ this ->disableLayout ();
52
+ $ this ->_helper ->viewRenderer ->setNoRender ();
53
+
54
+ $ this ->ModuleComponent ->Api ->controller = &$ this ;
55
+ $ this ->ModuleComponent ->Api ->apiSetup = &$ this ->apiSetup ;
56
+ $ this ->ModuleComponent ->Api ->userSession = &$ this ->userSession ;
59
57
}
60
58
}
61
59
@@ -123,57 +121,22 @@ private function _computeApiHelp($apiMethodPrefix)
123
121
}
124
122
}
125
123
126
- /** Initialize property allowing to generate XML */
127
- private function _initApiCommons ()
128
- {
129
- // Disable debug information - Required to generate valid XML output
130
- // Configure::write('debug', 0);
131
-
132
- $ this ->disableLayout ();
133
- $ this ->_helper ->viewRenderer ->setNoRender ();
134
-
135
- $ this ->ModuleComponent ->Api ->controller = &$ this ;
136
- $ this ->ModuleComponent ->Api ->apiSetup = &$ this ->apiSetup ;
137
- $ this ->ModuleComponent ->Api ->userSession = &$ this ->userSession ;
138
- }
139
-
140
- /** Controller action handling REST request */
141
- public function restAction ()
142
- {
143
- $ this ->disableLayout ();
144
- $ this ->_helper ->viewRenderer ->setNoRender ();
145
-
146
- $ method_name = $ this ->getParam ('method ' );
147
- if (!isset ($ method_name )) {
148
- echo 'Inconsistent request: please set a method parameter ' ;
149
- exit ;
150
- }
151
-
152
- $ request_data = $ this ->getAllParams ();
153
- $ this ->_computeApiCallback ($ method_name , $ this ->apiSetup ['apiMethodPrefix ' ]);
154
- // Handle XML-RPC request
155
- $ this ->kwWebApiCore = new KwWebApiRestCore ($ this ->apiSetup , $ this ->apicallbacks , $ request_data );
156
- }
157
-
158
124
/** Controller action handling JSON request */
159
125
public function jsonAction ()
160
126
{
161
127
$ this ->disableLayout ();
162
128
$ this ->_helper ->viewRenderer ->setNoRender ();
163
129
164
- $ method_name = $ this ->getParam ('method ' );
165
- if (!isset ($ method_name )) {
130
+ $ methodName = $ this ->getParam ('method ' );
131
+
132
+ if (!isset ($ methodName )) {
166
133
echo 'Inconsistent request: please set a method parameter ' ;
167
134
exit ;
168
135
}
169
136
170
- $ request_data = $ this ->getAllParams ();
171
- $ this ->_computeApiCallback ($ method_name , $ this ->apiSetup ['apiMethodPrefix ' ]);
172
- // Handle XML-RPC request
173
- $ this ->kwWebApiCore = new KwWebApiRestCore (
174
- $ this ->apiSetup ,
175
- $ this ->apicallbacks ,
176
- array_merge ($ request_data , array ('format ' => 'json ' ))
177
- );
137
+ $ requestData = $ this ->getAllParams ();
138
+ $ apiMethodPrefix = $ this ->apiSetup ['apiMethodPrefix ' ];
139
+ $ this ->_computeApiCallback ($ methodName , $ apiMethodPrefix );
140
+ $ this ->kwWebApiCore = new KwWebApiCore ($ apiMethodPrefix , $ this ->apicallbacks , $ requestData );
178
141
}
179
142
}
0 commit comments