@@ -119,7 +119,7 @@ |
||
119 | 119 | { |
120 | 120 | $feed = Prado::createComponent($feedConfig['class']); |
121 | 121 | if($service instanceof IFeedContentProvider) |
122 | - $properties = isset($feedConfig['properties'])?$feedConfig['properties']:[]; |
|
122 | + $properties = isset($feedConfig['properties']) ? $feedConfig['properties'] : []; |
|
123 | 123 | else |
124 | 124 | throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
125 | 125 | } |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | { |
78 | 78 | if(is_array($config)) |
79 | 79 | { |
80 | - foreach($config as $id => $feed) |
|
81 | - $this->_feeds[$id] = $feed; |
|
80 | + foreach($config as $id => $feed) { |
|
81 | + $this->_feeds[$id] = $feed; |
|
82 | + } |
|
82 | 83 | } |
83 | - } |
|
84 | - else |
|
84 | + } else |
|
85 | 85 | { |
86 | 86 | foreach($config->getElementsByTagName('feed') as $feed) |
87 | 87 | { |
@@ -122,11 +122,9 @@ discard block |
||
122 | 122 | $properties = isset($feedConfig['properties'])?$feedConfig['properties']:[]; |
123 | 123 | else |
124 | 124 | throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
125 | - } |
|
126 | - else |
|
125 | + } else |
|
127 | 126 | throw new TConfigurationException('jsonservice_class_required', $id); |
128 | - } |
|
129 | - else |
|
127 | + } else |
|
130 | 128 | { |
131 | 129 | $properties = $feedConfig->getAttributes(); |
132 | 130 | if(($class = $properties->remove('class')) !== null) |
@@ -134,22 +132,21 @@ discard block |
||
134 | 132 | $feed = Prado::createComponent($class); |
135 | 133 | if(!($feed instanceof IFeedContentProvider)) |
136 | 134 | throw new TConfigurationException('feedservice_feedtype_invalid', $id); |
137 | - } |
|
138 | - else |
|
135 | + } else |
|
139 | 136 | throw new TConfigurationException('feedservice_class_required', $id); |
140 | 137 | } |
141 | 138 | |
142 | 139 | // init feed properties |
143 | - foreach($properties as $name => $value) |
|
144 | - $feed->setSubproperty($name, $value); |
|
140 | + foreach($properties as $name => $value) { |
|
141 | + $feed->setSubproperty($name, $value); |
|
142 | + } |
|
145 | 143 | $feed->init($feedConfig); |
146 | 144 | |
147 | 145 | $content = $feed->getFeedContent(); |
148 | 146 | //$this->getResponse()->setContentType('application/rss+xml'); |
149 | 147 | $this->getResponse()->setContentType($feed->getContentType()); |
150 | 148 | $this->getResponse()->write($content); |
151 | - } |
|
152 | - else |
|
149 | + } else |
|
153 | 150 | throw new THttpException(404, 'feedservice_feed_unknown', $id); |
154 | 151 | } |
155 | 152 | } |
156 | 153 | \ No newline at end of file |
@@ -63,8 +63,9 @@ |
||
63 | 63 | { |
64 | 64 | $this->rpcServer = $rpcServer; |
65 | 65 | |
66 | - foreach($this->registerMethods() as $_methodName => $_methodDetails) |
|
67 | - $this->rpcServer->addRpcMethod($_methodName, $_methodDetails); |
|
66 | + foreach($this->registerMethods() as $_methodName => $_methodDetails) { |
|
67 | + $this->rpcServer->addRpcMethod($_methodName, $_methodDetails); |
|
68 | + } |
|
68 | 69 | } |
69 | 70 | |
70 | 71 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | foreach($config['soap'] as $id => $server) |
172 | 172 | { |
173 | - $properties = isset($server['properties'])?$server['properties']:[]; |
|
173 | + $properties = isset($server['properties']) ? $server['properties'] : []; |
|
174 | 174 | if(isset($this->_servers[$id])) |
175 | 175 | throw new TConfigurationException('soapservice_serverid_duplicated', $id); |
176 | 176 | $this->_servers[$id] = $properties; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | if($serverClass === null) |
257 | 257 | $serverClass = self::DEFAULT_SOAP_SERVER; |
258 | 258 | Prado::using($serverClass); |
259 | - $className = ($pos = strrpos($serverClass, '.')) !== false?substr($serverClass, $pos + 1):$serverClass; |
|
259 | + $className = ($pos = strrpos($serverClass, '.')) !== false ?substr($serverClass, $pos + 1) : $serverClass; |
|
260 | 260 | if($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER)) |
261 | 261 | throw new TConfigurationException('soapservice_server_invalid', $serverClass); |
262 | 262 | $server = new $className; |
@@ -126,8 +126,7 @@ discard block |
||
126 | 126 | $dom = new TXmlDocument; |
127 | 127 | $dom->loadFromFile($this->_configFile); |
128 | 128 | $this->loadConfig($dom); |
129 | - } |
|
130 | - else |
|
129 | + } else |
|
131 | 130 | throw new TConfigurationException('soapservice_configfile_invalid', $this->_configFile); |
132 | 131 | } |
133 | 132 | $this->loadConfig($config); |
@@ -149,8 +148,7 @@ discard block |
||
149 | 148 | { |
150 | 149 | $serverID = substr($serverID, 0, $pos); |
151 | 150 | $this->_wsdlRequest = true; |
152 | - } |
|
153 | - else |
|
151 | + } else |
|
154 | 152 | $this->_wsdlRequest = false; |
155 | 153 | $this->_serverID = $serverID; |
156 | 154 | if(!isset($this->_servers[$serverID])) |
@@ -176,8 +174,7 @@ discard block |
||
176 | 174 | $this->_servers[$id] = $properties; |
177 | 175 | } |
178 | 176 | } |
179 | - } |
|
180 | - else |
|
177 | + } else |
|
181 | 178 | { |
182 | 179 | foreach($config->getElementsByTagName('soap') as $serverXML) |
183 | 180 | { |
@@ -261,8 +258,9 @@ discard block |
||
261 | 258 | throw new TConfigurationException('soapservice_server_invalid', $serverClass); |
262 | 259 | $server = new $className; |
263 | 260 | $server->setID($this->_serverID); |
264 | - foreach($properties as $name => $value) |
|
265 | - $server->setSubproperty($name, $value); |
|
261 | + foreach($properties as $name => $value) { |
|
262 | + $server->setSubproperty($name, $value); |
|
263 | + } |
|
266 | 264 | return $server; |
267 | 265 | } |
268 | 266 | |
@@ -284,8 +282,7 @@ discard block |
||
284 | 282 | Prado::trace("Generating WSDL", 'Prado\Web\Services\TSoapService'); |
285 | 283 | $this->getResponse()->clear(); |
286 | 284 | $this->getResponse()->write($server->getWsdl()); |
287 | - } |
|
288 | - else |
|
285 | + } else |
|
289 | 286 | { |
290 | 287 | // provide SOAP service |
291 | 288 | Prado::trace("Handling SOAP request", 'Prado\Web\Services\TSoapService'); |
@@ -81,14 +81,12 @@ discard block |
||
81 | 81 | $server->setClass($providerClass, $this); |
82 | 82 | if($this->_persistent) |
83 | 83 | $server->setPersistence(SOAP_PERSISTENCE_SESSION); |
84 | - } |
|
85 | - else |
|
84 | + } else |
|
86 | 85 | $server = $this->createServer(); |
87 | 86 | try |
88 | 87 | { |
89 | 88 | $server->handle(); |
90 | - } |
|
91 | - catch (\Exception $e) |
|
89 | + } catch (\Exception $e) |
|
92 | 90 | { |
93 | 91 | if($this->getApplication()->getMode() === TApplicationMode::Debug) |
94 | 92 | $this->fault($e->getMessage(), $e->__toString()); |
@@ -172,8 +170,10 @@ discard block |
||
172 | 170 | $options['uri'] = $this->_uri; |
173 | 171 | if(is_string($this->_classMap)) |
174 | 172 | { |
175 | - foreach(preg_split('/\s*,\s*/', $this->_classMap) as $className) |
|
176 | - $options['classmap'][$className] = $className; //complex type uses the class name in the wsdl |
|
173 | + foreach(preg_split('/\s*,\s*/', $this->_classMap) as $className) { |
|
174 | + $options['classmap'][$className] = $className; |
|
175 | + } |
|
176 | + //complex type uses the class name in the wsdl |
|
177 | 177 | } |
178 | 178 | return $options; |
179 | 179 | } |
@@ -200,13 +200,11 @@ discard block |
||
200 | 200 | $wsdl = WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding()); |
201 | 201 | $cache->set(self::WSDL_CACHE_PREFIX . $providerClass, $wsdl); |
202 | 202 | return $wsdl; |
203 | - } |
|
204 | - else |
|
203 | + } else |
|
205 | 204 | { |
206 | 205 | return WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding()); |
207 | 206 | } |
208 | - } |
|
209 | - else |
|
207 | + } else |
|
210 | 208 | return file_get_contents($this->_wsdlUri); |
211 | 209 | } |
212 | 210 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if(($provider = $this->getProvider()) !== null) |
76 | 76 | { |
77 | 77 | Prado::using($provider); |
78 | - $providerClass = ($pos = strrpos($provider, '.')) !== false?substr($provider, $pos + 1):$provider; |
|
78 | + $providerClass = ($pos = strrpos($provider, '.')) !== false ?substr($provider, $pos + 1) : $provider; |
|
79 | 79 | $this->guessMethodCallRequested($providerClass); |
80 | 80 | $server = $this->createServer(); |
81 | 81 | $server->setClass($providerClass, $this); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | if($this->_wsdlUri === '') |
191 | 191 | { |
192 | 192 | $provider = $this->getProvider(); |
193 | - $providerClass = ($pos = strrpos($provider, '.')) !== false?substr($provider, $pos + 1):$provider; |
|
193 | + $providerClass = ($pos = strrpos($provider, '.')) !== false ?substr($provider, $pos + 1) : $provider; |
|
194 | 194 | Prado::using($provider); |
195 | 195 | if($this->getApplication()->getMode() === TApplicationMode::Performance && ($cache = $this->getApplication()->getCache()) !== null) |
196 | 196 | { |
@@ -117,7 +117,7 @@ |
||
117 | 117 | $service = Prado::createComponent($serviceConfig['class']); |
118 | 118 | if($service instanceof TJsonResponse) |
119 | 119 | { |
120 | - $properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:[]; |
|
120 | + $properties = isset($serviceConfig['properties']) ? $serviceConfig['properties'] : []; |
|
121 | 121 | $this->createJsonResponse($service, $properties, $serviceConfig); |
122 | 122 | } |
123 | 123 | else |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | { |
85 | 85 | if(is_array($config)) |
86 | 86 | { |
87 | - foreach($config['json'] as $id => $json) |
|
88 | - $this->_services[$id] = $json; |
|
87 | + foreach($config['json'] as $id => $json) { |
|
88 | + $this->_services[$id] = $json; |
|
89 | + } |
|
89 | 90 | } |
90 | - } |
|
91 | - else |
|
91 | + } else |
|
92 | 92 | { |
93 | 93 | foreach($config->getElementsByTagName('json') as $json) |
94 | 94 | { |
@@ -119,14 +119,11 @@ discard block |
||
119 | 119 | { |
120 | 120 | $properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:[]; |
121 | 121 | $this->createJsonResponse($service, $properties, $serviceConfig); |
122 | - } |
|
123 | - else |
|
122 | + } else |
|
124 | 123 | throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
125 | - } |
|
126 | - else |
|
124 | + } else |
|
127 | 125 | throw new TConfigurationException('jsonservice_class_required', $id); |
128 | - } |
|
129 | - else |
|
126 | + } else |
|
130 | 127 | { |
131 | 128 | $properties = $serviceConfig->getAttributes(); |
132 | 129 | if(($class = $properties->remove('class')) !== null) |
@@ -136,12 +133,10 @@ discard block |
||
136 | 133 | $this->createJsonResponse($service, $properties, $serviceConfig); |
137 | 134 | else |
138 | 135 | throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
139 | - } |
|
140 | - else |
|
136 | + } else |
|
141 | 137 | throw new TConfigurationException('jsonservice_class_required', $id); |
142 | 138 | } |
143 | - } |
|
144 | - else |
|
139 | + } else |
|
145 | 140 | throw new THttpException(404, 'jsonservice_provider_unknown', $id); |
146 | 141 | } |
147 | 142 | |
@@ -152,8 +147,9 @@ discard block |
||
152 | 147 | protected function createJsonResponse($service, $properties, $config) |
153 | 148 | { |
154 | 149 | // init service properties |
155 | - foreach($properties as $name => $value) |
|
156 | - $service->setSubproperty($name, $value); |
|
150 | + foreach($properties as $name => $value) { |
|
151 | + $service->setSubproperty($name, $value); |
|
152 | + } |
|
157 | 153 | $service->init($config); |
158 | 154 | |
159 | 155 | //send content if not null |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | public function __toString() |
49 | 49 | { |
50 | - return (string)$this->_s; |
|
50 | + return (string) $this->_s; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | public function toJavaScriptLiteral() |
@@ -34,8 +34,9 @@ discard block |
||
34 | 34 | public static function renderScriptFiles($files) |
35 | 35 | { |
36 | 36 | $str = ''; |
37 | - foreach($files as $file) |
|
38 | - $str .= self::renderScriptFile($file); |
|
37 | + foreach($files as $file) { |
|
38 | + $str .= self::renderScriptFile($file); |
|
39 | + } |
|
39 | 40 | return $str; |
40 | 41 | } |
41 | 42 | |
@@ -160,8 +161,7 @@ discard block |
||
160 | 161 | } |
161 | 162 | } |
162 | 163 | return '{' . $results . '}'; |
163 | - } |
|
164 | - else |
|
164 | + } else |
|
165 | 165 | { |
166 | 166 | foreach($value as $v) |
167 | 167 | { |
@@ -174,8 +174,7 @@ discard block |
||
174 | 174 | } |
175 | 175 | return '[' . $results . ']'; |
176 | 176 | } |
177 | - } |
|
178 | - elseif(is_int($value)) |
|
177 | + } elseif(is_int($value)) |
|
179 | 178 | return "$value"; |
180 | 179 | elseif(is_float($value)) |
181 | 180 | { |
@@ -195,8 +194,7 @@ discard block |
||
195 | 194 | return str_replace($locale['decimal_point'], '.', "$value"); |
196 | 195 | break; |
197 | 196 | } |
198 | - } |
|
199 | - elseif(is_object($value)) |
|
197 | + } elseif(is_object($value)) |
|
200 | 198 | if ($value instanceof TJavaScriptLiteral) |
201 | 199 | return $value->toJavaScriptLiteral(); |
202 | 200 | else |
@@ -234,8 +232,9 @@ discard block |
||
234 | 232 | $value = iconv($sourceEncoding, 'UTF-8', $value); |
235 | 233 | elseif (is_array($value)) |
236 | 234 | { |
237 | - foreach($value as &$element) |
|
238 | - self::convertToUtf8($element, $sourceEncoding); |
|
235 | + foreach($value as &$element) { |
|
236 | + self::convertToUtf8($element, $sourceEncoding); |
|
237 | + } |
|
239 | 238 | } |
240 | 239 | } |
241 | 240 |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | if(is_string($value)) |
145 | 145 | return self::quoteString($value); |
146 | 146 | elseif(is_bool($value)) |
147 | - return $value?'true':'false'; |
|
147 | + return $value ? 'true' : 'false'; |
|
148 | 148 | elseif(is_array($value)) |
149 | 149 | { |
150 | 150 | $results = ''; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | } |
198 | 198 | } |
199 | 199 | elseif(is_object($value)) |
200 | - if ($value instanceof TJavaScriptLiteral) |
|
200 | + if($value instanceof TJavaScriptLiteral) |
|
201 | 201 | return $value->toJavaScriptLiteral(); |
202 | 202 | else |
203 | 203 | return self::encode(get_object_vars($value), $toMap); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public static function jsonEncode($value, $options = 0) |
216 | 216 | { |
217 | - if (($g = Prado::getApplication()->getGlobalization(false)) !== null && |
|
217 | + if(($g = Prado::getApplication()->getGlobalization(false)) !== null && |
|
218 | 218 | strtoupper($enc = $g->getCharset()) != 'UTF-8') { |
219 | 219 | self::convertToUtf8($value, $enc); |
220 | 220 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | private static function convertToUtf8(&$value, $sourceEncoding) { |
233 | 233 | if(is_string($value)) |
234 | 234 | $value = iconv($sourceEncoding, 'UTF-8', $value); |
235 | - elseif (is_array($value)) |
|
235 | + elseif(is_array($value)) |
|
236 | 236 | { |
237 | 237 | foreach($value as &$element) |
238 | 238 | self::convertToUtf8($element, $sourceEncoding); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | private static function checkJsonError() |
258 | 258 | { |
259 | - switch ($err = json_last_error()) |
|
259 | + switch($err = json_last_error()) |
|
260 | 260 | { |
261 | 261 | case JSON_ERROR_NONE: |
262 | 262 | return; |
@@ -20,9 +20,9 @@ |
||
20 | 20 | */ |
21 | 21 | class THttpUtility |
22 | 22 | { |
23 | - private static $_encodeTable = ['<' => '<','>' => '>','"' => '"']; |
|
24 | - private static $_decodeTable = ['<' => '<','>' => '>','"' => '"']; |
|
25 | - private static $_stripTable = ['<' => '','>' => '','"' => '']; |
|
23 | + private static $_encodeTable = ['<' => '<', '>' => '>', '"' => '"']; |
|
24 | + private static $_decodeTable = ['<' => '<', '>' => '>', '"' => '"']; |
|
25 | + private static $_stripTable = ['<' => '', '>' => '', '"' => '']; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * HTML-encodes a string. |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | protected function getOption($name) |
55 | 55 | { |
56 | - if ($this->_options) |
|
56 | + if($this->_options) |
|
57 | 57 | return $this->_options->itemAt($name); |
58 | 58 | else |
59 | 59 | return null; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getOptions() |
75 | 75 | { |
76 | - if (!$this->_options) |
|
76 | + if(!$this->_options) |
|
77 | 77 | $this->_options = new TMap; |
78 | 78 | return $this->_options; |
79 | 79 | } |