@@ -19,8 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | namespace Jaxon\Traits; |
| 21 | 21 | |
| 22 | -use Jaxon\Utils\Container; |
|
| 23 | - |
|
| 24 | 22 | trait Autoload |
| 25 | 23 | { |
| 26 | 24 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param string $sLibKey The key of the library options in the file |
| 70 | 70 | * @param string|null $sAppKey The key of the application options in the file |
| 71 | 71 | * |
| 72 | - * @return array |
|
| 72 | + * @return null|\Jaxon\Utils\Config\Config |
|
| 73 | 73 | */ |
| 74 | 74 | public function readPhpConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 75 | 75 | { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string $sLibKey The key of the library options in the file |
| 84 | 84 | * @param string|null $sAppKey The key of the application options in the file |
| 85 | 85 | * |
| 86 | - * @return array |
|
| 86 | + * @return null|\Jaxon\Utils\Config\Config |
|
| 87 | 87 | */ |
| 88 | 88 | public function readYamlConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 89 | 89 | { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param string $sLibKey The key of the library options in the file |
| 98 | 98 | * @param string|null $sAppKey The key of the application options in the file |
| 99 | 99 | * |
| 100 | - * @return array |
|
| 100 | + * @return \Jaxon\Utils\Config\Config|null |
|
| 101 | 101 | */ |
| 102 | 102 | public function readJsonConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 103 | 103 | { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param string $sLibKey The key of the library options in the file |
| 112 | 112 | * @param string|null $sAppKey The key of the application options in the file |
| 113 | 113 | * |
| 114 | - * @return array |
|
| 114 | + * @return null|\Jaxon\Utils\Config\Config |
|
| 115 | 115 | */ |
| 116 | 116 | public function readConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 117 | 117 | { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | 'core.prefix.event' => 'jaxon_event_', |
| 44 | 44 | // 'core.request.uri' => '', |
| 45 | 45 | 'core.request.mode' => 'asynchronous', |
| 46 | - 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 46 | + 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 47 | 47 | 'core.response.merge.ap' => true, |
| 48 | 48 | 'core.response.merge.js' => true, |
| 49 | 49 | 'core.debug.on' => false, |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | public function readConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 119 | 119 | { |
| 120 | 120 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
| 121 | - switch($sExt) |
|
| 121 | + switch ($sExt) |
|
| 122 | 122 | { |
| 123 | 123 | case 'php': |
| 124 | 124 | return $this->readPhpConfigFile($sConfigFile, $sLibKey, $sAppKey); |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * - 1000 thru 8999: User created plugins, typically, these plugins don't care about order |
| 32 | 32 | * - 9000 thru 9999: Plugins that generally need to be last or near the end of the plugin list |
| 33 | 33 | * |
| 34 | - * @param Plugin $xPlugin An instance of a plugin |
|
| 34 | + * @param \Jaxon\Plugin\Plugin $xPlugin An instance of a plugin |
|
| 35 | 35 | * @param integer $nPriority The plugin priority, used to order the plugins |
| 36 | 36 | * |
| 37 | 37 | * @return void |
@@ -19,8 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | namespace Jaxon\Traits; |
| 21 | 21 | |
| 22 | -use Jaxon\Utils\Container; |
|
| 23 | - |
|
| 24 | 22 | trait Plugin |
| 25 | 23 | { |
| 26 | 24 | /** |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | /** |
| 47 | 47 | * Check uploaded files validity and move them to the user dir |
| 48 | 48 | * |
| 49 | - * @return boolean |
|
| 49 | + * @return null|boolean |
|
| 50 | 50 | */ |
| 51 | 51 | public function saveUploadedFiles() |
| 52 | 52 | { |
@@ -19,11 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | namespace Jaxon\Traits; |
| 21 | 21 | |
| 22 | -use Jaxon\Plugin\Manager as PluginManager; |
|
| 23 | -use Jaxon\Request\Manager as RequestManager; |
|
| 24 | -use Jaxon\Response\Manager as ResponseManager; |
|
| 25 | - |
|
| 26 | -use Jaxon\Utils\URI; |
|
| 27 | 22 | use Exception; |
| 28 | 23 | use Closure; |
| 29 | 24 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | trait Upload |
| 31 | 31 | { |
| 32 | - /** |
|
| 32 | + /** |
|
| 33 | 33 | * Check if uploaded files are available |
| 34 | 34 | * |
| 35 | 35 | * @return boolean |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | return $xUploadPlugin->canProcessRequest(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - /** |
|
| 46 | + /** |
|
| 47 | 47 | * Check uploaded files validity and move them to the user dir |
| 48 | 48 | * |
| 49 | 49 | * @return boolean |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function hasUploadedFiles() |
| 38 | 38 | { |
| 39 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 39 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 40 | 40 | { |
| 41 | 41 | return false; |
| 42 | 42 | } |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | try |
| 54 | 54 | { |
| 55 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 55 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 56 | 56 | { |
| 57 | 57 | throw new Exception($this->trans('errors.upload.plugin')); |
| 58 | 58 | } |
| 59 | - elseif(!$xUploadPlugin->canProcessRequest()) |
|
| 59 | + elseif (!$xUploadPlugin->canProcessRequest()) |
|
| 60 | 60 | { |
| 61 | 61 | throw new Exception($this->trans('errors.upload.request')); |
| 62 | 62 | } |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | $sResponse = '{"code": "success", "upl": "' . $sKey . '"}'; |
| 66 | 66 | $return = true; |
| 67 | 67 | } |
| 68 | - catch(Exception $e) |
|
| 68 | + catch (Exception $e) |
|
| 69 | 69 | { |
| 70 | 70 | $sResponse = '{"code": "error", "msg": "' . addslashes($e->getMessage()) . '"}'; |
| 71 | 71 | $return = false; |
| 72 | 72 | } |
| 73 | 73 | // Send the response back to the browser |
| 74 | 74 | echo '<script>var res = ', $sResponse, '; </script>'; |
| 75 | - if(($this->getOption('core.process.exit'))) |
|
| 75 | + if (($this->getOption('core.process.exit'))) |
|
| 76 | 76 | { |
| 77 | 77 | exit(); |
| 78 | 78 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function getUploadedFiles() |
| 88 | 88 | { |
| 89 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 89 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 90 | 90 | { |
| 91 | 91 | return []; |
| 92 | 92 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function setUploadFileFilter(Closure $fFileFilter) |
| 104 | 104 | { |
| 105 | - if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 105 | + if (($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
|
| 106 | 106 | { |
| 107 | 107 | return; |
| 108 | 108 | } |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) |
| 56 | 56 | { |
| 57 | 57 | throw new Exception($this->trans('errors.upload.plugin')); |
| 58 | - } |
|
| 59 | - elseif(!$xUploadPlugin->canProcessRequest()) |
|
| 58 | + } elseif(!$xUploadPlugin->canProcessRequest()) |
|
| 60 | 59 | { |
| 61 | 60 | throw new Exception($this->trans('errors.upload.request')); |
| 62 | 61 | } |
@@ -64,8 +63,7 @@ discard block |
||
| 64 | 63 | $sKey = $xUploadPlugin->saveUploadedFiles(); |
| 65 | 64 | $sResponse = '{"code": "success", "upl": "' . $sKey . '"}'; |
| 66 | 65 | $return = true; |
| 67 | - } |
|
| 68 | - catch(Exception $e) |
|
| 66 | + } catch(Exception $e) |
|
| 69 | 67 | { |
| 70 | 68 | $sResponse = '{"code": "error", "msg": "' . addslashes($e->getMessage()) . '"}'; |
| 71 | 69 | $return = false; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function __construct($xCallable) |
| 95 | 95 | { |
| 96 | - if(is_string($xCallable)) // Received a class name |
|
| 96 | + if (is_string($xCallable)) // Received a class name |
|
| 97 | 97 | { |
| 98 | 98 | $this->reflectionClass = new \ReflectionClass($xCallable); |
| 99 | 99 | $this->callableObject = null; |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | private function setCallable($xCallable = null) |
| 121 | 121 | { |
| 122 | - if($xCallable == null) |
|
| 122 | + if ($xCallable == null) |
|
| 123 | 123 | { |
| 124 | 124 | // Use the Reflection class to get the parameters of the constructor |
| 125 | - if(($constructor = $this->reflectionClass->getConstructor()) != null) |
|
| 125 | + if (($constructor = $this->reflectionClass->getConstructor()) != null) |
|
| 126 | 126 | { |
| 127 | 127 | $parameters = $constructor->getParameters(); |
| 128 | 128 | $parameterInstances = []; |
| 129 | - foreach($parameters as $parameter) |
|
| 129 | + foreach ($parameters as $parameter) |
|
| 130 | 130 | { |
| 131 | 131 | // Get the parameter instance from the DI |
| 132 | 132 | $parameterInstances[] = $this->diGet($parameter->getClass()->getName()); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | // Save the Jaxon callable object into the user callable object |
| 142 | - if($this->reflectionClass->hasMethod('setJaxonCallable')) |
|
| 142 | + if ($this->reflectionClass->hasMethod('setJaxonCallable')) |
|
| 143 | 143 | { |
| 144 | 144 | $xCallable->setJaxonCallable($this); |
| 145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function getRegisteredObject() |
| 155 | 155 | { |
| 156 | - if($this->callableObject == null) |
|
| 156 | + if ($this->callableObject == null) |
|
| 157 | 157 | { |
| 158 | 158 | $this->setCallable(); |
| 159 | 159 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | // The class name without the namespace. |
| 182 | 182 | $name = $this->reflectionClass->getShortName(); |
| 183 | 183 | // Append the classpath to the name |
| 184 | - if(($this->classpath)) |
|
| 184 | + if (($this->classpath)) |
|
| 185 | 185 | { |
| 186 | 186 | $name = $this->classpath . '\\' . $name; |
| 187 | 187 | } |
@@ -228,16 +228,16 @@ discard block |
||
| 228 | 228 | public function getMethods() |
| 229 | 229 | { |
| 230 | 230 | $aReturn = []; |
| 231 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 231 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 232 | 232 | { |
| 233 | 233 | $sMethodName = $xMethod->getShortName(); |
| 234 | 234 | // Don't take magic __call, __construct, __destruct methods |
| 235 | - if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 235 | + if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 236 | 236 | { |
| 237 | 237 | continue; |
| 238 | 238 | } |
| 239 | 239 | // Don't take excluded methods |
| 240 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
| 240 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
| 241 | 241 | { |
| 242 | 242 | continue; |
| 243 | 243 | } |
@@ -258,37 +258,37 @@ discard block |
||
| 258 | 258 | public function configure($sMethod, $sName, $sValue) |
| 259 | 259 | { |
| 260 | 260 | // Set the namespace |
| 261 | - if($sName == 'namespace') |
|
| 261 | + if ($sName == 'namespace') |
|
| 262 | 262 | { |
| 263 | - if($sValue != '') |
|
| 263 | + if ($sValue != '') |
|
| 264 | 264 | $this->namespace = $sValue; |
| 265 | 265 | return; |
| 266 | 266 | } |
| 267 | 267 | // Set the classpath |
| 268 | - if($sName == 'classpath') |
|
| 268 | + if ($sName == 'classpath') |
|
| 269 | 269 | { |
| 270 | - if($sValue != '') |
|
| 270 | + if ($sValue != '') |
|
| 271 | 271 | $this->classpath = trim($sValue, '\\'); |
| 272 | 272 | return; |
| 273 | 273 | } |
| 274 | 274 | // Set the separator |
| 275 | - if($sName == 'separator') |
|
| 275 | + if ($sName == 'separator') |
|
| 276 | 276 | { |
| 277 | - if($sValue == '_' || $sValue == '.') |
|
| 277 | + if ($sValue == '_' || $sValue == '.') |
|
| 278 | 278 | $this->separator = $sValue; |
| 279 | 279 | return; |
| 280 | 280 | } |
| 281 | 281 | // Set the excluded methods |
| 282 | - if($sName == 'protected') |
|
| 282 | + if ($sName == 'protected') |
|
| 283 | 283 | { |
| 284 | - if(is_array($sValue)) |
|
| 284 | + if (is_array($sValue)) |
|
| 285 | 285 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
| 286 | - elseif(is_string($sValue)) |
|
| 286 | + elseif (is_string($sValue)) |
|
| 287 | 287 | $this->aProtectedMethods[] = $sValue; |
| 288 | 288 | return; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if(!isset($this->aConfiguration[$sMethod])) |
|
| 291 | + if (!isset($this->aConfiguration[$sMethod])) |
|
| 292 | 292 | { |
| 293 | 293 | $this->aConfiguration[$sMethod] = []; |
| 294 | 294 | } |
@@ -309,16 +309,16 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | // Common options to be set on all methods |
| 311 | 311 | $aCommonConfig = array_key_exists('*', $this->aConfiguration) ? $this->aConfiguration['*'] : []; |
| 312 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 312 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 313 | 313 | { |
| 314 | 314 | $sMethodName = $xMethod->getShortName(); |
| 315 | 315 | // Don't export magic __call, __construct, __destruct methods |
| 316 | - if(strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__') |
|
| 316 | + if (strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__') |
|
| 317 | 317 | { |
| 318 | 318 | continue; |
| 319 | 319 | } |
| 320 | 320 | // Don't export "protected" methods |
| 321 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
| 321 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
| 322 | 322 | { |
| 323 | 323 | continue; |
| 324 | 324 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | public function call($sMethod, $aArgs) |
| 370 | 370 | { |
| 371 | - if(!$this->hasMethod($sMethod)) |
|
| 371 | + if (!$this->hasMethod($sMethod)) |
|
| 372 | 372 | return; |
| 373 | 373 | $reflectionMethod = $this->reflectionClass->getMethod($sMethod); |
| 374 | 374 | $callableObject = $this->getRegisteredObject(); |
@@ -93,12 +93,13 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function __construct($xCallable) |
| 95 | 95 | { |
| 96 | - if(is_string($xCallable)) // Received a class name |
|
| 96 | + if(is_string($xCallable)) { |
|
| 97 | + // Received a class name |
|
| 97 | 98 | { |
| 98 | 99 | $this->reflectionClass = new \ReflectionClass($xCallable); |
| 99 | - $this->callableObject = null; |
|
| 100 | 100 | } |
| 101 | - else // if(is_object($xCallable)) // Received a class instance |
|
| 101 | + $this->callableObject = null; |
|
| 102 | + } else // if(is_object($xCallable)) // Received a class instance |
|
| 102 | 103 | { |
| 103 | 104 | $this->reflectionClass = new \ReflectionClass(get_class($xCallable)); |
| 104 | 105 | $this->setCallable($xCallable); |
@@ -132,8 +133,7 @@ discard block |
||
| 132 | 133 | $parameterInstances[] = $this->diGet($parameter->getClass()->getName()); |
| 133 | 134 | } |
| 134 | 135 | $xCallable = $this->reflectionClass->newInstanceArgs($parameterInstances); |
| 135 | - } |
|
| 136 | - else |
|
| 136 | + } else |
|
| 137 | 137 | { |
| 138 | 138 | $xCallable = $this->reflectionClass->newInstance(); |
| 139 | 139 | } |
@@ -260,31 +260,35 @@ discard block |
||
| 260 | 260 | // Set the namespace |
| 261 | 261 | if($sName == 'namespace') |
| 262 | 262 | { |
| 263 | - if($sValue != '') |
|
| 264 | - $this->namespace = $sValue; |
|
| 263 | + if($sValue != '') { |
|
| 264 | + $this->namespace = $sValue; |
|
| 265 | + } |
|
| 265 | 266 | return; |
| 266 | 267 | } |
| 267 | 268 | // Set the classpath |
| 268 | 269 | if($sName == 'classpath') |
| 269 | 270 | { |
| 270 | - if($sValue != '') |
|
| 271 | - $this->classpath = trim($sValue, '\\'); |
|
| 271 | + if($sValue != '') { |
|
| 272 | + $this->classpath = trim($sValue, '\\'); |
|
| 273 | + } |
|
| 272 | 274 | return; |
| 273 | 275 | } |
| 274 | 276 | // Set the separator |
| 275 | 277 | if($sName == 'separator') |
| 276 | 278 | { |
| 277 | - if($sValue == '_' || $sValue == '.') |
|
| 278 | - $this->separator = $sValue; |
|
| 279 | + if($sValue == '_' || $sValue == '.') { |
|
| 280 | + $this->separator = $sValue; |
|
| 281 | + } |
|
| 279 | 282 | return; |
| 280 | 283 | } |
| 281 | 284 | // Set the excluded methods |
| 282 | 285 | if($sName == 'protected') |
| 283 | 286 | { |
| 284 | - if(is_array($sValue)) |
|
| 285 | - $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
|
| 286 | - elseif(is_string($sValue)) |
|
| 287 | - $this->aProtectedMethods[] = $sValue; |
|
| 287 | + if(is_array($sValue)) { |
|
| 288 | + $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
|
| 289 | + } elseif(is_string($sValue)) { |
|
| 290 | + $this->aProtectedMethods[] = $sValue; |
|
| 291 | + } |
|
| 288 | 292 | return; |
| 289 | 293 | } |
| 290 | 294 | |
@@ -368,8 +372,9 @@ discard block |
||
| 368 | 372 | */ |
| 369 | 373 | public function call($sMethod, $aArgs) |
| 370 | 374 | { |
| 371 | - if(!$this->hasMethod($sMethod)) |
|
| 372 | - return; |
|
| 375 | + if(!$this->hasMethod($sMethod)) { |
|
| 376 | + return; |
|
| 377 | + } |
|
| 373 | 378 | $reflectionMethod = $this->reflectionClass->getMethod($sMethod); |
| 374 | 379 | $callableObject = $this->getRegisteredObject(); |
| 375 | 380 | $this->getResponseManager()->append($reflectionMethod->invokeArgs($callableObject, $aArgs)); |