Passed
Branch php-cs-fixer (b9836a)
by Fabio
15:58
created
framework/Wsat/pages/TWsatScaffolding.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
 								{
59 59
 										$id = "cb_$tableName";
60 60
 										$obj = $this->tableNames->findControl($id);
61
-										if($obj !== null && $obj->Checked)
61
+										if ($obj !== null && $obj->Checked)
62 62
 										{
63 63
 												$scf_generator->generateCRUD($tableName);
64 64
 										}
Please login to merge, or discard this patch.
framework/TApplicationComponent.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,10 +98,10 @@
 block discarded – undo
98 98
 	 */
99 99
 	public function publishAsset($assetPath, $className = null)
100 100
 	{
101
-		if($className === null)
101
+		if ($className === null)
102 102
 			$className = get_class($this);
103 103
 		$class = new \ReflectionClass($className);
104
-		$fullPath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $assetPath;
104
+		$fullPath = dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath;
105 105
 		return $this->publishFilePath($fullPath);
106 106
 	}
107 107
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,8 +98,9 @@
 block discarded – undo
98 98
 	 */
99 99
 	public function publishAsset($assetPath, $className = null)
100 100
 	{
101
-		if($className === null)
102
-			$className = get_class($this);
101
+		if($className === null) {
102
+					$className = get_class($this);
103
+		}
103 104
 		$class = new \ReflectionClass($className);
104 105
 		$fullPath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $assetPath;
105 106
 		return $this->publishFilePath($fullPath);
Please login to merge, or discard this patch.
framework/TApplicationConfiguration.php 2 patches
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function loadFromFile($fname)
68 68
 	{
69
-		if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
69
+		if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
70 70
 		{
71 71
 			$fcontent = include $fname;
72 72
 			$this->loadFromPhp($fcontent, dirname($fname));
@@ -95,28 +95,28 @@  discard block
 block discarded – undo
95 95
 	public function loadFromPhp($config, $configPath)
96 96
 	{
97 97
 		// application properties
98
-		if(isset($config['application']))
98
+		if (isset($config['application']))
99 99
 		{
100
-			foreach($config['application'] as $name => $value)
100
+			foreach ($config['application'] as $name => $value)
101 101
 			{
102 102
 				$this->_properties[$name] = $value;
103 103
 			}
104 104
 			$this->_empty = false;
105 105
 		}
106 106
 
107
-		if(isset($config['paths']) && is_array($config['paths']))
107
+		if (isset($config['paths']) && is_array($config['paths']))
108 108
 			$this->loadPathsPhp($config['paths'], $configPath);
109 109
 
110
-		if(isset($config['modules']) && is_array($config['modules']))
110
+		if (isset($config['modules']) && is_array($config['modules']))
111 111
 			$this->loadModulesPhp($config['modules'], $configPath);
112 112
 
113
-		if(isset($config['services']) && is_array($config['services']))
113
+		if (isset($config['services']) && is_array($config['services']))
114 114
 			$this->loadServicesPhp($config['services'], $configPath);
115 115
 
116
-		if(isset($config['parameters']) && is_array($config['parameters']))
116
+		if (isset($config['parameters']) && is_array($config['parameters']))
117 117
 			$this->loadParametersPhp($config['parameters'], $configPath);
118 118
 
119
-		if(isset($config['includes']) && is_array($config['includes']))
119
+		if (isset($config['includes']) && is_array($config['includes']))
120 120
 			$this->loadExternalXml($config['includes'], $configPath);
121 121
 	}
122 122
 
@@ -128,15 +128,15 @@  discard block
 block discarded – undo
128 128
 	public function loadFromXml($dom, $configPath)
129 129
 	{
130 130
 		// application properties
131
-		foreach($dom->getAttributes() as $name => $value)
131
+		foreach ($dom->getAttributes() as $name => $value)
132 132
 		{
133 133
 			$this->_properties[$name] = $value;
134 134
 			$this->_empty = false;
135 135
 		}
136 136
 
137
-		foreach($dom->getElements() as $element)
137
+		foreach ($dom->getElements() as $element)
138 138
 		{
139
-			switch($element->getTagName())
139
+			switch ($element->getTagName())
140 140
 			{
141 141
 				case 'paths':
142 142
 					$this->loadPathsXml($element, $configPath);
@@ -167,26 +167,26 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	protected function loadPathsPhp($pathsNode, $configPath)
169 169
 	{
170
-		if(isset($pathsNode['aliases']) && is_array($pathsNode['aliases']))
170
+		if (isset($pathsNode['aliases']) && is_array($pathsNode['aliases']))
171 171
 		{
172
-			foreach($pathsNode['aliases'] as $id => $path)
172
+			foreach ($pathsNode['aliases'] as $id => $path)
173 173
 			{
174 174
 				$path = str_replace('\\', '/', $path);
175
-				if(preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
175
+				if (preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
176 176
 					$p = realpath($path);
177 177
 				else
178
-					$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
179
-				if($p === false || !is_dir($p))
178
+					$p = realpath($configPath.DIRECTORY_SEPARATOR.$path);
179
+				if ($p === false || !is_dir($p))
180 180
 					throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
181
-				if(isset($this->_aliases[$id]))
181
+				if (isset($this->_aliases[$id]))
182 182
 					throw new TConfigurationException('appconfig_alias_redefined', $id);
183 183
 				$this->_aliases[$id] = $p;
184 184
 			}
185 185
 		}
186 186
 
187
-		if(isset($pathsNode['using']) && is_array($pathsNode['using']))
187
+		if (isset($pathsNode['using']) && is_array($pathsNode['using']))
188 188
 		{
189
-			foreach($pathsNode['using'] as $namespace)
189
+			foreach ($pathsNode['using'] as $namespace)
190 190
 			{
191 191
 				$this->_usings[] = $namespace;
192 192
 			}
@@ -200,22 +200,22 @@  discard block
 block discarded – undo
200 200
 	 */
201 201
 	protected function loadPathsXml($pathsNode, $configPath)
202 202
 	{
203
-		foreach($pathsNode->getElements() as $element)
203
+		foreach ($pathsNode->getElements() as $element)
204 204
 		{
205
-			switch($element->getTagName())
205
+			switch ($element->getTagName())
206 206
 			{
207 207
 				case 'alias':
208 208
 				{
209
-					if(($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null)
209
+					if (($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null)
210 210
 					{
211 211
 						$path = str_replace('\\', '/', $path);
212
-						if(preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
212
+						if (preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
213 213
 							$p = realpath($path);
214 214
 						else
215
-							$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
216
-						if($p === false || !is_dir($p))
215
+							$p = realpath($configPath.DIRECTORY_SEPARATOR.$path);
216
+						if ($p === false || !is_dir($p))
217 217
 							throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
218
-						if(isset($this->_aliases[$id]))
218
+						if (isset($this->_aliases[$id]))
219 219
 							throw new TConfigurationException('appconfig_alias_redefined', $id);
220 220
 						$this->_aliases[$id] = $p;
221 221
 					}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 				}
227 227
 				case 'using':
228 228
 				{
229
-					if(($namespace = $element->getAttribute('namespace')) !== null)
229
+					if (($namespace = $element->getAttribute('namespace')) !== null)
230 230
 						$this->_usings[] = $namespace;
231 231
 					else
232 232
 						throw new TConfigurationException('appconfig_using_invalid');
@@ -246,20 +246,20 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	protected function loadModulesPhp($modulesNode, $configPath)
248 248
 	{
249
-		foreach($modulesNode as $id => $module)
249
+		foreach ($modulesNode as $id => $module)
250 250
 		{
251
-			if(!isset($module['class']))
251
+			if (!isset($module['class']))
252 252
 				throw new TConfigurationException('appconfig_moduletype_required', $id);
253 253
 			$type = $module['class'];
254 254
 			unset($module['class']);
255 255
 			$properties = [];
256
-			if(isset($module['properties']))
256
+			if (isset($module['properties']))
257 257
 			{
258 258
 				$properties = $module['properties'];
259 259
 				unset($module['properties']);
260 260
 			}
261 261
 			$properties['id'] = $id;
262
-			$this->_modules[$id] = [$type,$properties,$module];
262
+			$this->_modules[$id] = [$type, $properties, $module];
263 263
 			$this->_empty = false;
264 264
 		}
265 265
 	}
@@ -271,20 +271,20 @@  discard block
 block discarded – undo
271 271
 	 */
272 272
 	protected function loadModulesXml($modulesNode, $configPath)
273 273
 	{
274
-		foreach($modulesNode->getElements() as $element)
274
+		foreach ($modulesNode->getElements() as $element)
275 275
 		{
276
-			if($element->getTagName() === 'module')
276
+			if ($element->getTagName() === 'module')
277 277
 			{
278 278
 				$properties = $element->getAttributes();
279 279
 				$id = $properties->itemAt('id');
280 280
 				$type = $properties->remove('class');
281
-				if($type === null)
281
+				if ($type === null)
282 282
 					throw new TConfigurationException('appconfig_moduletype_required', $id);
283 283
 				$element->setParent(null);
284
-				if($id === null)
285
-					$this->_modules[] = [$type,$properties->toArray(),$element];
284
+				if ($id === null)
285
+					$this->_modules[] = [$type, $properties->toArray(), $element];
286 286
 				else
287
-					$this->_modules[$id] = [$type,$properties->toArray(),$element];
287
+					$this->_modules[$id] = [$type, $properties->toArray(), $element];
288 288
 				$this->_empty = false;
289 289
 			}
290 290
 			else
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	protected function loadServicesPhp($servicesNode, $configPath)
301 301
 	{
302
-		foreach($servicesNode as $id => $service)
302
+		foreach ($servicesNode as $id => $service)
303 303
 		{
304
-			if(!isset($service['class']))
304
+			if (!isset($service['class']))
305 305
 				throw new TConfigurationException('appconfig_servicetype_required');
306 306
 			$type = $service['class'];
307 307
 			$properties = isset($service['properties']) ? $service['properties'] : [];
308 308
 			unset($service['properties']);
309 309
 			$properties['id'] = $id;
310
-			$this->_services[$id] = [$type,$properties,$service];
310
+			$this->_services[$id] = [$type, $properties, $service];
311 311
 			$this->_empty = false;
312 312
 		}
313 313
 	}
@@ -319,17 +319,17 @@  discard block
 block discarded – undo
319 319
 	 */
320 320
 	protected function loadServicesXml($servicesNode, $configPath)
321 321
 	{
322
-		foreach($servicesNode->getElements() as $element)
322
+		foreach ($servicesNode->getElements() as $element)
323 323
 		{
324
-			if($element->getTagName() === 'service')
324
+			if ($element->getTagName() === 'service')
325 325
 			{
326 326
 				$properties = $element->getAttributes();
327
-				if(($id = $properties->itemAt('id')) === null)
327
+				if (($id = $properties->itemAt('id')) === null)
328 328
 					throw new TConfigurationException('appconfig_serviceid_required');
329
-				if(($type = $properties->remove('class')) === null)
329
+				if (($type = $properties->remove('class')) === null)
330 330
 					throw new TConfigurationException('appconfig_servicetype_required', $id);
331 331
 				$element->setParent(null);
332
-				$this->_services[$id] = [$type,$properties->toArray(),$element];
332
+				$this->_services[$id] = [$type, $properties->toArray(), $element];
333 333
 				$this->_empty = false;
334 334
 			}
335 335
 			else
@@ -344,17 +344,17 @@  discard block
 block discarded – undo
344 344
 	 */
345 345
 	protected function loadParametersPhp($parametersNode, $configPath)
346 346
 	{
347
-		foreach($parametersNode as $id => $parameter)
347
+		foreach ($parametersNode as $id => $parameter)
348 348
 		{
349
-			if(is_array($parameter))
349
+			if (is_array($parameter))
350 350
 			{
351
-				if(isset($parameter['class']))
351
+				if (isset($parameter['class']))
352 352
 				{
353 353
 					$type = $parameter['class'];
354 354
 					unset($parameter['class']);
355 355
 					$properties = isset($service['properties']) ? $service['properties'] : [];
356 356
 					$properties['id'] = $id;
357
-					$this->_parameters[$id] = [$type,$properties];
357
+					$this->_parameters[$id] = [$type, $properties];
358 358
 				}
359 359
 			}
360 360
 			else
@@ -371,22 +371,22 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	protected function loadParametersXml($parametersNode, $configPath)
373 373
 	{
374
-		foreach($parametersNode->getElements() as $element)
374
+		foreach ($parametersNode->getElements() as $element)
375 375
 		{
376
-			if($element->getTagName() === 'parameter')
376
+			if ($element->getTagName() === 'parameter')
377 377
 			{
378 378
 				$properties = $element->getAttributes();
379
-				if(($id = $properties->remove('id')) === null)
379
+				if (($id = $properties->remove('id')) === null)
380 380
 					throw new TConfigurationException('appconfig_parameterid_required');
381
-				if(($type = $properties->remove('class')) === null)
381
+				if (($type = $properties->remove('class')) === null)
382 382
 				{
383
-					if(($value = $properties->remove('value')) === null)
383
+					if (($value = $properties->remove('value')) === null)
384 384
 						$this->_parameters[$id] = $element;
385 385
 					else
386 386
 						$this->_parameters[$id] = $value;
387 387
 				}
388 388
 				else
389
-					$this->_parameters[$id] = [$type,$properties->toArray()];
389
+					$this->_parameters[$id] = [$type, $properties->toArray()];
390 390
 				$this->_empty = false;
391 391
 			}
392 392
 			else
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	protected function loadExternalPhp($includeNode, $configPath)
403 403
 	{
404
-		foreach($includeNode as $include)
404
+		foreach ($includeNode as $include)
405 405
 		{
406
-			$when = isset($include['when'])?true:false;
407
-			if(!isset($include['file']))
406
+			$when = isset($include['when']) ?true:false;
407
+			if (!isset($include['file']))
408 408
 				throw new TConfigurationException('appconfig_includefile_required');
409 409
 			$filePath = $include['file'];
410
-			if(isset($this->_includes[$filePath]))
411
-				$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
410
+			if (isset($this->_includes[$filePath]))
411
+				$this->_includes[$filePath] = '('.$this->_includes[$filePath].') || ('.$when.')';
412 412
 			else
413 413
 				$$this->_includes[$filePath] = $when;
414 414
 			$this->_empty = false;
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	protected function loadExternalXml($includeNode, $configPath)
424 424
 	{
425
-		if(($when = $includeNode->getAttribute('when')) === null)
425
+		if (($when = $includeNode->getAttribute('when')) === null)
426 426
 			$when = true;
427
-		if(($filePath = $includeNode->getAttribute('file')) === null)
427
+		if (($filePath = $includeNode->getAttribute('file')) === null)
428 428
 			throw new TConfigurationException('appconfig_includefile_required');
429
-		if(isset($this->_includes[$filePath]))
430
-			$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
429
+		if (isset($this->_includes[$filePath]))
430
+			$this->_includes[$filePath] = '('.$this->_includes[$filePath].') || ('.$when.')';
431 431
 		else
432 432
 			$this->_includes[$filePath] = $when;
433 433
 		$this->_empty = false;
Please login to merge, or discard this patch.
Braces   +101 added lines, -76 removed lines patch added patch discarded remove patch
@@ -70,8 +70,7 @@  discard block
 block discarded – undo
70 70
 		{
71 71
 			$fcontent = include $fname;
72 72
 			$this->loadFromPhp($fcontent, dirname($fname));
73
-		}
74
-		else
73
+		} else
75 74
 		{
76 75
 			$dom = new TXmlDocument;
77 76
 			$dom->loadFromFile($fname);
@@ -104,20 +103,25 @@  discard block
 block discarded – undo
104 103
 			$this->_empty = false;
105 104
 		}
106 105
 
107
-		if(isset($config['paths']) && is_array($config['paths']))
108
-			$this->loadPathsPhp($config['paths'], $configPath);
106
+		if(isset($config['paths']) && is_array($config['paths'])) {
107
+					$this->loadPathsPhp($config['paths'], $configPath);
108
+		}
109 109
 
110
-		if(isset($config['modules']) && is_array($config['modules']))
111
-			$this->loadModulesPhp($config['modules'], $configPath);
110
+		if(isset($config['modules']) && is_array($config['modules'])) {
111
+					$this->loadModulesPhp($config['modules'], $configPath);
112
+		}
112 113
 
113
-		if(isset($config['services']) && is_array($config['services']))
114
-			$this->loadServicesPhp($config['services'], $configPath);
114
+		if(isset($config['services']) && is_array($config['services'])) {
115
+					$this->loadServicesPhp($config['services'], $configPath);
116
+		}
115 117
 
116
-		if(isset($config['parameters']) && is_array($config['parameters']))
117
-			$this->loadParametersPhp($config['parameters'], $configPath);
118
+		if(isset($config['parameters']) && is_array($config['parameters'])) {
119
+					$this->loadParametersPhp($config['parameters'], $configPath);
120
+		}
118 121
 
119
-		if(isset($config['includes']) && is_array($config['includes']))
120
-			$this->loadExternalXml($config['includes'], $configPath);
122
+		if(isset($config['includes']) && is_array($config['includes'])) {
123
+					$this->loadExternalXml($config['includes'], $configPath);
124
+		}
121 125
 	}
122 126
 
123 127
 	/**
@@ -172,14 +176,18 @@  discard block
 block discarded – undo
172 176
 			foreach($pathsNode['aliases'] as $id => $path)
173 177
 			{
174 178
 				$path = str_replace('\\', '/', $path);
175
-				if(preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
179
+				if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) {
180
+					// if absolute path
176 181
 					$p = realpath($path);
177
-				else
178
-					$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
179
-				if($p === false || !is_dir($p))
180
-					throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
181
-				if(isset($this->_aliases[$id]))
182
-					throw new TConfigurationException('appconfig_alias_redefined', $id);
182
+				} else {
183
+									$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
184
+				}
185
+				if($p === false || !is_dir($p)) {
186
+									throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
187
+				}
188
+				if(isset($this->_aliases[$id])) {
189
+									throw new TConfigurationException('appconfig_alias_redefined', $id);
190
+				}
183 191
 				$this->_aliases[$id] = $p;
184 192
 			}
185 193
 		}
@@ -209,27 +217,32 @@  discard block
 block discarded – undo
209 217
 					if(($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null)
210 218
 					{
211 219
 						$path = str_replace('\\', '/', $path);
212
-						if(preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
220
+						if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) {
221
+							// if absolute path
213 222
 							$p = realpath($path);
214
-						else
215
-							$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
216
-						if($p === false || !is_dir($p))
217
-							throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
218
-						if(isset($this->_aliases[$id]))
219
-							throw new TConfigurationException('appconfig_alias_redefined', $id);
223
+						} else {
224
+													$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
225
+						}
226
+						if($p === false || !is_dir($p)) {
227
+													throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
228
+						}
229
+						if(isset($this->_aliases[$id])) {
230
+													throw new TConfigurationException('appconfig_alias_redefined', $id);
231
+						}
220 232
 						$this->_aliases[$id] = $p;
233
+					} else {
234
+											throw new TConfigurationException('appconfig_alias_invalid');
221 235
 					}
222
-					else
223
-						throw new TConfigurationException('appconfig_alias_invalid');
224 236
 					$this->_empty = false;
225 237
 					break;
226 238
 				}
227 239
 				case 'using':
228 240
 				{
229
-					if(($namespace = $element->getAttribute('namespace')) !== null)
230
-						$this->_usings[] = $namespace;
231
-					else
232
-						throw new TConfigurationException('appconfig_using_invalid');
241
+					if(($namespace = $element->getAttribute('namespace')) !== null) {
242
+											$this->_usings[] = $namespace;
243
+					} else {
244
+											throw new TConfigurationException('appconfig_using_invalid');
245
+					}
233 246
 					$this->_empty = false;
234 247
 					break;
235 248
 				}
@@ -248,8 +261,9 @@  discard block
 block discarded – undo
248 261
 	{
249 262
 		foreach($modulesNode as $id => $module)
250 263
 		{
251
-			if(!isset($module['class']))
252
-				throw new TConfigurationException('appconfig_moduletype_required', $id);
264
+			if(!isset($module['class'])) {
265
+							throw new TConfigurationException('appconfig_moduletype_required', $id);
266
+			}
253 267
 			$type = $module['class'];
254 268
 			unset($module['class']);
255 269
 			$properties = [];
@@ -278,17 +292,19 @@  discard block
 block discarded – undo
278 292
 				$properties = $element->getAttributes();
279 293
 				$id = $properties->itemAt('id');
280 294
 				$type = $properties->remove('class');
281
-				if($type === null)
282
-					throw new TConfigurationException('appconfig_moduletype_required', $id);
295
+				if($type === null) {
296
+									throw new TConfigurationException('appconfig_moduletype_required', $id);
297
+				}
283 298
 				$element->setParent(null);
284
-				if($id === null)
285
-					$this->_modules[] = [$type,$properties->toArray(),$element];
286
-				else
287
-					$this->_modules[$id] = [$type,$properties->toArray(),$element];
299
+				if($id === null) {
300
+									$this->_modules[] = [$type,$properties->toArray(),$element];
301
+				} else {
302
+									$this->_modules[$id] = [$type,$properties->toArray(),$element];
303
+				}
288 304
 				$this->_empty = false;
305
+			} else {
306
+							throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName());
289 307
 			}
290
-			else
291
-				throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName());
292 308
 		}
293 309
 	}
294 310
 
@@ -301,8 +317,9 @@  discard block
 block discarded – undo
301 317
 	{
302 318
 		foreach($servicesNode as $id => $service)
303 319
 		{
304
-			if(!isset($service['class']))
305
-				throw new TConfigurationException('appconfig_servicetype_required');
320
+			if(!isset($service['class'])) {
321
+							throw new TConfigurationException('appconfig_servicetype_required');
322
+			}
306 323
 			$type = $service['class'];
307 324
 			$properties = isset($service['properties']) ? $service['properties'] : [];
308 325
 			unset($service['properties']);
@@ -324,16 +341,18 @@  discard block
 block discarded – undo
324 341
 			if($element->getTagName() === 'service')
325 342
 			{
326 343
 				$properties = $element->getAttributes();
327
-				if(($id = $properties->itemAt('id')) === null)
328
-					throw new TConfigurationException('appconfig_serviceid_required');
329
-				if(($type = $properties->remove('class')) === null)
330
-					throw new TConfigurationException('appconfig_servicetype_required', $id);
344
+				if(($id = $properties->itemAt('id')) === null) {
345
+									throw new TConfigurationException('appconfig_serviceid_required');
346
+				}
347
+				if(($type = $properties->remove('class')) === null) {
348
+									throw new TConfigurationException('appconfig_servicetype_required', $id);
349
+				}
331 350
 				$element->setParent(null);
332 351
 				$this->_services[$id] = [$type,$properties->toArray(),$element];
333 352
 				$this->_empty = false;
353
+			} else {
354
+							throw new TConfigurationException('appconfig_services_invalid', $element->getTagName());
334 355
 			}
335
-			else
336
-				throw new TConfigurationException('appconfig_services_invalid', $element->getTagName());
337 356
 		}
338 357
 	}
339 358
 
@@ -356,8 +375,7 @@  discard block
 block discarded – undo
356 375
 					$properties['id'] = $id;
357 376
 					$this->_parameters[$id] = [$type,$properties];
358 377
 				}
359
-			}
360
-			else
378
+			} else
361 379
 			{
362 380
 				$this->_parameters[$id] = $parameter;
363 381
 			}
@@ -376,21 +394,23 @@  discard block
 block discarded – undo
376 394
 			if($element->getTagName() === 'parameter')
377 395
 			{
378 396
 				$properties = $element->getAttributes();
379
-				if(($id = $properties->remove('id')) === null)
380
-					throw new TConfigurationException('appconfig_parameterid_required');
397
+				if(($id = $properties->remove('id')) === null) {
398
+									throw new TConfigurationException('appconfig_parameterid_required');
399
+				}
381 400
 				if(($type = $properties->remove('class')) === null)
382 401
 				{
383
-					if(($value = $properties->remove('value')) === null)
384
-						$this->_parameters[$id] = $element;
385
-					else
386
-						$this->_parameters[$id] = $value;
402
+					if(($value = $properties->remove('value')) === null) {
403
+											$this->_parameters[$id] = $element;
404
+					} else {
405
+											$this->_parameters[$id] = $value;
406
+					}
407
+				} else {
408
+									$this->_parameters[$id] = [$type,$properties->toArray()];
387 409
 				}
388
-				else
389
-					$this->_parameters[$id] = [$type,$properties->toArray()];
390 410
 				$this->_empty = false;
411
+			} else {
412
+							throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName());
391 413
 			}
392
-			else
393
-				throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName());
394 414
 		}
395 415
 	}
396 416
 
@@ -404,13 +424,15 @@  discard block
 block discarded – undo
404 424
 		foreach($includeNode as $include)
405 425
 		{
406 426
 			$when = isset($include['when'])?true:false;
407
-			if(!isset($include['file']))
408
-				throw new TConfigurationException('appconfig_includefile_required');
427
+			if(!isset($include['file'])) {
428
+							throw new TConfigurationException('appconfig_includefile_required');
429
+			}
409 430
 			$filePath = $include['file'];
410
-			if(isset($this->_includes[$filePath]))
411
-				$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
412
-			else
413
-				$$this->_includes[$filePath] = $when;
431
+			if(isset($this->_includes[$filePath])) {
432
+							$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
433
+			} else {
434
+							$$this->_includes[$filePath] = $when;
435
+			}
414 436
 			$this->_empty = false;
415 437
 		}
416 438
 	}
@@ -422,14 +444,17 @@  discard block
 block discarded – undo
422 444
 	 */
423 445
 	protected function loadExternalXml($includeNode, $configPath)
424 446
 	{
425
-		if(($when = $includeNode->getAttribute('when')) === null)
426
-			$when = true;
427
-		if(($filePath = $includeNode->getAttribute('file')) === null)
428
-			throw new TConfigurationException('appconfig_includefile_required');
429
-		if(isset($this->_includes[$filePath]))
430
-			$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
431
-		else
432
-			$this->_includes[$filePath] = $when;
447
+		if(($when = $includeNode->getAttribute('when')) === null) {
448
+					$when = true;
449
+		}
450
+		if(($filePath = $includeNode->getAttribute('file')) === null) {
451
+					throw new TConfigurationException('appconfig_includefile_required');
452
+		}
453
+		if(isset($this->_includes[$filePath])) {
454
+					$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
455
+		} else {
456
+					$this->_includes[$filePath] = $when;
457
+		}
433 458
 		$this->_empty = false;
434 459
 	}
435 460
 
Please login to merge, or discard this patch.
framework/Web/TSessionIterator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function current()
71 71
 	{
72
-		return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null;
72
+		return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null;
73 73
 	}
74 74
 
75 75
 	/**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		{
83 83
 			$this->_key = next($this->_keys);
84 84
 		}
85
-		while(!isset($_SESSION[$this->_key]) && $this->_key !== false);
85
+		while (!isset($_SESSION[$this->_key]) && $this->_key !== false);
86 86
 	}
87 87
 
88 88
 	/**
Please login to merge, or discard this patch.
framework/Web/Services/TFeedService.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -73,19 +73,19 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function init($config)
75 75
 	{
76
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
76
+		if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
77 77
 		{
78
-			if(is_array($config))
78
+			if (is_array($config))
79 79
 			{
80
-				foreach($config as $id => $feed)
80
+				foreach ($config as $id => $feed)
81 81
 					$this->_feeds[$id] = $feed;
82 82
 			}
83 83
 		}
84 84
 		else
85 85
 		{
86
-			foreach($config->getElementsByTagName('feed') as $feed)
86
+			foreach ($config->getElementsByTagName('feed') as $feed)
87 87
 			{
88
-				if(($id = $feed->getAttributes()->remove('id')) !== null)
88
+				if (($id = $feed->getAttributes()->remove('id')) !== null)
89 89
 					$this->_feeds[$id] = $feed;
90 90
 				else
91 91
 					throw new TConfigurationException('feedservice_id_required');
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
 	public function run()
109 109
 	{
110 110
 		$id = $this->getRequest()->getServiceParameter();
111
-		if(isset($this->_feeds[$id]))
111
+		if (isset($this->_feeds[$id]))
112 112
 		{
113 113
 			$feedConfig = $this->_feeds[$id];
114 114
 			$properties = [];
115 115
 			$feed = null;
116
-			if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
116
+			if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
117 117
 			{
118
-				if(isset($feedConfig['class']))
118
+				if (isset($feedConfig['class']))
119 119
 				{
120 120
 					$feed = Prado::createComponent($feedConfig['class']);
121
-					if($service instanceof IFeedContentProvider)
122
-						$properties = isset($feedConfig['properties'])?$feedConfig['properties']:[];
121
+					if ($service instanceof IFeedContentProvider)
122
+						$properties = isset($feedConfig['properties']) ? $feedConfig['properties'] : [];
123 123
 					else
124 124
 						throw new TConfigurationException('jsonservice_response_type_invalid', $id);
125 125
 				}
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
 			else
130 130
 			{
131 131
 				$properties = $feedConfig->getAttributes();
132
-				if(($class = $properties->remove('class')) !== null)
132
+				if (($class = $properties->remove('class')) !== null)
133 133
 				{
134 134
 					$feed = Prado::createComponent($class);
135
-					if(!($feed instanceof IFeedContentProvider))
135
+					if (!($feed instanceof IFeedContentProvider))
136 136
 						throw new TConfigurationException('feedservice_feedtype_invalid', $id);
137 137
 				}
138 138
 				else
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 			}
141 141
 
142 142
 			// init feed properties
143
-			foreach($properties as $name => $value)
143
+			foreach ($properties as $name => $value)
144 144
 				$feed->setSubproperty($name, $value);
145 145
 			$feed->init($feedConfig);
146 146
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -24 removed lines patch added patch discarded remove patch
@@ -77,18 +77,19 @@  discard block
 block discarded – undo
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
 			{
88
-				if(($id = $feed->getAttributes()->remove('id')) !== null)
89
-					$this->_feeds[$id] = $feed;
90
-				else
91
-					throw new TConfigurationException('feedservice_id_required');
88
+				if(($id = $feed->getAttributes()->remove('id')) !== null) {
89
+									$this->_feeds[$id] = $feed;
90
+				} else {
91
+									throw new TConfigurationException('feedservice_id_required');
92
+				}
92 93
 			}
93 94
 		}
94 95
 	}
@@ -118,38 +119,40 @@  discard block
 block discarded – undo
118 119
 				if(isset($feedConfig['class']))
119 120
 				{
120 121
 					$feed = Prado::createComponent($feedConfig['class']);
121
-					if($service instanceof IFeedContentProvider)
122
-						$properties = isset($feedConfig['properties'])?$feedConfig['properties']:[];
123
-					else
124
-						throw new TConfigurationException('jsonservice_response_type_invalid', $id);
122
+					if($service instanceof IFeedContentProvider) {
123
+											$properties = isset($feedConfig['properties'])?$feedConfig['properties']:[];
124
+					} else {
125
+											throw new TConfigurationException('jsonservice_response_type_invalid', $id);
126
+					}
127
+				} else {
128
+									throw new TConfigurationException('jsonservice_class_required', $id);
125 129
 				}
126
-				else
127
-					throw new TConfigurationException('jsonservice_class_required', $id);
128
-			}
129
-			else
130
+			} else
130 131
 			{
131 132
 				$properties = $feedConfig->getAttributes();
132 133
 				if(($class = $properties->remove('class')) !== null)
133 134
 				{
134 135
 					$feed = Prado::createComponent($class);
135
-					if(!($feed instanceof IFeedContentProvider))
136
-						throw new TConfigurationException('feedservice_feedtype_invalid', $id);
136
+					if(!($feed instanceof IFeedContentProvider)) {
137
+											throw new TConfigurationException('feedservice_feedtype_invalid', $id);
138
+					}
139
+				} else {
140
+									throw new TConfigurationException('feedservice_class_required', $id);
137 141
 				}
138
-				else
139
-					throw new TConfigurationException('feedservice_class_required', $id);
140 142
 			}
141 143
 
142 144
 			// init feed properties
143
-			foreach($properties as $name => $value)
144
-				$feed->setSubproperty($name, $value);
145
+			foreach($properties as $name => $value) {
146
+							$feed->setSubproperty($name, $value);
147
+			}
145 148
 			$feed->init($feedConfig);
146 149
 
147 150
 			$content = $feed->getFeedContent();
148 151
 			//$this->getResponse()->setContentType('application/rss+xml');
149 152
 			$this->getResponse()->setContentType($feed->getContentType());
150 153
 			$this->getResponse()->write($content);
154
+		} else {
155
+					throw new THttpException(404, 'feedservice_feed_unknown', $id);
151 156
 		}
152
-		else
153
-			throw new THttpException(404, 'feedservice_feed_unknown', $id);
154 157
 	}
155 158
 }
156 159
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Web/Services/TSoapService.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function init($config)
121 121
 	{
122
-		if($this->_configFile !== null)
122
+		if ($this->_configFile !== null)
123 123
 		{
124
-			if(is_file($this->_configFile))
124
+			if (is_file($this->_configFile))
125 125
 			{
126 126
 				$dom = new TXmlDocument;
127 127
 				$dom->loadFromFile($this->_configFile);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	protected function resolveRequest()
146 146
 	{
147 147
 		$serverID = $this->getRequest()->getServiceParameter();
148
-		if(($pos = strrpos($serverID, '.wsdl')) === strlen($serverID) - 5)
148
+		if (($pos = strrpos($serverID, '.wsdl')) === strlen($serverID) - 5)
149 149
 		{
150 150
 			$serverID = substr($serverID, 0, $pos);
151 151
 			$this->_wsdlRequest = true;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		else
154 154
 			$this->_wsdlRequest = false;
155 155
 		$this->_serverID = $serverID;
156
-		if(!isset($this->_servers[$serverID]))
156
+		if (!isset($this->_servers[$serverID]))
157 157
 			throw new THttpException(400, 'soapservice_request_invalid', $serverID);
158 158
 	}
159 159
 
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	private function loadConfig($config)
166 166
 	{
167
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
167
+		if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
168 168
 		{
169
-			if(is_array($config))
169
+			if (is_array($config))
170 170
 			{
171
-				foreach($config['soap'] as $id => $server)
171
+				foreach ($config['soap'] as $id => $server)
172 172
 				{
173
-					$properties = isset($server['properties'])?$server['properties']:[];
174
-					if(isset($this->_servers[$id]))
173
+					$properties = isset($server['properties']) ? $server['properties'] : [];
174
+					if (isset($this->_servers[$id]))
175 175
 						throw new TConfigurationException('soapservice_serverid_duplicated', $id);
176 176
 					$this->_servers[$id] = $properties;
177 177
 				}
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 		}
180 180
 		else
181 181
 		{
182
-			foreach($config->getElementsByTagName('soap') as $serverXML)
182
+			foreach ($config->getElementsByTagName('soap') as $serverXML)
183 183
 			{
184 184
 				$properties = $serverXML->getAttributes();
185
-				if(($id = $properties->remove('id')) === null)
185
+				if (($id = $properties->remove('id')) === null)
186 186
 					throw new TConfigurationException('soapservice_serverid_required');
187
-				if(isset($this->_servers[$id]))
187
+				if (isset($this->_servers[$id]))
188 188
 					throw new TConfigurationException('soapservice_serverid_duplicated', $id);
189 189
 				$this->_servers[$id] = $properties;
190 190
 			}
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function setConfigFile($value)
208 208
 	{
209
-		if(($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null)
209
+		if (($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null)
210 210
 			throw new TConfigurationException('soapservice_configfile_invalid', $value);
211 211
 	}
212 212
 
@@ -249,19 +249,19 @@  discard block
 block discarded – undo
249 249
 	{
250 250
 		$properties = $this->_servers[$this->_serverID];
251 251
 		$serverClass = null;
252
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class']))
252
+		if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class']))
253 253
 			$serverClass = $config['class'];
254
-		elseif($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML)
254
+		elseif ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML)
255 255
 			$serverClass = $properties->remove('class');
256
-		if($serverClass === null)
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;
260
-		if($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER))
259
+		$className = ($pos = strrpos($serverClass, '.')) !== false ?substr($serverClass, $pos + 1) : $serverClass;
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;
263 263
 		$server->setID($this->_serverID);
264
-		foreach($properties as $name => $value)
264
+		foreach ($properties as $name => $value)
265 265
 			$server->setSubproperty($name, $value);
266 266
 		return $server;
267 267
 	}
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		$server = $this->createServer();
279 279
 		$this->getResponse()->setContentType('text/xml');
280 280
 		$this->getResponse()->setCharset($server->getEncoding());
281
-		if($this->getIsWsdlRequest())
281
+		if ($this->getIsWsdlRequest())
282 282
 		{
283 283
 			// server WSDL file
284 284
 			Prado::trace("Generating WSDL", 'Prado\Web\Services\TSoapService');
Please login to merge, or discard this patch.
Braces   +35 added lines, -28 removed lines patch added patch discarded remove patch
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 				$dom = new TXmlDocument;
127 127
 				$dom->loadFromFile($this->_configFile);
128 128
 				$this->loadConfig($dom);
129
+			} else {
130
+							throw new TConfigurationException('soapservice_configfile_invalid', $this->_configFile);
129 131
 			}
130
-			else
131
-				throw new TConfigurationException('soapservice_configfile_invalid', $this->_configFile);
132 132
 		}
133 133
 		$this->loadConfig($config);
134 134
 
@@ -149,12 +149,13 @@  discard block
 block discarded – undo
149 149
 		{
150 150
 			$serverID = substr($serverID, 0, $pos);
151 151
 			$this->_wsdlRequest = true;
152
+		} else {
153
+					$this->_wsdlRequest = false;
152 154
 		}
153
-		else
154
-			$this->_wsdlRequest = false;
155 155
 		$this->_serverID = $serverID;
156
-		if(!isset($this->_servers[$serverID]))
157
-			throw new THttpException(400, 'soapservice_request_invalid', $serverID);
156
+		if(!isset($this->_servers[$serverID])) {
157
+					throw new THttpException(400, 'soapservice_request_invalid', $serverID);
158
+		}
158 159
 	}
159 160
 
160 161
 	/**
@@ -171,21 +172,23 @@  discard block
 block discarded – undo
171 172
 				foreach($config['soap'] as $id => $server)
172 173
 				{
173 174
 					$properties = isset($server['properties'])?$server['properties']:[];
174
-					if(isset($this->_servers[$id]))
175
-						throw new TConfigurationException('soapservice_serverid_duplicated', $id);
175
+					if(isset($this->_servers[$id])) {
176
+											throw new TConfigurationException('soapservice_serverid_duplicated', $id);
177
+					}
176 178
 					$this->_servers[$id] = $properties;
177 179
 				}
178 180
 			}
179
-		}
180
-		else
181
+		} else
181 182
 		{
182 183
 			foreach($config->getElementsByTagName('soap') as $serverXML)
183 184
 			{
184 185
 				$properties = $serverXML->getAttributes();
185
-				if(($id = $properties->remove('id')) === null)
186
-					throw new TConfigurationException('soapservice_serverid_required');
187
-				if(isset($this->_servers[$id]))
188
-					throw new TConfigurationException('soapservice_serverid_duplicated', $id);
186
+				if(($id = $properties->remove('id')) === null) {
187
+									throw new TConfigurationException('soapservice_serverid_required');
188
+				}
189
+				if(isset($this->_servers[$id])) {
190
+									throw new TConfigurationException('soapservice_serverid_duplicated', $id);
191
+				}
189 192
 				$this->_servers[$id] = $properties;
190 193
 			}
191 194
 		}
@@ -206,8 +209,9 @@  discard block
 block discarded – undo
206 209
 	 */
207 210
 	public function setConfigFile($value)
208 211
 	{
209
-		if(($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null)
210
-			throw new TConfigurationException('soapservice_configfile_invalid', $value);
212
+		if(($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null) {
213
+					throw new TConfigurationException('soapservice_configfile_invalid', $value);
214
+		}
211 215
 	}
212 216
 
213 217
 	/**
@@ -249,20 +253,24 @@  discard block
 block discarded – undo
249 253
 	{
250 254
 		$properties = $this->_servers[$this->_serverID];
251 255
 		$serverClass = null;
252
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class']))
253
-			$serverClass = $config['class'];
254
-		elseif($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML)
255
-			$serverClass = $properties->remove('class');
256
-		if($serverClass === null)
257
-			$serverClass = self::DEFAULT_SOAP_SERVER;
256
+		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class'])) {
257
+					$serverClass = $config['class'];
258
+		} elseif($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML) {
259
+					$serverClass = $properties->remove('class');
260
+		}
261
+		if($serverClass === null) {
262
+					$serverClass = self::DEFAULT_SOAP_SERVER;
263
+		}
258 264
 		Prado::using($serverClass);
259 265
 		$className = ($pos = strrpos($serverClass, '.')) !== false?substr($serverClass, $pos + 1):$serverClass;
260
-		if($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER))
261
-			throw new TConfigurationException('soapservice_server_invalid', $serverClass);
266
+		if($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER)) {
267
+					throw new TConfigurationException('soapservice_server_invalid', $serverClass);
268
+		}
262 269
 		$server = new $className;
263 270
 		$server->setID($this->_serverID);
264
-		foreach($properties as $name => $value)
265
-			$server->setSubproperty($name, $value);
271
+		foreach($properties as $name => $value) {
272
+					$server->setSubproperty($name, $value);
273
+		}
266 274
 		return $server;
267 275
 	}
268 276
 
@@ -284,8 +292,7 @@  discard block
 block discarded – undo
284 292
 			Prado::trace("Generating WSDL", 'Prado\Web\Services\TSoapService');
285 293
 			$this->getResponse()->clear();
286 294
 			$this->getResponse()->write($server->getWsdl());
287
-		}
288
-		else
295
+		} else
289 296
 		{
290 297
 			// provide SOAP service
291 298
 			Prado::trace("Handling SOAP request", 'Prado\Web\Services\TSoapService');
Please login to merge, or discard this patch.
framework/Web/Services/TPageConfiguration.php 2 patches
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
 		$fileName = Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP
115 115
 			? TPageService::CONFIG_FILE_PHP
116 116
 			: TPageService::CONFIG_FILE_XML;
117
-		foreach($paths as $p)
117
+		foreach ($paths as $p)
118 118
 		{
119
-			$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
120
-			$path .= DIRECTORY_SEPARATOR . $p;
121
-			if($configPagePath === '')
119
+			$this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath);
120
+			$path .= DIRECTORY_SEPARATOR.$p;
121
+			if ($configPagePath === '')
122 122
 				$configPagePath = $p;
123 123
 			else
124
-				$configPagePath .= '.' . $p;
124
+				$configPagePath .= '.'.$p;
125 125
 		}
126
-		$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
126
+		$this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath);
127 127
 		$this->_rules = new TAuthorizationRuleCollection($this->_rules);
128 128
 	}
129 129
 
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 	public function loadFromFile($fname, $configPagePath)
136 136
 	{
137 137
 		Prado::trace("Loading page configuration file $fname", 'System.Web.Services.TPageService');
138
-		if(empty($fname) || !is_file($fname))
138
+		if (empty($fname) || !is_file($fname))
139 139
 			return;
140 140
 
141
-		if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
141
+		if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
142 142
 		{
143 143
 			$fcontent = include $fname;
144 144
 			$this->loadFromPhp($fcontent, dirname($fname), $configPagePath);
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		else
147 147
 		{
148 148
 			$dom = new TXmlDocument;
149
-			if($dom->loadFromFile($fname))
149
+			if ($dom->loadFromFile($fname))
150 150
 				$this->loadFromXml($dom, dirname($fname), $configPagePath);
151 151
 			else
152 152
 				throw new TConfigurationException('pageserviceconf_file_invalid', $fname);
@@ -195,32 +195,32 @@  discard block
 block discarded – undo
195 195
 	public function loadPageConfigurationFromPhp($config, $configPath, $configPagePath)
196 196
 	{
197 197
 		// authorization
198
-		if(isset($config['authorization']) && is_array($config['authorization']))
198
+		if (isset($config['authorization']) && is_array($config['authorization']))
199 199
 		{
200 200
 			$rules = [];
201
-			foreach($config['authorization'] as $authorization)
201
+			foreach ($config['authorization'] as $authorization)
202 202
 			{
203
-				$patterns = isset($authorization['pages'])?$authorization['pages']:'';
203
+				$patterns = isset($authorization['pages']) ? $authorization['pages'] : '';
204 204
 				$ruleApplies = false;
205
-				if(empty($patterns) || trim($patterns) === '*') // null or empty string
205
+				if (empty($patterns) || trim($patterns) === '*') // null or empty string
206 206
 					$ruleApplies = true;
207 207
 				else
208 208
 				{
209
-					foreach(explode(',', $patterns) as $pattern)
209
+					foreach (explode(',', $patterns) as $pattern)
210 210
 					{
211
-						if(($pattern = trim($pattern)) !== '')
211
+						if (($pattern = trim($pattern)) !== '')
212 212
 						{
213 213
 							// we know $configPagePath and $this->_pagePath
214
-							if($configPagePath !== '')  // prepend the pattern with ConfigPagePath
215
-								$pattern = $configPagePath . '.' . $pattern;
216
-							if(strcasecmp($pattern, $this->_pagePath) === 0)
214
+							if ($configPagePath !== '')  // prepend the pattern with ConfigPagePath
215
+								$pattern = $configPagePath.'.'.$pattern;
216
+							if (strcasecmp($pattern, $this->_pagePath) === 0)
217 217
 							{
218 218
 								$ruleApplies = true;
219 219
 								break;
220 220
 							}
221
-							if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
221
+							if ($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
222 222
 							{
223
-								if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
223
+								if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
224 224
 								{
225 225
 									$ruleApplies = true;
226 226
 									break;
@@ -229,58 +229,58 @@  discard block
 block discarded – undo
229 229
 						}
230 230
 					}
231 231
 				}
232
-				if($ruleApplies)
232
+				if ($ruleApplies)
233 233
 				{
234
-					$action = isset($authorization['action'])?$authorization['action']:'';
235
-					$users = isset($authorization['users'])?$authorization['users']:'';
236
-					$roles = isset($authorization['roles'])?$authorization['roles']:'';
237
-					$verb = isset($authorization['verb'])?$authorization['verb']:'';
238
-					$ips = isset($authorization['ips'])?$authorization['ips']:'';
234
+					$action = isset($authorization['action']) ? $authorization['action'] : '';
235
+					$users = isset($authorization['users']) ? $authorization['users'] : '';
236
+					$roles = isset($authorization['roles']) ? $authorization['roles'] : '';
237
+					$verb = isset($authorization['verb']) ? $authorization['verb'] : '';
238
+					$ips = isset($authorization['ips']) ? $authorization['ips'] : '';
239 239
 					$rules[] = new TAuthorizationRule($action, $users, $roles, $verb, $ips);
240 240
 				}
241 241
 			}
242 242
 			$this->_rules = array_merge($rules, $this->_rules);
243 243
 		}
244 244
 		// pages
245
-		if(isset($config['pages']) && is_array($config['pages']))
245
+		if (isset($config['pages']) && is_array($config['pages']))
246 246
 		{
247
-			if(isset($config['pages']['properties']))
247
+			if (isset($config['pages']['properties']))
248 248
 			{
249 249
 				$this->_properties = array_merge($this->_properties, $config['pages']['properties']);
250 250
 				unset($config['pages']['properties']);
251 251
 			}
252
-			foreach($config['pages'] as $id => $page)
252
+			foreach ($config['pages'] as $id => $page)
253 253
 			{
254 254
 				$properties = [];
255
-				if(isset($page['properties']))
255
+				if (isset($page['properties']))
256 256
 				{
257 257
 					$properties = $page['properties'];
258 258
 					unset($page['properties']);
259 259
 				}
260 260
 				$matching = false;
261
-				$id = ($configPagePath === '')?$id:$configPagePath . '.' . $id;
262
-				if(strcasecmp($id, $this->_pagePath) === 0)
261
+				$id = ($configPagePath === '') ? $id : $configPagePath.'.'.$id;
262
+				if (strcasecmp($id, $this->_pagePath) === 0)
263 263
 					$matching = true;
264
-				elseif($id[strlen($id) - 1] === '*') // try wildcard matching
264
+				elseif ($id[strlen($id) - 1] === '*') // try wildcard matching
265 265
 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
266
-				if($matching)
266
+				if ($matching)
267 267
 					$this->_properties = array_merge($this->_properties, $properties);
268 268
 			}
269 269
 		}
270 270
 
271 271
 		// external configurations
272
-		if(isset($config['includes']) && is_array($config['includes']))
272
+		if (isset($config['includes']) && is_array($config['includes']))
273 273
 		{
274
-			foreach($config['includes'] as $include)
274
+			foreach ($config['includes'] as $include)
275 275
 			{
276
-				$when = isset($include['when'])?true:false;
277
-				if(!isset($include['file']))
276
+				$when = isset($include['when']) ?true:false;
277
+				if (!isset($include['file']))
278 278
 					throw new TConfigurationException('pageserviceconf_includefile_required');
279 279
 				$filePath = $include['file'];
280
-				if(isset($this->_includes[$filePath]))
281
-					$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
280
+				if (isset($this->_includes[$filePath]))
281
+					$this->_includes[$filePath] = [$configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'];
282 282
 				else
283
-					$this->_includes[$filePath] = [$configPagePath,$when];
283
+					$this->_includes[$filePath] = [$configPagePath, $when];
284 284
 			}
285 285
 		}
286 286
 	}
@@ -294,32 +294,32 @@  discard block
 block discarded – undo
294 294
 	public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath)
295 295
 	{
296 296
 		// authorization
297
-		if(($authorizationNode = $dom->getElementByTagName('authorization')) !== null)
297
+		if (($authorizationNode = $dom->getElementByTagName('authorization')) !== null)
298 298
 		{
299 299
 			$rules = [];
300
-			foreach($authorizationNode->getElements() as $node)
300
+			foreach ($authorizationNode->getElements() as $node)
301 301
 			{
302 302
 				$patterns = $node->getAttribute('pages');
303 303
 				$ruleApplies = false;
304
-				if(empty($patterns) || trim($patterns) === '*') // null or empty string
304
+				if (empty($patterns) || trim($patterns) === '*') // null or empty string
305 305
 					$ruleApplies = true;
306 306
 				else
307 307
 				{
308
-					foreach(explode(',', $patterns) as $pattern)
308
+					foreach (explode(',', $patterns) as $pattern)
309 309
 					{
310
-						if(($pattern = trim($pattern)) !== '')
310
+						if (($pattern = trim($pattern)) !== '')
311 311
 						{
312 312
 							// we know $configPagePath and $this->_pagePath
313
-							if($configPagePath !== '')  // prepend the pattern with ConfigPagePath
314
-								$pattern = $configPagePath . '.' . $pattern;
315
-							if(strcasecmp($pattern, $this->_pagePath) === 0)
313
+							if ($configPagePath !== '')  // prepend the pattern with ConfigPagePath
314
+								$pattern = $configPagePath.'.'.$pattern;
315
+							if (strcasecmp($pattern, $this->_pagePath) === 0)
316 316
 							{
317 317
 								$ruleApplies = true;
318 318
 								break;
319 319
 							}
320
-							if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
320
+							if ($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
321 321
 							{
322
-								if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
322
+								if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
323 323
 								{
324 324
 									$ruleApplies = true;
325 325
 									break;
@@ -328,45 +328,45 @@  discard block
 block discarded – undo
328 328
 						}
329 329
 					}
330 330
 				}
331
-				if($ruleApplies)
331
+				if ($ruleApplies)
332 332
 					$rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips'));
333 333
 			}
334 334
 			$this->_rules = array_merge($rules, $this->_rules);
335 335
 		}
336 336
 
337 337
 		// pages
338
-		if(($pagesNode = $dom->getElementByTagName('pages')) !== null)
338
+		if (($pagesNode = $dom->getElementByTagName('pages')) !== null)
339 339
 		{
340 340
 			$this->_properties = array_merge($this->_properties, $pagesNode->getAttributes()->toArray());
341 341
 			// at the page folder
342
-			foreach($pagesNode->getElementsByTagName('page') as $node)
342
+			foreach ($pagesNode->getElementsByTagName('page') as $node)
343 343
 			{
344 344
 				$properties = $node->getAttributes();
345 345
 				$id = $properties->remove('id');
346
-				if(empty($id))
346
+				if (empty($id))
347 347
 					throw new TConfigurationException('pageserviceconf_page_invalid', $configPath);
348 348
 				$matching = false;
349
-				$id = ($configPagePath === '')?$id:$configPagePath . '.' . $id;
350
-				if(strcasecmp($id, $this->_pagePath) === 0)
349
+				$id = ($configPagePath === '') ? $id : $configPagePath.'.'.$id;
350
+				if (strcasecmp($id, $this->_pagePath) === 0)
351 351
 					$matching = true;
352
-				elseif($id[strlen($id) - 1] === '*') // try wildcard matching
352
+				elseif ($id[strlen($id) - 1] === '*') // try wildcard matching
353 353
 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
354
-				if($matching)
354
+				if ($matching)
355 355
 					$this->_properties = array_merge($this->_properties, $properties->toArray());
356 356
 			}
357 357
 		}
358 358
 
359 359
 		// external configurations
360
-		foreach($dom->getElementsByTagName('include') as $node)
360
+		foreach ($dom->getElementsByTagName('include') as $node)
361 361
 		{
362
-			if(($when = $node->getAttribute('when')) === null)
362
+			if (($when = $node->getAttribute('when')) === null)
363 363
 				$when = true;
364
-			if(($filePath = $node->getAttribute('file')) === null)
364
+			if (($filePath = $node->getAttribute('file')) === null)
365 365
 				throw new TConfigurationException('pageserviceconf_includefile_required');
366
-			if(isset($this->_includes[$filePath]))
367
-				$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
366
+			if (isset($this->_includes[$filePath]))
367
+				$this->_includes[$filePath] = [$configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'];
368 368
 			else
369
-				$this->_includes[$filePath] = [$configPagePath,$when];
369
+				$this->_includes[$filePath] = [$configPagePath, $when];
370 370
 		}
371 371
 	}
372 372
 }
373 373
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +73 added lines, -48 removed lines patch added patch discarded remove patch
@@ -118,10 +118,11 @@  discard block
 block discarded – undo
118 118
 		{
119 119
 			$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
120 120
 			$path .= DIRECTORY_SEPARATOR . $p;
121
-			if($configPagePath === '')
122
-				$configPagePath = $p;
123
-			else
124
-				$configPagePath .= '.' . $p;
121
+			if($configPagePath === '') {
122
+							$configPagePath = $p;
123
+			} else {
124
+							$configPagePath .= '.' . $p;
125
+			}
125 126
 		}
126 127
 		$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
127 128
 		$this->_rules = new TAuthorizationRuleCollection($this->_rules);
@@ -135,21 +136,22 @@  discard block
 block discarded – undo
135 136
 	public function loadFromFile($fname, $configPagePath)
136 137
 	{
137 138
 		Prado::trace("Loading page configuration file $fname", 'System.Web.Services.TPageService');
138
-		if(empty($fname) || !is_file($fname))
139
-			return;
139
+		if(empty($fname) || !is_file($fname)) {
140
+					return;
141
+		}
140 142
 
141 143
 		if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
142 144
 		{
143 145
 			$fcontent = include $fname;
144 146
 			$this->loadFromPhp($fcontent, dirname($fname), $configPagePath);
145
-		}
146
-		else
147
+		} else
147 148
 		{
148 149
 			$dom = new TXmlDocument;
149
-			if($dom->loadFromFile($fname))
150
-				$this->loadFromXml($dom, dirname($fname), $configPagePath);
151
-			else
152
-				throw new TConfigurationException('pageserviceconf_file_invalid', $fname);
150
+			if($dom->loadFromFile($fname)) {
151
+							$this->loadFromXml($dom, dirname($fname), $configPagePath);
152
+			} else {
153
+							throw new TConfigurationException('pageserviceconf_file_invalid', $fname);
154
+			}
153 155
 		}
154 156
 	}
155 157
 
@@ -202,27 +204,32 @@  discard block
 block discarded – undo
202 204
 			{
203 205
 				$patterns = isset($authorization['pages'])?$authorization['pages']:'';
204 206
 				$ruleApplies = false;
205
-				if(empty($patterns) || trim($patterns) === '*') // null or empty string
207
+				if(empty($patterns) || trim($patterns) === '*') {
208
+					// null or empty string
206 209
 					$ruleApplies = true;
207
-				else
210
+				} else
208 211
 				{
209 212
 					foreach(explode(',', $patterns) as $pattern)
210 213
 					{
211 214
 						if(($pattern = trim($pattern)) !== '')
212 215
 						{
213 216
 							// we know $configPagePath and $this->_pagePath
214
-							if($configPagePath !== '')  // prepend the pattern with ConfigPagePath
217
+							if($configPagePath !== '') {
218
+								// prepend the pattern with ConfigPagePath
215 219
 								$pattern = $configPagePath . '.' . $pattern;
220
+							}
216 221
 							if(strcasecmp($pattern, $this->_pagePath) === 0)
217 222
 							{
218 223
 								$ruleApplies = true;
219 224
 								break;
220 225
 							}
221
-							if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
226
+							if($pattern[strlen($pattern) - 1] === '*') {
227
+								// try wildcard matching
222 228
 							{
223 229
 								if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
224 230
 								{
225 231
 									$ruleApplies = true;
232
+							}
226 233
 									break;
227 234
 								}
228 235
 							}
@@ -259,12 +266,15 @@  discard block
 block discarded – undo
259 266
 				}
260 267
 				$matching = false;
261 268
 				$id = ($configPagePath === '')?$id:$configPagePath . '.' . $id;
262
-				if(strcasecmp($id, $this->_pagePath) === 0)
263
-					$matching = true;
264
-				elseif($id[strlen($id) - 1] === '*') // try wildcard matching
269
+				if(strcasecmp($id, $this->_pagePath) === 0) {
270
+									$matching = true;
271
+				} elseif($id[strlen($id) - 1] === '*') {
272
+					// try wildcard matching
265 273
 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
266
-				if($matching)
267
-					$this->_properties = array_merge($this->_properties, $properties);
274
+				}
275
+				if($matching) {
276
+									$this->_properties = array_merge($this->_properties, $properties);
277
+				}
268 278
 			}
269 279
 		}
270 280
 
@@ -274,13 +284,15 @@  discard block
 block discarded – undo
274 284
 			foreach($config['includes'] as $include)
275 285
 			{
276 286
 				$when = isset($include['when'])?true:false;
277
-				if(!isset($include['file']))
278
-					throw new TConfigurationException('pageserviceconf_includefile_required');
287
+				if(!isset($include['file'])) {
288
+									throw new TConfigurationException('pageserviceconf_includefile_required');
289
+				}
279 290
 				$filePath = $include['file'];
280
-				if(isset($this->_includes[$filePath]))
281
-					$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
282
-				else
283
-					$this->_includes[$filePath] = [$configPagePath,$when];
291
+				if(isset($this->_includes[$filePath])) {
292
+									$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
293
+				} else {
294
+									$this->_includes[$filePath] = [$configPagePath,$when];
295
+				}
284 296
 			}
285 297
 		}
286 298
 	}
@@ -301,35 +313,41 @@  discard block
 block discarded – undo
301 313
 			{
302 314
 				$patterns = $node->getAttribute('pages');
303 315
 				$ruleApplies = false;
304
-				if(empty($patterns) || trim($patterns) === '*') // null or empty string
316
+				if(empty($patterns) || trim($patterns) === '*') {
317
+					// null or empty string
305 318
 					$ruleApplies = true;
306
-				else
319
+				} else
307 320
 				{
308 321
 					foreach(explode(',', $patterns) as $pattern)
309 322
 					{
310 323
 						if(($pattern = trim($pattern)) !== '')
311 324
 						{
312 325
 							// we know $configPagePath and $this->_pagePath
313
-							if($configPagePath !== '')  // prepend the pattern with ConfigPagePath
326
+							if($configPagePath !== '') {
327
+								// prepend the pattern with ConfigPagePath
314 328
 								$pattern = $configPagePath . '.' . $pattern;
329
+							}
315 330
 							if(strcasecmp($pattern, $this->_pagePath) === 0)
316 331
 							{
317 332
 								$ruleApplies = true;
318 333
 								break;
319 334
 							}
320
-							if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
335
+							if($pattern[strlen($pattern) - 1] === '*') {
336
+								// try wildcard matching
321 337
 							{
322 338
 								if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
323 339
 								{
324 340
 									$ruleApplies = true;
341
+							}
325 342
 									break;
326 343
 								}
327 344
 							}
328 345
 						}
329 346
 					}
330 347
 				}
331
-				if($ruleApplies)
332
-					$rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips'));
348
+				if($ruleApplies) {
349
+									$rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips'));
350
+				}
333 351
 			}
334 352
 			$this->_rules = array_merge($rules, $this->_rules);
335 353
 		}
@@ -343,30 +361,37 @@  discard block
 block discarded – undo
343 361
 			{
344 362
 				$properties = $node->getAttributes();
345 363
 				$id = $properties->remove('id');
346
-				if(empty($id))
347
-					throw new TConfigurationException('pageserviceconf_page_invalid', $configPath);
364
+				if(empty($id)) {
365
+									throw new TConfigurationException('pageserviceconf_page_invalid', $configPath);
366
+				}
348 367
 				$matching = false;
349 368
 				$id = ($configPagePath === '')?$id:$configPagePath . '.' . $id;
350
-				if(strcasecmp($id, $this->_pagePath) === 0)
351
-					$matching = true;
352
-				elseif($id[strlen($id) - 1] === '*') // try wildcard matching
369
+				if(strcasecmp($id, $this->_pagePath) === 0) {
370
+									$matching = true;
371
+				} elseif($id[strlen($id) - 1] === '*') {
372
+					// try wildcard matching
353 373
 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
354
-				if($matching)
355
-					$this->_properties = array_merge($this->_properties, $properties->toArray());
374
+				}
375
+				if($matching) {
376
+									$this->_properties = array_merge($this->_properties, $properties->toArray());
377
+				}
356 378
 			}
357 379
 		}
358 380
 
359 381
 		// external configurations
360 382
 		foreach($dom->getElementsByTagName('include') as $node)
361 383
 		{
362
-			if(($when = $node->getAttribute('when')) === null)
363
-				$when = true;
364
-			if(($filePath = $node->getAttribute('file')) === null)
365
-				throw new TConfigurationException('pageserviceconf_includefile_required');
366
-			if(isset($this->_includes[$filePath]))
367
-				$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
368
-			else
369
-				$this->_includes[$filePath] = [$configPagePath,$when];
384
+			if(($when = $node->getAttribute('when')) === null) {
385
+							$when = true;
386
+			}
387
+			if(($filePath = $node->getAttribute('file')) === null) {
388
+							throw new TConfigurationException('pageserviceconf_includefile_required');
389
+			}
390
+			if(isset($this->_includes[$filePath])) {
391
+							$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
392
+			} else {
393
+							$this->_includes[$filePath] = [$configPagePath,$when];
394
+			}
370 395
 		}
371 396
 	}
372 397
 }
373 398
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Web/Services/TPageService.php 2 patches
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	protected function initPageContext($pageConfig)
175 175
 	{
176 176
 		$application = $this->getApplication();
177
-		foreach($pageConfig->getApplicationConfigurations() as $appConfig)
177
+		foreach ($pageConfig->getApplicationConfigurations() as $appConfig)
178 178
 			$application->applyConfiguration($appConfig);
179 179
 
180 180
 		$this->applyConfiguration($pageConfig);
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 		$this->getApplication()->getAuthorizationRules()->mergeWith($config->getRules());
192 192
 		$pagePath = $this->getRequestedPagePath();
193 193
 		// external configurations
194
-		foreach($config->getExternalConfigurations() as $filePath => $params)
194
+		foreach ($config->getExternalConfigurations() as $filePath => $params)
195 195
 		{
196 196
 			list($configPagePath, $condition) = $params;
197
-			if($condition !== true)
197
+			if ($condition !== true)
198 198
 				$condition = $this->evaluateExpression($condition);
199
-			if($condition)
199
+			if ($condition)
200 200
 			{
201
-				if(($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path))
201
+				if (($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path))
202 202
 					throw new TConfigurationException('pageservice_includefile_invalid', $filePath);
203 203
 				$c = new TPageConfiguration($pagePath);
204 204
 				$c->loadFromFile($path, $configPagePath);
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	protected function determineRequestedPagePath()
216 216
 	{
217 217
 		$pagePath = $this->getRequest()->getServiceParameter();
218
-		if(empty($pagePath))
218
+		if (empty($pagePath))
219 219
 			$pagePath = $this->getDefaultPage();
220 220
 		return $pagePath;
221 221
 	}
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
 	{
230 230
 		$application = $this->getApplication();
231 231
 		$pagePath = $this->getRequestedPagePath();
232
-		if(($cache = $application->getCache()) === null)
232
+		if (($cache = $application->getCache()) === null)
233 233
 		{
234 234
 			$pageConfig = new TPageConfiguration($pagePath);
235
-			if($config !== null)
235
+			if ($config !== null)
236 236
 			{
237
-				if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
237
+				if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
238 238
 					$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
239 239
 				else
240 240
 					$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
@@ -245,25 +245,25 @@  discard block
 block discarded – undo
245 245
 		{
246 246
 			$configCached = true;
247 247
 			$currentTimestamp = [];
248
-			$arr = $cache->get(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath);
249
-			if(is_array($arr))
248
+			$arr = $cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath);
249
+			if (is_array($arr))
250 250
 			{
251 251
 				list($pageConfig, $timestamps) = $arr;
252
-				if($application->getMode() !== TApplicationMode::Performance)
252
+				if ($application->getMode() !== TApplicationMode::Performance)
253 253
 				{
254
-					foreach($timestamps as $fileName => $timestamp)
254
+					foreach ($timestamps as $fileName => $timestamp)
255 255
 					{
256
-						if($fileName === 0) // application config file
256
+						if ($fileName === 0) // application config file
257 257
 						{
258 258
 							$appConfigFile = $application->getConfigurationFile();
259
-							$currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile);
260
-							if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0]))
259
+							$currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile);
260
+							if ($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0]))
261 261
 								$configCached = false;
262 262
 						}
263 263
 						else
264 264
 						{
265 265
 							$currentTimestamp[$fileName] = @filemtime($fileName);
266
-							if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName]))
266
+							if ($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName]))
267 267
 								$configCached = false;
268 268
 						}
269 269
 					}
@@ -277,27 +277,27 @@  discard block
 block discarded – undo
277 277
 				$fileName = $this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP
278 278
 					? self::CONFIG_FILE_PHP
279 279
 					: self::CONFIG_FILE_XML;
280
-				foreach($paths as $path)
280
+				foreach ($paths as $path)
281 281
 				{
282
-					$configFile = $configPath . DIRECTORY_SEPARATOR . $fileName;
282
+					$configFile = $configPath.DIRECTORY_SEPARATOR.$fileName;
283 283
 					$currentTimestamp[$configFile] = @filemtime($configFile);
284
-					$configPath .= DIRECTORY_SEPARATOR . $path;
284
+					$configPath .= DIRECTORY_SEPARATOR.$path;
285 285
 				}
286 286
 				$appConfigFile = $application->getConfigurationFile();
287
-				$currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile);
287
+				$currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile);
288 288
 			}
289
-			if(!$configCached)
289
+			if (!$configCached)
290 290
 			{
291 291
 				$pageConfig = new TPageConfiguration($pagePath);
292
-				if($config !== null)
292
+				if ($config !== null)
293 293
 				{
294
-					if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
294
+					if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
295 295
 						$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
296 296
 					else
297 297
 						$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
298 298
 				}
299 299
 				$pageConfig->loadFromFiles($this->getBasePath());
300
-				$cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, [$pageConfig,$currentTimestamp]);
300
+				$cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath, [$pageConfig, $currentTimestamp]);
301 301
 			}
302 302
 		}
303 303
 		return $pageConfig;
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 */
309 309
 	public function getTemplateManager()
310 310
 	{
311
-		if(!$this->_templateManager)
311
+		if (!$this->_templateManager)
312 312
 		{
313 313
 			$this->_templateManager = new TTemplateManager;
314 314
 			$this->_templateManager->init(null);
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	 */
330 330
 	public function getThemeManager()
331 331
 	{
332
-		if(!$this->_themeManager)
332
+		if (!$this->_themeManager)
333 333
 		{
334 334
 			$this->_themeManager = new TThemeManager;
335 335
 			$this->_themeManager->init(null);
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
 	 */
351 351
 	public function getRequestedPagePath()
352 352
 	{
353
-		if($this->_pagePath === null)
353
+		if ($this->_pagePath === null)
354 354
 		{
355 355
 			$this->_pagePath = strtr($this->determineRequestedPagePath(), '/\\', '..');
356
-			if(empty($this->_pagePath))
356
+			if (empty($this->_pagePath))
357 357
 				throw new THttpException(404, 'pageservice_page_required');
358 358
 		}
359 359
 		return $this->_pagePath;
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 	 */
382 382
 	public function setDefaultPage($value)
383 383
 	{
384
-		if($this->_initialized)
384
+		if ($this->_initialized)
385 385
 			throw new TInvalidOperationException('pageservice_defaultpage_unchangeable');
386 386
 		else
387 387
 			$this->_defaultPage = $value;
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 	 */
401 401
 	public function getBasePath()
402 402
 	{
403
-		if($this->_basePath === null)
403
+		if ($this->_basePath === null)
404 404
 		{
405
-			$basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH;
406
-			if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
405
+			$basePath = $this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH;
406
+			if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
407 407
 			{
408
-				$basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::FALLBACK_BASEPATH;
409
-				if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
408
+				$basePath = $this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH;
409
+				if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
410 410
 					throw new TConfigurationException('pageservice_basepath_invalid', $basePath);
411 411
 			}
412 412
 		}
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
 	 */
420 420
 	public function setBasePath($value)
421 421
 	{
422
-		if($this->_initialized)
422
+		if ($this->_initialized)
423 423
 			throw new TInvalidOperationException('pageservice_basepath_unchangeable');
424
-		elseif(($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path))
424
+		elseif (($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path))
425 425
 			throw new TConfigurationException('pageservice_basepath_invalid', $value);
426 426
 		$this->_basePath = realpath($path);
427 427
 	}
@@ -485,40 +485,40 @@  discard block
 block discarded – undo
485 485
 	 */
486 486
 	protected function createPage($pagePath)
487 487
 	{
488
-		$path = $this->getBasePath() . DIRECTORY_SEPARATOR . strtr($pagePath, '.', DIRECTORY_SEPARATOR);
489
-		$hasTemplateFile = is_file($path . self::PAGE_FILE_EXT);
490
-		$hasClassFile = is_file($path . Prado::CLASS_FILE_EXT);
488
+		$path = $this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath, '.', DIRECTORY_SEPARATOR);
489
+		$hasTemplateFile = is_file($path.self::PAGE_FILE_EXT);
490
+		$hasClassFile = is_file($path.Prado::CLASS_FILE_EXT);
491 491
 
492
-		if(!$hasTemplateFile && !$hasClassFile)
492
+		if (!$hasTemplateFile && !$hasClassFile)
493 493
 			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
494 494
 
495
-		if($hasClassFile)
495
+		if ($hasClassFile)
496 496
 		{
497 497
 			$className = basename($path);
498
-			$namespacedClassName = static::PAGE_NAMESPACE_PREFIX . str_replace('.', '\\', $pagePath);
498
+			$namespacedClassName = static::PAGE_NAMESPACE_PREFIX.str_replace('.', '\\', $pagePath);
499 499
 
500
-			if(!class_exists($className, false) && !class_exists($namespacedClassName, false))
501
-				include_once($path . Prado::CLASS_FILE_EXT);
500
+			if (!class_exists($className, false) && !class_exists($namespacedClassName, false))
501
+				include_once($path.Prado::CLASS_FILE_EXT);
502 502
 
503
-			if(!class_exists($className, false))
503
+			if (!class_exists($className, false))
504 504
 				$className = $namespacedClassName;
505 505
 		}
506 506
 		else
507 507
 		{
508 508
 			$className = $this->getBasePageClass();
509 509
 			Prado::using($className);
510
-			if(($pos = strrpos($className, '.')) !== false)
510
+			if (($pos = strrpos($className, '.')) !== false)
511 511
 				$className = substr($className, $pos + 1);
512 512
 		}
513 513
 
514
-		if($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage'))
514
+		if ($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage'))
515 515
 			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
516 516
 
517 517
 		$page = Prado::createComponent($className);
518 518
 		$page->setPagePath($pagePath);
519 519
 
520
-		if($hasTemplateFile)
521
-			$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT));
520
+		if ($hasTemplateFile)
521
+			$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT));
522 522
 
523 523
 		return $page;
524 524
 	}
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 */
531 531
 	protected function runPage($page, $properties)
532 532
 	{
533
-		foreach($properties as $name => $value)
533
+		foreach ($properties as $name => $value)
534 534
 			$page->setSubProperty($name, $value);
535 535
 		$page->run($this->getResponse()->createHtmlWriter());
536 536
 	}
Please login to merge, or discard this patch.
Braces   +72 added lines, -55 removed lines patch added patch discarded remove patch
@@ -174,8 +174,9 @@  discard block
 block discarded – undo
174 174
 	protected function initPageContext($pageConfig)
175 175
 	{
176 176
 		$application = $this->getApplication();
177
-		foreach($pageConfig->getApplicationConfigurations() as $appConfig)
178
-			$application->applyConfiguration($appConfig);
177
+		foreach($pageConfig->getApplicationConfigurations() as $appConfig) {
178
+					$application->applyConfiguration($appConfig);
179
+		}
179 180
 
180 181
 		$this->applyConfiguration($pageConfig);
181 182
 	}
@@ -194,12 +195,14 @@  discard block
 block discarded – undo
194 195
 		foreach($config->getExternalConfigurations() as $filePath => $params)
195 196
 		{
196 197
 			list($configPagePath, $condition) = $params;
197
-			if($condition !== true)
198
-				$condition = $this->evaluateExpression($condition);
198
+			if($condition !== true) {
199
+							$condition = $this->evaluateExpression($condition);
200
+			}
199 201
 			if($condition)
200 202
 			{
201
-				if(($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path))
202
-					throw new TConfigurationException('pageservice_includefile_invalid', $filePath);
203
+				if(($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path)) {
204
+									throw new TConfigurationException('pageservice_includefile_invalid', $filePath);
205
+				}
203 206
 				$c = new TPageConfiguration($pagePath);
204 207
 				$c->loadFromFile($path, $configPagePath);
205 208
 				$this->applyConfiguration($c);
@@ -215,8 +218,9 @@  discard block
 block discarded – undo
215 218
 	protected function determineRequestedPagePath()
216 219
 	{
217 220
 		$pagePath = $this->getRequest()->getServiceParameter();
218
-		if(empty($pagePath))
219
-			$pagePath = $this->getDefaultPage();
221
+		if(empty($pagePath)) {
222
+					$pagePath = $this->getDefaultPage();
223
+		}
220 224
 		return $pagePath;
221 225
 	}
222 226
 
@@ -234,14 +238,14 @@  discard block
 block discarded – undo
234 238
 			$pageConfig = new TPageConfiguration($pagePath);
235 239
 			if($config !== null)
236 240
 			{
237
-				if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
238
-					$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
239
-				else
240
-					$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
241
+				if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
242
+									$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
243
+				} else {
244
+									$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
245
+				}
241 246
 			}
242 247
 			$pageConfig->loadFromFiles($this->getBasePath());
243
-		}
244
-		else
248
+		} else
245 249
 		{
246 250
 			$configCached = true;
247 251
 			$currentTimestamp = [];
@@ -253,23 +257,25 @@  discard block
 block discarded – undo
253 257
 				{
254 258
 					foreach($timestamps as $fileName => $timestamp)
255 259
 					{
256
-						if($fileName === 0) // application config file
260
+						if($fileName === 0) {
261
+							// application config file
257 262
 						{
258 263
 							$appConfigFile = $application->getConfigurationFile();
259
-							$currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile);
260
-							if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0]))
261
-								$configCached = false;
262 264
 						}
263
-						else
265
+							$currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile);
266
+							if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) {
267
+															$configCached = false;
268
+							}
269
+						} else
264 270
 						{
265 271
 							$currentTimestamp[$fileName] = @filemtime($fileName);
266
-							if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName]))
267
-								$configCached = false;
272
+							if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) {
273
+															$configCached = false;
274
+							}
268 275
 						}
269 276
 					}
270 277
 				}
271
-			}
272
-			else
278
+			} else
273 279
 			{
274 280
 				$configCached = false;
275 281
 				$paths = explode('.', $pagePath);
@@ -291,10 +297,11 @@  discard block
 block discarded – undo
291 297
 				$pageConfig = new TPageConfiguration($pagePath);
292 298
 				if($config !== null)
293 299
 				{
294
-					if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
295
-						$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
296
-					else
297
-						$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
300
+					if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
301
+											$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
302
+					} else {
303
+											$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
304
+					}
298 305
 				}
299 306
 				$pageConfig->loadFromFiles($this->getBasePath());
300 307
 				$cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, [$pageConfig,$currentTimestamp]);
@@ -353,8 +360,9 @@  discard block
 block discarded – undo
353 360
 		if($this->_pagePath === null)
354 361
 		{
355 362
 			$this->_pagePath = strtr($this->determineRequestedPagePath(), '/\\', '..');
356
-			if(empty($this->_pagePath))
357
-				throw new THttpException(404, 'pageservice_page_required');
363
+			if(empty($this->_pagePath)) {
364
+							throw new THttpException(404, 'pageservice_page_required');
365
+			}
358 366
 		}
359 367
 		return $this->_pagePath;
360 368
 	}
@@ -381,10 +389,11 @@  discard block
 block discarded – undo
381 389
 	 */
382 390
 	public function setDefaultPage($value)
383 391
 	{
384
-		if($this->_initialized)
385
-			throw new TInvalidOperationException('pageservice_defaultpage_unchangeable');
386
-		else
387
-			$this->_defaultPage = $value;
392
+		if($this->_initialized) {
393
+					throw new TInvalidOperationException('pageservice_defaultpage_unchangeable');
394
+		} else {
395
+					$this->_defaultPage = $value;
396
+		}
388 397
 	}
389 398
 
390 399
 	/**
@@ -406,8 +415,9 @@  discard block
 block discarded – undo
406 415
 			if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
407 416
 			{
408 417
 				$basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::FALLBACK_BASEPATH;
409
-				if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
410
-					throw new TConfigurationException('pageservice_basepath_invalid', $basePath);
418
+				if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) {
419
+									throw new TConfigurationException('pageservice_basepath_invalid', $basePath);
420
+				}
411 421
 			}
412 422
 		}
413 423
 		return $this->_basePath;
@@ -419,10 +429,11 @@  discard block
 block discarded – undo
419 429
 	 */
420 430
 	public function setBasePath($value)
421 431
 	{
422
-		if($this->_initialized)
423
-			throw new TInvalidOperationException('pageservice_basepath_unchangeable');
424
-		elseif(($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path))
425
-			throw new TConfigurationException('pageservice_basepath_invalid', $value);
432
+		if($this->_initialized) {
433
+					throw new TInvalidOperationException('pageservice_basepath_unchangeable');
434
+		} elseif(($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path)) {
435
+					throw new TConfigurationException('pageservice_basepath_invalid', $value);
436
+		}
426 437
 		$this->_basePath = realpath($path);
427 438
 	}
428 439
 
@@ -489,36 +500,41 @@  discard block
 block discarded – undo
489 500
 		$hasTemplateFile = is_file($path . self::PAGE_FILE_EXT);
490 501
 		$hasClassFile = is_file($path . Prado::CLASS_FILE_EXT);
491 502
 
492
-		if(!$hasTemplateFile && !$hasClassFile)
493
-			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
503
+		if(!$hasTemplateFile && !$hasClassFile) {
504
+					throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
505
+		}
494 506
 
495 507
 		if($hasClassFile)
496 508
 		{
497 509
 			$className = basename($path);
498 510
 			$namespacedClassName = static::PAGE_NAMESPACE_PREFIX . str_replace('.', '\\', $pagePath);
499 511
 
500
-			if(!class_exists($className, false) && !class_exists($namespacedClassName, false))
501
-				include_once($path . Prado::CLASS_FILE_EXT);
512
+			if(!class_exists($className, false) && !class_exists($namespacedClassName, false)) {
513
+							include_once($path . Prado::CLASS_FILE_EXT);
514
+			}
502 515
 
503
-			if(!class_exists($className, false))
504
-				$className = $namespacedClassName;
505
-		}
506
-		else
516
+			if(!class_exists($className, false)) {
517
+							$className = $namespacedClassName;
518
+			}
519
+		} else
507 520
 		{
508 521
 			$className = $this->getBasePageClass();
509 522
 			Prado::using($className);
510
-			if(($pos = strrpos($className, '.')) !== false)
511
-				$className = substr($className, $pos + 1);
523
+			if(($pos = strrpos($className, '.')) !== false) {
524
+							$className = substr($className, $pos + 1);
525
+			}
512 526
 		}
513 527
 
514
-		if($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage'))
515
-			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
528
+		if($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage')) {
529
+					throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
530
+		}
516 531
 
517 532
 		$page = Prado::createComponent($className);
518 533
 		$page->setPagePath($pagePath);
519 534
 
520
-		if($hasTemplateFile)
521
-			$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT));
535
+		if($hasTemplateFile) {
536
+					$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT));
537
+		}
522 538
 
523 539
 		return $page;
524 540
 	}
@@ -530,8 +546,9 @@  discard block
 block discarded – undo
530 546
 	 */
531 547
 	protected function runPage($page, $properties)
532 548
 	{
533
-		foreach($properties as $name => $value)
534
-			$page->setSubProperty($name, $value);
549
+		foreach($properties as $name => $value) {
550
+					$page->setSubProperty($name, $value);
551
+		}
535 552
 		$page->run($this->getResponse()->createHtmlWriter());
536 553
 	}
537 554
 
Please login to merge, or discard this patch.
framework/Web/Services/TJsonRpcProtocol.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -40,31 +40,31 @@  discard block
 block discarded – undo
40 40
 		{
41 41
 			$_request = $this->decode($requestPayload);
42 42
 
43
-			if(isset($_request['jsonrpc']))
43
+			if (isset($_request['jsonrpc']))
44 44
 			{
45 45
 				$this->_specificationVersion = $_request['jsonrpc'];
46
-				if($this->_specificationVersion > 2.0)
46
+				if ($this->_specificationVersion > 2.0)
47 47
 					throw new TRpcException('Unsupported specification version', '-32600');
48 48
 			}
49 49
 
50
-			if(isset($_request['id']))
50
+			if (isset($_request['id']))
51 51
 				$this->_id = $_request['id'];
52 52
 
53
-			if(!isset($_request['method']))
53
+			if (!isset($_request['method']))
54 54
 					throw new TRpcException('Missing request method', '-32600');
55 55
 
56
-			if(!isset($_request['params']))
56
+			if (!isset($_request['params']))
57 57
 				$parameters = [];
58 58
 			else
59 59
 				$parameters = $_request['params'];
60 60
 
61
-			if(!is_array($parameters))
61
+			if (!is_array($parameters))
62 62
 				$parameters = [$parameters];
63 63
 
64 64
 			// a request without an id is a notification that doesn't need a response
65
-			if($this->_id !== null)
65
+			if ($this->_id !== null)
66 66
 			{
67
-				if($this->_specificationVersion == 2.0)
67
+				if ($this->_specificationVersion == 2.0)
68 68
 				{
69 69
 					return $this->encode([
70 70
 						'jsonrpc' => '2.0',
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 				}
81 81
 			}
82 82
 		}
83
-		catch(TRpcException $e)
83
+		catch (TRpcException $e)
84 84
 		{
85 85
 			return $this->createErrorResponse($e);
86 86
 		}
87
-		catch(THttpException $e)
87
+		catch (THttpException $e)
88 88
 		{
89 89
 			throw $e;
90 90
 		}
91
-		catch(\Exception $e)
91
+		catch (\Exception $e)
92 92
 		{
93 93
 			return $this->createErrorResponse(new TRpcException('An internal error occured', '-32603'));
94 94
 		}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function createErrorResponse(TRpcException $exception)
103 103
 	{
104
-		if($this->_specificationVersion == 2.0)
104
+		if ($this->_specificationVersion == 2.0)
105 105
 		{
106 106
 			return $this->encode([
107 107
 				'id' => $this->_id,
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	private static function checkJsonError()
162 162
 	{
163 163
 		$errnum = json_last_error();
164
-		if($errnum != JSON_ERROR_NONE)
164
+		if ($errnum != JSON_ERROR_NONE)
165 165
 			throw new \Exception("JSON error: $msg", $err);
166 166
 	}
167 167
 
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	public function callApiMethod($methodName, $parameters)
176 176
 	{
177
-		if(!isset($this->rpcMethods[$methodName]))
178
-			throw new TRpcException('Method "' . $methodName . '" not found', '-32601');
177
+		if (!isset($this->rpcMethods[$methodName]))
178
+			throw new TRpcException('Method "'.$methodName.'" not found', '-32601');
179 179
 
180 180
 		return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters);
181 181
 	}
Please login to merge, or discard this patch.
Braces   +26 added lines, -22 removed lines patch added patch discarded remove patch
@@ -43,23 +43,28 @@  discard block
 block discarded – undo
43 43
 			if(isset($_request['jsonrpc']))
44 44
 			{
45 45
 				$this->_specificationVersion = $_request['jsonrpc'];
46
-				if($this->_specificationVersion > 2.0)
47
-					throw new TRpcException('Unsupported specification version', '-32600');
46
+				if($this->_specificationVersion > 2.0) {
47
+									throw new TRpcException('Unsupported specification version', '-32600');
48
+				}
48 49
 			}
49 50
 
50
-			if(isset($_request['id']))
51
-				$this->_id = $_request['id'];
51
+			if(isset($_request['id'])) {
52
+							$this->_id = $_request['id'];
53
+			}
52 54
 
53
-			if(!isset($_request['method']))
54
-					throw new TRpcException('Missing request method', '-32600');
55
+			if(!isset($_request['method'])) {
56
+								throw new TRpcException('Missing request method', '-32600');
57
+			}
55 58
 
56
-			if(!isset($_request['params']))
57
-				$parameters = [];
58
-			else
59
-				$parameters = $_request['params'];
59
+			if(!isset($_request['params'])) {
60
+							$parameters = [];
61
+			} else {
62
+							$parameters = $_request['params'];
63
+			}
60 64
 
61
-			if(!is_array($parameters))
62
-				$parameters = [$parameters];
65
+			if(!is_array($parameters)) {
66
+							$parameters = [$parameters];
67
+			}
63 68
 
64 69
 			// a request without an id is a notification that doesn't need a response
65 70
 			if($this->_id !== null)
@@ -79,16 +84,13 @@  discard block
 block discarded – undo
79 84
 					]);
80 85
 				}
81 86
 			}
82
-		}
83
-		catch(TRpcException $e)
87
+		} catch(TRpcException $e)
84 88
 		{
85 89
 			return $this->createErrorResponse($e);
86
-		}
87
-		catch(THttpException $e)
90
+		} catch(THttpException $e)
88 91
 		{
89 92
 			throw $e;
90
-		}
91
-		catch(\Exception $e)
93
+		} catch(\Exception $e)
92 94
 		{
93 95
 			return $this->createErrorResponse(new TRpcException('An internal error occured', '-32603'));
94 96
 		}
@@ -161,8 +163,9 @@  discard block
 block discarded – undo
161 163
 	private static function checkJsonError()
162 164
 	{
163 165
 		$errnum = json_last_error();
164
-		if($errnum != JSON_ERROR_NONE)
165
-			throw new \Exception("JSON error: $msg", $err);
166
+		if($errnum != JSON_ERROR_NONE) {
167
+					throw new \Exception("JSON error: $msg", $err);
168
+		}
166 169
 	}
167 170
 
168 171
 	/**
@@ -174,8 +177,9 @@  discard block
 block discarded – undo
174 177
 	 */
175 178
 	public function callApiMethod($methodName, $parameters)
176 179
 	{
177
-		if(!isset($this->rpcMethods[$methodName]))
178
-			throw new TRpcException('Method "' . $methodName . '" not found', '-32601');
180
+		if(!isset($this->rpcMethods[$methodName])) {
181
+					throw new TRpcException('Method "' . $methodName . '" not found', '-32601');
182
+		}
179 183
 
180 184
 		return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters);
181 185
 	}
Please login to merge, or discard this patch.