@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function getRegisteredObject() |
| 104 | 104 | { |
| 105 | - if($this->registeredObject == null) |
|
| 105 | + if ($this->registeredObject == null) |
|
| 106 | 106 | { |
| 107 | 107 | $di = jaxon()->di(); |
| 108 | 108 | // Use the Reflection class to get the parameters of the constructor |
| 109 | - if(($constructor = $this->reflectionClass->getConstructor()) != null) |
|
| 109 | + if (($constructor = $this->reflectionClass->getConstructor()) != null) |
|
| 110 | 110 | { |
| 111 | 111 | $parameters = $constructor->getParameters(); |
| 112 | 112 | $parameterInstances = []; |
| 113 | - foreach($parameters as $parameter) |
|
| 113 | + foreach ($parameters as $parameter) |
|
| 114 | 114 | { |
| 115 | 115 | // Get the parameter instance from the DI |
| 116 | 116 | $parameterInstances[] = $di->get($parameter->getClass()->getName()); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | // The class name without the namespace. |
| 147 | 147 | $name = $this->reflectionClass->getShortName(); |
| 148 | 148 | // Append the classpath to the name |
| 149 | - if(($this->classpath)) |
|
| 149 | + if (($this->classpath)) |
|
| 150 | 150 | { |
| 151 | 151 | $name = $this->classpath . '\\' . $name; |
| 152 | 152 | } |
@@ -193,16 +193,16 @@ discard block |
||
| 193 | 193 | public function getMethods() |
| 194 | 194 | { |
| 195 | 195 | $aReturn = []; |
| 196 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 196 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 197 | 197 | { |
| 198 | 198 | $sMethodName = $xMethod->getShortName(); |
| 199 | 199 | // Don't take magic __call, __construct, __destruct methods |
| 200 | - if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 200 | + if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 201 | 201 | { |
| 202 | 202 | continue; |
| 203 | 203 | } |
| 204 | 204 | // Don't take excluded methods |
| 205 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
| 205 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
| 206 | 206 | { |
| 207 | 207 | continue; |
| 208 | 208 | } |
@@ -223,37 +223,37 @@ discard block |
||
| 223 | 223 | public function configure($sMethod, $sName, $sValue) |
| 224 | 224 | { |
| 225 | 225 | // Set the namespace |
| 226 | - if($sName == 'namespace') |
|
| 226 | + if ($sName == 'namespace') |
|
| 227 | 227 | { |
| 228 | - if($sValue != '') |
|
| 228 | + if ($sValue != '') |
|
| 229 | 229 | $this->namespace = $sValue; |
| 230 | 230 | return; |
| 231 | 231 | } |
| 232 | 232 | // Set the classpath |
| 233 | - if($sName == 'classpath') |
|
| 233 | + if ($sName == 'classpath') |
|
| 234 | 234 | { |
| 235 | - if($sValue != '') |
|
| 235 | + if ($sValue != '') |
|
| 236 | 236 | $this->classpath = trim($sValue, '\\'); |
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | // Set the separator |
| 240 | - if($sName == 'separator') |
|
| 240 | + if ($sName == 'separator') |
|
| 241 | 241 | { |
| 242 | - if($sValue == '_' || $sValue == '.') |
|
| 242 | + if ($sValue == '_' || $sValue == '.') |
|
| 243 | 243 | $this->separator = $sValue; |
| 244 | 244 | return; |
| 245 | 245 | } |
| 246 | 246 | // Set the excluded methods |
| 247 | - if($sName == 'protected') |
|
| 247 | + if ($sName == 'protected') |
|
| 248 | 248 | { |
| 249 | - if(is_array($sValue)) |
|
| 249 | + if (is_array($sValue)) |
|
| 250 | 250 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
| 251 | - elseif(is_string($sValue)) |
|
| 251 | + elseif (is_string($sValue)) |
|
| 252 | 252 | $this->aProtectedMethods[] = $sValue; |
| 253 | 253 | return; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if(!isset($this->aConfiguration[$sMethod])) |
|
| 256 | + if (!isset($this->aConfiguration[$sMethod])) |
|
| 257 | 257 | { |
| 258 | 258 | $this->aConfiguration[$sMethod] = []; |
| 259 | 259 | } |
@@ -274,16 +274,16 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | // Common options to be set on all methods |
| 276 | 276 | $aCommonConfig = array_key_exists('*', $this->aConfiguration) ? $this->aConfiguration['*'] : []; |
| 277 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 277 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 278 | 278 | { |
| 279 | 279 | $sMethodName = $xMethod->getShortName(); |
| 280 | 280 | // Don't export magic __call, __construct, __destruct methods |
| 281 | - if(strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__') |
|
| 281 | + if (strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__') |
|
| 282 | 282 | { |
| 283 | 283 | continue; |
| 284 | 284 | } |
| 285 | 285 | // Don't export "protected" methods |
| 286 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
| 286 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
| 287 | 287 | { |
| 288 | 288 | continue; |
| 289 | 289 | } |
@@ -333,14 +333,14 @@ discard block |
||
| 333 | 333 | */ |
| 334 | 334 | public function call($sMethod, $aArgs) |
| 335 | 335 | { |
| 336 | - if(!$this->hasMethod($sMethod)) |
|
| 336 | + if (!$this->hasMethod($sMethod)) |
|
| 337 | 337 | { |
| 338 | 338 | return; |
| 339 | 339 | } |
| 340 | 340 | $reflectionMethod = $this->reflectionClass->getMethod($sMethod); |
| 341 | 341 | $registeredObject = $this->getRegisteredObject(); |
| 342 | 342 | $response = $reflectionMethod->invokeArgs($registeredObject, $aArgs); |
| 343 | - if(($response)) |
|
| 343 | + if (($response)) |
|
| 344 | 344 | { |
| 345 | 345 | $this->getResponseManager()->append($response); |
| 346 | 346 | } |
@@ -116,8 +116,7 @@ discard block |
||
| 116 | 116 | $parameterInstances[] = $di->get($parameter->getClass()->getName()); |
| 117 | 117 | } |
| 118 | 118 | $this->registeredObject = $this->reflectionClass->newInstanceArgs($parameterInstances); |
| 119 | - } |
|
| 120 | - else |
|
| 119 | + } else |
|
| 121 | 120 | { |
| 122 | 121 | $this->registeredObject = $this->reflectionClass->newInstance(); |
| 123 | 122 | } |
@@ -225,31 +224,35 @@ discard block |
||
| 225 | 224 | // Set the namespace |
| 226 | 225 | if($sName == 'namespace') |
| 227 | 226 | { |
| 228 | - if($sValue != '') |
|
| 229 | - $this->namespace = $sValue; |
|
| 227 | + if($sValue != '') { |
|
| 228 | + $this->namespace = $sValue; |
|
| 229 | + } |
|
| 230 | 230 | return; |
| 231 | 231 | } |
| 232 | 232 | // Set the classpath |
| 233 | 233 | if($sName == 'classpath') |
| 234 | 234 | { |
| 235 | - if($sValue != '') |
|
| 236 | - $this->classpath = trim($sValue, '\\'); |
|
| 235 | + if($sValue != '') { |
|
| 236 | + $this->classpath = trim($sValue, '\\'); |
|
| 237 | + } |
|
| 237 | 238 | return; |
| 238 | 239 | } |
| 239 | 240 | // Set the separator |
| 240 | 241 | if($sName == 'separator') |
| 241 | 242 | { |
| 242 | - if($sValue == '_' || $sValue == '.') |
|
| 243 | - $this->separator = $sValue; |
|
| 243 | + if($sValue == '_' || $sValue == '.') { |
|
| 244 | + $this->separator = $sValue; |
|
| 245 | + } |
|
| 244 | 246 | return; |
| 245 | 247 | } |
| 246 | 248 | // Set the excluded methods |
| 247 | 249 | if($sName == 'protected') |
| 248 | 250 | { |
| 249 | - if(is_array($sValue)) |
|
| 250 | - $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
|
| 251 | - elseif(is_string($sValue)) |
|
| 252 | - $this->aProtectedMethods[] = $sValue; |
|
| 251 | + if(is_array($sValue)) { |
|
| 252 | + $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
|
| 253 | + } elseif(is_string($sValue)) { |
|
| 254 | + $this->aProtectedMethods[] = $sValue; |
|
| 255 | + } |
|
| 253 | 256 | return; |
| 254 | 257 | } |
| 255 | 258 | |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | public function __construct() |
| 84 | 84 | { |
| 85 | - if(!empty($_GET['jxncls'])) |
|
| 85 | + if (!empty($_GET['jxncls'])) |
|
| 86 | 86 | { |
| 87 | 87 | $this->sRequestedClass = $_GET['jxncls']; |
| 88 | 88 | } |
| 89 | - if(!empty($_GET['jxnmthd'])) |
|
| 89 | + if (!empty($_GET['jxnmthd'])) |
|
| 90 | 90 | { |
| 91 | 91 | $this->sRequestedMethod = $_GET['jxnmthd']; |
| 92 | 92 | } |
| 93 | - if(!empty($_POST['jxncls'])) |
|
| 93 | + if (!empty($_POST['jxncls'])) |
|
| 94 | 94 | { |
| 95 | 95 | $this->sRequestedClass = $_POST['jxncls']; |
| 96 | 96 | } |
| 97 | - if(!empty($_POST['jxnmthd'])) |
|
| 97 | + if (!empty($_POST['jxnmthd'])) |
|
| 98 | 98 | { |
| 99 | 99 | $this->sRequestedMethod = $_POST['jxnmthd']; |
| 100 | 100 | } |
@@ -145,34 +145,34 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function register($sType, $sDirectory, $aOptions) |
| 147 | 147 | { |
| 148 | - if($sType != $this->getName()) |
|
| 148 | + if ($sType != $this->getName()) |
|
| 149 | 149 | { |
| 150 | 150 | return false; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if(!is_string($sDirectory) || !is_dir($sDirectory)) |
|
| 153 | + if (!is_string($sDirectory) || !is_dir($sDirectory)) |
|
| 154 | 154 | { |
| 155 | 155 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 156 | 156 | } |
| 157 | 157 | $sDirectory = trim($sDirectory, DIRECTORY_SEPARATOR); |
| 158 | 158 | |
| 159 | - if(is_string($aOptions)) |
|
| 159 | + if (is_string($aOptions)) |
|
| 160 | 160 | { |
| 161 | 161 | $aOptions = ['namespace' => $aOptions]; |
| 162 | 162 | } |
| 163 | - if(!is_array($aOptions)) |
|
| 163 | + if (!is_array($aOptions)) |
|
| 164 | 164 | { |
| 165 | 165 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if(!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 168 | + if (!is_dir(($sDirectory = trim($sDirectory)))) |
|
| 169 | 169 | { |
| 170 | 170 | return false; |
| 171 | 171 | } |
| 172 | 172 | $aOptions['directory'] = $sDirectory; |
| 173 | 173 | |
| 174 | 174 | $aProtected = key_exists('protected', $aOptions) ? $aOptions['protected'] : []; |
| 175 | - if(!is_array($aProtected)) |
|
| 175 | + if (!is_array($aProtected)) |
|
| 176 | 176 | { |
| 177 | 177 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 178 | 178 | } |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $sSeparator = key_exists('separator', $aOptions) ? $aOptions['separator'] : '.'; |
| 182 | 182 | // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead. |
| 183 | - if(($sSeparator = trim($sSeparator)) != '_') |
|
| 183 | + if (($sSeparator = trim($sSeparator)) != '_') |
|
| 184 | 184 | { |
| 185 | 185 | $sSeparator = '.'; |
| 186 | 186 | } |
| 187 | 187 | $aOptions['separator'] = $sSeparator; |
| 188 | 188 | |
| 189 | 189 | $sNamespace = key_exists('namespace', $aOptions) ? $aOptions['namespace'] : ''; |
| 190 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 190 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 191 | 191 | { |
| 192 | 192 | $sNamespace = ''; |
| 193 | 193 | } |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | // } |
| 203 | 203 | // $aOptions['classes'] = $aNewOptions; |
| 204 | 204 | |
| 205 | - if(($sNamespace)) |
|
| 205 | + if (($sNamespace)) |
|
| 206 | 206 | { |
| 207 | 207 | // Register the dir with PSR4 autoloading |
| 208 | - if(($this->xAutoloader)) |
|
| 208 | + if (($this->xAutoloader)) |
|
| 209 | 209 | { |
| 210 | 210 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 211 | 211 | } |
@@ -221,20 +221,20 @@ discard block |
||
| 221 | 221 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 222 | 222 | $itFile = new RecursiveIteratorIterator($itDir); |
| 223 | 223 | // Iterate on dir content |
| 224 | - foreach($itFile as $xFile) |
|
| 224 | + foreach ($itFile as $xFile) |
|
| 225 | 225 | { |
| 226 | 226 | // skip everything except PHP files |
| 227 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 227 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 228 | 228 | { |
| 229 | 229 | continue; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | $sClassName = $xFile->getBasename('.php'); |
| 233 | - if(($this->xAutoloader)) |
|
| 233 | + if (($this->xAutoloader)) |
|
| 234 | 234 | { |
| 235 | 235 | $this->xAutoloader->addClassMap([$sClassName => $xFile->getPathname()]); |
| 236 | 236 | } |
| 237 | - elseif(!class_exists($sClassName)) |
|
| 237 | + elseif (!class_exists($sClassName)) |
|
| 238 | 238 | { |
| 239 | 239 | $aOptions['include'] = $xFile->getPathname(); |
| 240 | 240 | } |
@@ -260,27 +260,27 @@ discard block |
||
| 260 | 260 | $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\'); |
| 261 | 261 | |
| 262 | 262 | // Make sure the registered class exists |
| 263 | - if(!class_exists('\\' . $sClassName)) |
|
| 263 | + if (!class_exists('\\' . $sClassName)) |
|
| 264 | 264 | { |
| 265 | 265 | return null; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if(key_exists($sClassName, $this->aCallableObjects)) |
|
| 268 | + if (key_exists($sClassName, $this->aCallableObjects)) |
|
| 269 | 269 | { |
| 270 | 270 | return $this->aCallableObjects[$sClassName]; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // Find the corresponding namespace |
| 274 | 274 | $sNamespace = null; |
| 275 | - foreach(array_keys($this->aNamespaces) as $_sNamespace) |
|
| 275 | + foreach (array_keys($this->aNamespaces) as $_sNamespace) |
|
| 276 | 276 | { |
| 277 | - if(substr($sClassName, 0, strlen($_sNamespace)) == $_sNamespace) |
|
| 277 | + if (substr($sClassName, 0, strlen($_sNamespace)) == $_sNamespace) |
|
| 278 | 278 | { |
| 279 | 279 | $sNamespace = $_sNamespace; |
| 280 | 280 | break; |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | - if($sNamespace == null) |
|
| 283 | + if ($sNamespace == null) |
|
| 284 | 284 | { |
| 285 | 285 | return null; // Class not registered |
| 286 | 286 | } |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | // Create the callable object |
| 289 | 289 | $xCallableObject = new \Jaxon\Request\Support\CallableObject($sClassName); |
| 290 | 290 | $aOptions = $this->aNamespaces[$sNamespace]; |
| 291 | - foreach($aOptions as $sMethod => $aValue) |
|
| 291 | + foreach ($aOptions as $sMethod => $aValue) |
|
| 292 | 292 | { |
| 293 | - foreach($aValue as $sName => $sValue) |
|
| 293 | + foreach ($aValue as $sName => $sValue) |
|
| 294 | 294 | { |
| 295 | 295 | $xCallableObject->configure($sMethod, $sName, $sValue); |
| 296 | 296 | } |
@@ -298,12 +298,12 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | $this->aCallableObjects[$sClassName] = $xCallableObject; |
| 300 | 300 | // Register the request factory for this callable object |
| 301 | - jaxon()->di()->set($sClassName . '\Factory\Rq', function ($di) use ($sClassName) { |
|
| 301 | + jaxon()->di()->set($sClassName . '\Factory\Rq', function($di) use ($sClassName) { |
|
| 302 | 302 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 303 | 303 | return new \Jaxon\Factory\Request\Portable($xCallableObject); |
| 304 | 304 | }); |
| 305 | 305 | // Register the paginator factory for this callable object |
| 306 | - jaxon()->di()->set($sClassName . '\Factory\Pg', function ($di) use ($sClassName) { |
|
| 306 | + jaxon()->di()->set($sClassName . '\Factory\Pg', function($di) use ($sClassName) { |
|
| 307 | 307 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 308 | 308 | return new \Jaxon\Factory\Request\Paginator($xCallableObject); |
| 309 | 309 | }); |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | { |
| 335 | 335 | $sDS = DIRECTORY_SEPARATOR; |
| 336 | 336 | |
| 337 | - foreach($this->aNamespaces as $sNamespace => $aOptions) |
|
| 337 | + foreach ($this->aNamespaces as $sNamespace => $aOptions) |
|
| 338 | 338 | { |
| 339 | - if(key_exists($sNamespace, $this->aClassNames)) |
|
| 339 | + if (key_exists($sNamespace, $this->aClassNames)) |
|
| 340 | 340 | { |
| 341 | 341 | continue; |
| 342 | 342 | } |
@@ -347,10 +347,10 @@ discard block |
||
| 347 | 347 | $sDirectory = $aOptions['directory']; |
| 348 | 348 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 349 | 349 | $itFile = new RecursiveIteratorIterator($itDir); |
| 350 | - foreach($itFile as $xFile) |
|
| 350 | + foreach ($itFile as $xFile) |
|
| 351 | 351 | { |
| 352 | 352 | // skip everything except PHP files |
| 353 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 353 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 354 | 354 | { |
| 355 | 355 | continue; |
| 356 | 356 | } |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | $sClassPath = $sNamespace; |
| 360 | 360 | $sRelativePath = substr($xFile->getPath(), strlen($sDirectory)); |
| 361 | 361 | $sRelativePath = trim(str_replace($sDS, '\\', $sClassPath), '\\'); |
| 362 | - if(($sRelativePath)) |
|
| 362 | + if (($sRelativePath)) |
|
| 363 | 363 | { |
| 364 | 364 | $sClassPath .= '\\' . $sRelativePath; |
| 365 | 365 | } |
| 366 | - if(!key_exists($sClassPath, $this->aClassNames)) |
|
| 366 | + if (!key_exists($sClassPath, $this->aClassNames)) |
|
| 367 | 367 | { |
| 368 | 368 | $this->aClassNames[$sClassPath] = []; |
| 369 | 369 | } |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | public function generateHash() |
| 384 | 384 | { |
| 385 | - if(count($this->aNamespaces) == 0) |
|
| 385 | + if (count($this->aNamespaces) == 0) |
|
| 386 | 386 | { |
| 387 | 387 | return ''; |
| 388 | 388 | } |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | $this->createCallableObjects(); |
| 391 | 391 | |
| 392 | 392 | $sHash = ''; |
| 393 | - foreach($this->aNamespaces as $sNamespace => $aOptions) |
|
| 393 | + foreach ($this->aNamespaces as $sNamespace => $aOptions) |
|
| 394 | 394 | { |
| 395 | 395 | $sHash .= $sNamespace . $aOptions['directory'] . $aOptions['separator']; |
| 396 | 396 | } |
| 397 | - foreach($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 397 | + foreach ($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 398 | 398 | { |
| 399 | 399 | $sHash .= $sClassName . implode('|', $xCallableObject->getMethods()); |
| 400 | 400 | } |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | $sJaxonPrefix = $this->getOption('core.prefix.class'); |
| 416 | 416 | $aJsClasses = []; |
| 417 | 417 | $sCode = ''; |
| 418 | - foreach(array_keys($this->aClassNames) as $sNamespace) |
|
| 418 | + foreach (array_keys($this->aClassNames) as $sNamespace) |
|
| 419 | 419 | { |
| 420 | 420 | // if(key_exists('separator', $aOptions) && $aOptions['separator'] != '.') |
| 421 | 421 | // { |
@@ -424,11 +424,11 @@ discard block |
||
| 424 | 424 | $offset = 0; |
| 425 | 425 | $sJsClasses = str_replace('\\', '.', $sNamespace); |
| 426 | 426 | $sJsClasses .= '.Null'; // This is a sentinel. The last token is not processed in the while loop. |
| 427 | - while(($dotPosition = strpos($sJsClasses, '.', $offset)) !== false) |
|
| 427 | + while (($dotPosition = strpos($sJsClasses, '.', $offset)) !== false) |
|
| 428 | 428 | { |
| 429 | 429 | $sJsClass = substr($sJsClasses, 0, $dotPosition); |
| 430 | 430 | // Generate code for this object |
| 431 | - if(!key_exists($sJsClass, $aJsClasses)) |
|
| 431 | + if (!key_exists($sJsClass, $aJsClasses)) |
|
| 432 | 432 | { |
| 433 | 433 | $sCode .= "$sJaxonPrefix$sJsClass = {};\n"; |
| 434 | 434 | $aJsClasses[$sJsClass] = $sJsClass; |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | $offset = $dotPosition + 1; |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | - foreach($this->aCallableObjects as $xCallableObject) |
|
| 439 | + foreach ($this->aCallableObjects as $xCallableObject) |
|
| 440 | 440 | { |
| 441 | 441 | $sCode .= $xCallableObject->getScript(); |
| 442 | 442 | } |
@@ -452,13 +452,13 @@ discard block |
||
| 452 | 452 | public function canProcessRequest() |
| 453 | 453 | { |
| 454 | 454 | // Check the validity of the class name |
| 455 | - if(($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass)) |
|
| 455 | + if (($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass)) |
|
| 456 | 456 | { |
| 457 | 457 | $this->sRequestedClass = null; |
| 458 | 458 | $this->sRequestedMethod = null; |
| 459 | 459 | } |
| 460 | 460 | // Check the validity of the method name |
| 461 | - if(($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod)) |
|
| 461 | + if (($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod)) |
|
| 462 | 462 | { |
| 463 | 463 | $this->sRequestedClass = null; |
| 464 | 464 | $this->sRequestedMethod = null; |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | public function processRequest() |
| 475 | 475 | { |
| 476 | - if(!$this->canProcessRequest()) |
|
| 476 | + if (!$this->canProcessRequest()) |
|
| 477 | 477 | { |
| 478 | 478 | return false; |
| 479 | 479 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | // Find the requested method |
| 484 | 484 | $xCallableObject = $this->getCallableObject($this->sRequestedClass); |
| 485 | - if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 485 | + if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 486 | 486 | { |
| 487 | 487 | // Unable to find the requested object or method |
| 488 | 488 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid', |
@@ -211,8 +211,7 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | $this->aNamespaces[$sNamespace] = $aOptions; |
| 214 | - } |
|
| 215 | - else |
|
| 214 | + } else |
|
| 216 | 215 | { |
| 217 | 216 | // Get the callable class plugin |
| 218 | 217 | $callableClassPlugin = $this->getPluginManager()->getRequestPlugin(Jaxon::CALLABLE_CLASS); |
@@ -233,8 +232,7 @@ discard block |
||
| 233 | 232 | if(($this->xAutoloader)) |
| 234 | 233 | { |
| 235 | 234 | $this->xAutoloader->addClassMap([$sClassName => $xFile->getPathname()]); |
| 236 | - } |
|
| 237 | - elseif(!class_exists($sClassName)) |
|
| 235 | + } elseif(!class_exists($sClassName)) |
|
| 238 | 236 | { |
| 239 | 237 | $aOptions['include'] = $xFile->getPathname(); |
| 240 | 238 | } |
@@ -61,19 +61,19 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | public function __construct() |
| 63 | 63 | { |
| 64 | - if(!empty($_GET['jxncls'])) |
|
| 64 | + if (!empty($_GET['jxncls'])) |
|
| 65 | 65 | { |
| 66 | 66 | $this->sRequestedClass = $_GET['jxncls']; |
| 67 | 67 | } |
| 68 | - if(!empty($_GET['jxnmthd'])) |
|
| 68 | + if (!empty($_GET['jxnmthd'])) |
|
| 69 | 69 | { |
| 70 | 70 | $this->sRequestedMethod = $_GET['jxnmthd']; |
| 71 | 71 | } |
| 72 | - if(!empty($_POST['jxncls'])) |
|
| 72 | + if (!empty($_POST['jxncls'])) |
|
| 73 | 73 | { |
| 74 | 74 | $this->sRequestedClass = $_POST['jxncls']; |
| 75 | 75 | } |
| 76 | - if(!empty($_POST['jxnmthd'])) |
|
| 76 | + if (!empty($_POST['jxnmthd'])) |
|
| 77 | 77 | { |
| 78 | 78 | $this->sRequestedMethod = $_POST['jxnmthd']; |
| 79 | 79 | } |
@@ -100,16 +100,16 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function register($sType, $sClassName, $aOptions) |
| 102 | 102 | { |
| 103 | - if($sType != $this->getName()) |
|
| 103 | + if ($sType != $this->getName()) |
|
| 104 | 104 | { |
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if(!is_string($sClassName)) |
|
| 108 | + if (!is_string($sClassName)) |
|
| 109 | 109 | { |
| 110 | 110 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 111 | 111 | } |
| 112 | - if(!is_array($aOptions)) |
|
| 112 | + if (!is_array($aOptions)) |
|
| 113 | 113 | { |
| 114 | 114 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 115 | 115 | } |
@@ -133,21 +133,21 @@ discard block |
||
| 133 | 133 | // at the beginning and the end of the class name. |
| 134 | 134 | $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\'); |
| 135 | 135 | |
| 136 | - if(!key_exists($sClassName, $this->aClassOptions)) |
|
| 136 | + if (!key_exists($sClassName, $this->aClassOptions)) |
|
| 137 | 137 | { |
| 138 | 138 | return null; // Class not registered |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if(key_exists($sClassName, $this->aCallableObjects)) |
|
| 141 | + if (key_exists($sClassName, $this->aCallableObjects)) |
|
| 142 | 142 | { |
| 143 | 143 | return $this->aCallableObjects[$sClassName]; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Create the callable object |
| 147 | 147 | $xCallableObject = new \Jaxon\Request\Support\CallableObject($sClassName); |
| 148 | - foreach($aOptions as $sMethod => $aValue) |
|
| 148 | + foreach ($aOptions as $sMethod => $aValue) |
|
| 149 | 149 | { |
| 150 | - foreach($aValue as $sName => $sValue) |
|
| 150 | + foreach ($aValue as $sName => $sValue) |
|
| 151 | 151 | { |
| 152 | 152 | $xCallableObject->configure($sMethod, $sName, $sValue); |
| 153 | 153 | } |
@@ -156,19 +156,19 @@ discard block |
||
| 156 | 156 | // Make sure the registered class exists |
| 157 | 157 | // We need to check this after the callable object is configured |
| 158 | 158 | // to take the 'include' option into account. |
| 159 | - if(!class_exists($sClassName)) |
|
| 159 | + if (!class_exists($sClassName)) |
|
| 160 | 160 | { |
| 161 | 161 | return null; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $this->aCallableObjects[$sClassName] = $xCallableObject; |
| 165 | 165 | // Register the request factory for this callable object |
| 166 | - jaxon()->di()->set($sClassName . '\Factory\Rq', function ($di) use ($sClassName) { |
|
| 166 | + jaxon()->di()->set($sClassName . '\Factory\Rq', function($di) use ($sClassName) { |
|
| 167 | 167 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 168 | 168 | return new \Jaxon\Factory\Request\Portable($xCallableObject); |
| 169 | 169 | }); |
| 170 | 170 | // Register the paginator factory for this callable object |
| 171 | - jaxon()->di()->set($sClassName . '\Factory\Pg', function ($di) use ($sClassName) { |
|
| 171 | + jaxon()->di()->set($sClassName . '\Factory\Pg', function($di) use ($sClassName) { |
|
| 172 | 172 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 173 | 173 | return new \Jaxon\Factory\Request\Paginator($xCallableObject); |
| 174 | 174 | }); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | private function createCallableObjects() |
| 199 | 199 | { |
| 200 | - foreach(array_keys($this->aClassOptions) as $sClassName) |
|
| 200 | + foreach (array_keys($this->aClassOptions) as $sClassName) |
|
| 201 | 201 | { |
| 202 | 202 | $this->getCallableObject($sClassName); |
| 203 | 203 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $this->createCallableObjects(); |
| 214 | 214 | |
| 215 | 215 | $sHash = ''; |
| 216 | - foreach($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 216 | + foreach ($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 217 | 217 | { |
| 218 | 218 | $sHash .= $sClassName . implode('|', $xCallableObject->getMethods()); |
| 219 | 219 | } |
@@ -234,19 +234,19 @@ discard block |
||
| 234 | 234 | $sJaxonPrefix = $this->getOption('core.prefix.class'); |
| 235 | 235 | $aJsClasses = []; |
| 236 | 236 | $sCode = ''; |
| 237 | - foreach($this->aClassOptions as $sClassName => $aOptions) |
|
| 237 | + foreach ($this->aClassOptions as $sClassName => $aOptions) |
|
| 238 | 238 | { |
| 239 | - if(key_exists('separator', $aOptions) && $aOptions['separator'] != '.') |
|
| 239 | + if (key_exists('separator', $aOptions) && $aOptions['separator'] != '.') |
|
| 240 | 240 | { |
| 241 | 241 | continue; |
| 242 | 242 | } |
| 243 | 243 | $offset = 0; |
| 244 | 244 | $sJsClasses = str_replace('\\', '.', $sClassName); |
| 245 | - while(($dotPosition = strpos($sJsClasses, '.', $offset)) !== false) |
|
| 245 | + while (($dotPosition = strpos($sJsClasses, '.', $offset)) !== false) |
|
| 246 | 246 | { |
| 247 | 247 | $sJsClass = substr($sJsClasses, 0, $dotPosition); |
| 248 | 248 | // Generate code for this object |
| 249 | - if(!key_exists($sJsClass, $aJsClasses)) |
|
| 249 | + if (!key_exists($sJsClass, $aJsClasses)) |
|
| 250 | 250 | { |
| 251 | 251 | $sCode .= "$sJaxonPrefix$sJsClass = {};\n"; |
| 252 | 252 | $aJsClasses[$sJsClass] = $sJsClass; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $offset = $dotPosition + 1; |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | - foreach($this->aCallableObjects as $xCallableObject) |
|
| 257 | + foreach ($this->aCallableObjects as $xCallableObject) |
|
| 258 | 258 | { |
| 259 | 259 | $sCode .= $xCallableObject->getScript(); |
| 260 | 260 | } |
@@ -270,13 +270,13 @@ discard block |
||
| 270 | 270 | public function canProcessRequest() |
| 271 | 271 | { |
| 272 | 272 | // Check the validity of the class name |
| 273 | - if(($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass)) |
|
| 273 | + if (($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass)) |
|
| 274 | 274 | { |
| 275 | 275 | $this->sRequestedClass = null; |
| 276 | 276 | $this->sRequestedMethod = null; |
| 277 | 277 | } |
| 278 | 278 | // Check the validity of the method name |
| 279 | - if(($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod)) |
|
| 279 | + if (($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod)) |
|
| 280 | 280 | { |
| 281 | 281 | $this->sRequestedClass = null; |
| 282 | 282 | $this->sRequestedMethod = null; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | public function processRequest() |
| 294 | 294 | { |
| 295 | - if(!$this->canProcessRequest()) |
|
| 295 | + if (!$this->canProcessRequest()) |
|
| 296 | 296 | { |
| 297 | 297 | return false; |
| 298 | 298 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | // Find the requested method |
| 303 | 303 | $xCallableObject = $this->getCallableObject($this->sRequestedClass); |
| 304 | - if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 304 | + if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
| 305 | 305 | { |
| 306 | 306 | // Unable to find the requested object or method |
| 307 | 307 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid', |