@@ -223,13 +223,11 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | // The name of a request plugin is used as key in the plugin table |
| 225 | 225 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 226 | - } |
|
| 227 | - elseif($xPlugin instanceof Response) |
|
| 226 | + } elseif($xPlugin instanceof Response) |
|
| 228 | 227 | { |
| 229 | 228 | // The name of a response plugin is used as key in the plugin table |
| 230 | 229 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 231 | - } |
|
| 232 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 230 | + } elseif(!$bIsConfirm && !$bIsAlert) |
|
| 233 | 231 | { |
| 234 | 232 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 235 | 233 | } |
@@ -644,8 +642,7 @@ discard block |
||
| 644 | 642 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 645 | 643 | 'sUrl' => $sJsAppURI . $sOutFile, |
| 646 | 644 | )); |
| 647 | - } |
|
| 648 | - else |
|
| 645 | + } else |
|
| 649 | 646 | { |
| 650 | 647 | // The plugins scripts are wrapped with javascript tags |
| 651 | 648 | $sScript = $this->render('jaxon::plugins/wrapper.js', array( |
@@ -219,32 +219,32 @@ discard block |
||
| 219 | 219 | { |
| 220 | 220 | $bIsAlert = ($xPlugin instanceof Dialogs\Interfaces\Alert); |
| 221 | 221 | $bIsConfirm = ($xPlugin instanceof Dialogs\Interfaces\Confirm); |
| 222 | - if($xPlugin instanceof Request) |
|
| 222 | + if ($xPlugin instanceof Request) |
|
| 223 | 223 | { |
| 224 | 224 | // The name of a request plugin is used as key in the plugin table |
| 225 | 225 | $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin; |
| 226 | 226 | } |
| 227 | - elseif($xPlugin instanceof Response) |
|
| 227 | + elseif ($xPlugin instanceof Response) |
|
| 228 | 228 | { |
| 229 | 229 | // The name of a response plugin is used as key in the plugin table |
| 230 | 230 | $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin; |
| 231 | 231 | } |
| 232 | - elseif(!$bIsConfirm && !$bIsAlert) |
|
| 232 | + elseif (!$bIsConfirm && !$bIsAlert) |
|
| 233 | 233 | { |
| 234 | 234 | throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin)))); |
| 235 | 235 | } |
| 236 | 236 | // This plugin implements the Alert interface |
| 237 | - if($bIsAlert) |
|
| 237 | + if ($bIsAlert) |
|
| 238 | 238 | { |
| 239 | 239 | $this->setAlert($xPlugin); |
| 240 | 240 | } |
| 241 | 241 | // This plugin implements the Confirm interface |
| 242 | - if($bIsConfirm) |
|
| 242 | + if ($bIsConfirm) |
|
| 243 | 243 | { |
| 244 | 244 | $this->setConfirm($xPlugin); |
| 245 | 245 | } |
| 246 | 246 | // Register the plugin as an event listener |
| 247 | - if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 247 | + if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener) |
|
| 248 | 248 | { |
| 249 | 249 | $this->addEventListener($xPlugin); |
| 250 | 250 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | private function generateHash() |
| 275 | 275 | { |
| 276 | 276 | $sHash = $this->getVersion(); |
| 277 | - foreach($this->aPlugins as $xPlugin) |
|
| 277 | + foreach ($this->aPlugins as $xPlugin) |
|
| 278 | 278 | { |
| 279 | 279 | $sHash .= $xPlugin->generateHash(); |
| 280 | 280 | } |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | public function canProcessRequest() |
| 293 | 293 | { |
| 294 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 294 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 295 | 295 | { |
| 296 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 296 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 297 | 297 | { |
| 298 | 298 | return true; |
| 299 | 299 | } |
@@ -312,12 +312,12 @@ discard block |
||
| 312 | 312 | public function processRequest() |
| 313 | 313 | { |
| 314 | 314 | $xUploadPlugin = $this->getRequestPlugin(Jaxon::FILE_UPLOAD); |
| 315 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 315 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 316 | 316 | { |
| 317 | - if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 317 | + if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest()) |
|
| 318 | 318 | { |
| 319 | 319 | // Process uploaded files |
| 320 | - if($xUploadPlugin != null) |
|
| 320 | + if ($xUploadPlugin != null) |
|
| 321 | 321 | { |
| 322 | 322 | $xUploadPlugin->processRequest(); |
| 323 | 323 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function register($sType, $sCallable, $aOptions) |
| 344 | 344 | { |
| 345 | - if(!key_exists($sType, $this->aRequestPlugins)) |
|
| 345 | + if (!key_exists($sType, $this->aRequestPlugins)) |
|
| 346 | 346 | { |
| 347 | 347 | throw new \Jaxon\Exception\Error($this->trans('errors.register.plugin', ['name' => $sType])); |
| 348 | 348 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | private function getJsLibUri() |
| 368 | 368 | { |
| 369 | - if(!$this->hasOption('js.lib.uri')) |
|
| 369 | + if (!$this->hasOption('js.lib.uri')) |
|
| 370 | 370 | { |
| 371 | 371 | // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
| 372 | 372 | return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/'; |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | // The jsDelivr CDN only hosts minified files |
| 390 | 390 | // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
| 391 | 391 | // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files. |
| 392 | - if(($this->getOption('js.app.minify'))) |
|
| 392 | + if (($this->getOption('js.app.minify'))) |
|
| 393 | 393 | { |
| 394 | 394 | return '.min.js'; |
| 395 | 395 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | // Check config options |
| 407 | 407 | // - The js.app.extern option must be set to true |
| 408 | 408 | // - The js.app.uri and js.app.dir options must be set to non null values |
| 409 | - if(!$this->getOption('js.app.extern') || |
|
| 409 | + if (!$this->getOption('js.app.extern') || |
|
| 410 | 410 | !$this->getOption('js.app.uri') || |
| 411 | 411 | !$this->getOption('js.app.dir')) |
| 412 | 412 | { |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | // Check dir access |
| 416 | 416 | // - The js.app.dir must be writable |
| 417 | 417 | $sJsAppDir = $this->getOption('js.app.dir'); |
| 418 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 418 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
| 419 | 419 | { |
| 420 | 420 | return false; |
| 421 | 421 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | private function setTemplateCacheDir() |
| 431 | 431 | { |
| 432 | - if($this->hasOption('core.template.cache_dir')) |
|
| 432 | + if ($this->hasOption('core.template.cache_dir')) |
|
| 433 | 433 | { |
| 434 | 434 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
| 435 | 435 | } |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | // Add component files to the javascript file array; |
| 453 | 453 | $aJsFiles = array($sJsCoreUrl); |
| 454 | - if($this->getOption('core.debug.on')) |
|
| 454 | + if ($this->getOption('core.debug.on')) |
|
| 455 | 455 | { |
| 456 | 456 | $aJsFiles[] = $sJsDebugUrl; |
| 457 | 457 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -467,17 +467,17 @@ discard block |
||
| 467 | 467 | 'sJsOptions' => $this->getOption('js.app.options'), |
| 468 | 468 | 'aUrls' => $aJsFiles, |
| 469 | 469 | )); |
| 470 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 470 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 471 | 471 | { |
| 472 | - if(($str = trim($xPlugin->getJs()))) |
|
| 472 | + if (($str = trim($xPlugin->getJs()))) |
|
| 473 | 473 | { |
| 474 | 474 | $sCode .= rtrim($str, " \n") . "\n"; |
| 475 | 475 | } |
| 476 | 476 | } |
| 477 | - foreach($this->aPackages as $sClass) |
|
| 477 | + foreach ($this->aPackages as $sClass) |
|
| 478 | 478 | { |
| 479 | 479 | $xPackage = jaxon()->di()->get($sClass); |
| 480 | - if(($str = trim($xPackage->js()))) |
|
| 480 | + if (($str = trim($xPackage->js()))) |
|
| 481 | 481 | { |
| 482 | 482 | $sCode .= rtrim($str, " \n") . "\n"; |
| 483 | 483 | } |
@@ -496,17 +496,17 @@ discard block |
||
| 496 | 496 | $this->setTemplateCacheDir(); |
| 497 | 497 | |
| 498 | 498 | $sCode = ''; |
| 499 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 499 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 500 | 500 | { |
| 501 | - if(($str = trim($xPlugin->getCss()))) |
|
| 501 | + if (($str = trim($xPlugin->getCss()))) |
|
| 502 | 502 | { |
| 503 | 503 | $sCode .= rtrim($str, " \n") . "\n"; |
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | - foreach($this->aPackages as $sClass) |
|
| 506 | + foreach ($this->aPackages as $sClass) |
|
| 507 | 507 | { |
| 508 | 508 | $xPackage = jaxon()->di()->get($sClass); |
| 509 | - if(($str = trim($xPackage->css()))) |
|
| 509 | + if (($str = trim($xPackage->css()))) |
|
| 510 | 510 | { |
| 511 | 511 | $sCode .= rtrim($str, " \n") . "\n"; |
| 512 | 512 | } |
@@ -570,17 +570,17 @@ discard block |
||
| 570 | 570 | private function getReadyScript() |
| 571 | 571 | { |
| 572 | 572 | $sPluginScript = ''; |
| 573 | - foreach($this->aResponsePlugins as $xPlugin) |
|
| 573 | + foreach ($this->aResponsePlugins as $xPlugin) |
|
| 574 | 574 | { |
| 575 | - if(($str = trim($xPlugin->getScript()))) |
|
| 575 | + if (($str = trim($xPlugin->getScript()))) |
|
| 576 | 576 | { |
| 577 | 577 | $sPluginScript .= "\n" . trim($str, " \n"); |
| 578 | 578 | } |
| 579 | 579 | } |
| 580 | - foreach($this->aPackages as $sClass) |
|
| 580 | + foreach ($this->aPackages as $sClass) |
|
| 581 | 581 | { |
| 582 | 582 | $xPackage = jaxon()->di()->get($sClass); |
| 583 | - if(($str = trim($xPackage->ready()))) |
|
| 583 | + if (($str = trim($xPackage->ready()))) |
|
| 584 | 584 | { |
| 585 | 585 | $sPluginScript .= "\n" . trim($str, " \n"); |
| 586 | 586 | } |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | { |
| 604 | 604 | // Get the config and plugins scripts |
| 605 | 605 | $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n"; |
| 606 | - foreach($this->aRequestPlugins as $xPlugin) |
|
| 606 | + foreach ($this->aRequestPlugins as $xPlugin) |
|
| 607 | 607 | { |
| 608 | 608 | $sScript .= "\n" . trim($xPlugin->getScript(), " \n"); |
| 609 | 609 | } |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | // Set the template engine cache dir |
| 626 | 626 | $this->setTemplateCacheDir(); |
| 627 | 627 | |
| 628 | - if($this->canExportJavascript()) |
|
| 628 | + if ($this->canExportJavascript()) |
|
| 629 | 629 | { |
| 630 | 630 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
| 631 | 631 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -634,13 +634,13 @@ discard block |
||
| 634 | 634 | $sHash = $this->generateHash(); |
| 635 | 635 | $sOutFile = $sHash . '.js'; |
| 636 | 636 | $sMinFile = $sHash . '.min.js'; |
| 637 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
| 637 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
| 638 | 638 | { |
| 639 | 639 | file_put_contents($sJsAppDir . $sOutFile, $this->getAllScripts()); |
| 640 | 640 | } |
| 641 | - if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
| 641 | + if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
| 642 | 642 | { |
| 643 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 643 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
| 644 | 644 | { |
| 645 | 645 | $sOutFile = $sMinFile; |
| 646 | 646 | } |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | */ |
| 674 | 674 | public function getResponsePlugin($sName) |
| 675 | 675 | { |
| 676 | - if(array_key_exists($sName, $this->aResponsePlugins)) |
|
| 676 | + if (array_key_exists($sName, $this->aResponsePlugins)) |
|
| 677 | 677 | { |
| 678 | 678 | return $this->aResponsePlugins[$sName]; |
| 679 | 679 | } |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | */ |
| 690 | 690 | public function getRequestPlugin($sName) |
| 691 | 691 | { |
| 692 | - if(array_key_exists($sName, $this->aRequestPlugins)) |
|
| 692 | + if (array_key_exists($sName, $this->aRequestPlugins)) |
|
| 693 | 693 | { |
| 694 | 694 | return $this->aRequestPlugins[$sName]; |
| 695 | 695 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function confirm($question, $yesScript, $noScript) |
| 24 | 24 | { |
| 25 | - if(!$noScript) |
|
| 25 | + if (!$noScript) |
|
| 26 | 26 | { |
| 27 | 27 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}'; |
| 28 | 28 | } |
@@ -25,8 +25,7 @@ |
||
| 25 | 25 | if(!$noScript) |
| 26 | 26 | { |
| 27 | 27 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}'; |
| 28 | - } |
|
| 29 | - else |
|
| 28 | + } else |
|
| 30 | 29 | { |
| 31 | 30 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}else{' . $noScript . ';}'; |
| 32 | 31 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | protected function alert($message, $title) |
| 28 | 28 | { |
| 29 | - if($this->getReturn()) |
|
| 29 | + if ($this->getReturn()) |
|
| 30 | 30 | { |
| 31 | 31 | return 'alert(' . $message . ')'; |
| 32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param string|null $sClass The callable class |
| 37 | 37 | * |
| 38 | - * @return Factory |
|
| 38 | + * @return Request |
|
| 39 | 39 | */ |
| 40 | 40 | public function setClassName($sClass) |
| 41 | 41 | { |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @param CallableObject $xCallable The callable object |
| 60 | 60 | * |
| 61 | - * @return Factory |
|
| 61 | + * @return Request |
|
| 62 | 62 | */ |
| 63 | 63 | public function setCallable(CallableObject $xCallable) |
| 64 | 64 | { |
@@ -71,7 +71,6 @@ discard block |
||
| 71 | 71 | * Return the javascript call to a Jaxon function or object method |
| 72 | 72 | * |
| 73 | 73 | * @param string $sFunction The function or method (without class) name |
| 74 | - * @param ... $xParams The parameters of the function or method |
|
| 75 | 74 | * |
| 76 | 75 | * @return \Jaxon\Request\Request |
| 77 | 76 | */ |
@@ -100,7 +99,6 @@ discard block |
||
| 100 | 99 | * Return the javascript call to a generic function |
| 101 | 100 | * |
| 102 | 101 | * @param string $sFunction The function or method (with class) name |
| 103 | - * @param ... $xParams The parameters of the function or method |
|
| 104 | 102 | * |
| 105 | 103 | * @return \Jaxon\Request\Request |
| 106 | 104 | */ |
@@ -124,7 +122,6 @@ discard block |
||
| 124 | 122 | * @param integer $nItemsPerPage The number of items per page page |
| 125 | 123 | * @param integer $nCurrentPage The current page |
| 126 | 124 | * @param string $sMethod The name of function or a method prepended with its class name |
| 127 | - * @param ... $xParams The parameters of the function or method |
|
| 128 | 125 | * |
| 129 | 126 | * @return string the pagination links |
| 130 | 127 | */ |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | $this->sPrefix = $this->getOption('core.prefix.function'); |
| 62 | 62 | |
| 63 | 63 | $sClass = trim($sClass, '.\\ '); |
| 64 | - if(!$sClass) |
|
| 64 | + if (!$sClass) |
|
| 65 | 65 | { |
| 66 | 66 | return $this; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if(!($xCallable = $this->xRepository->getCallableObject($sClass))) |
|
| 69 | + if (!($xCallable = $this->xRepository->getCallableObject($sClass))) |
|
| 70 | 70 | { |
| 71 | 71 | // Todo: decide which of these values to return |
| 72 | 72 | // return null; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | array_shift($aArguments); |
| 108 | 108 | |
| 109 | 109 | // Makes legacy code works |
| 110 | - if(strpos($sFunction, '.') !== false) |
|
| 110 | + if (strpos($sFunction, '.') !== false) |
|
| 111 | 111 | { |
| 112 | 112 | // If there is a dot in the name, then it is a call to a class |
| 113 | 113 | $this->sPrefix = $this->getOption('core.prefix.class'); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | 'core.prefix.class' => 'Jaxon', |
| 43 | 43 | // 'core.request.uri' => '', |
| 44 | 44 | 'core.request.mode' => 'asynchronous', |
| 45 | - 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 45 | + 'core.request.method' => 'POST', // W3C: Method is case sensitive |
|
| 46 | 46 | 'core.response.merge.ap' => true, |
| 47 | 47 | 'core.response.merge.js' => true, |
| 48 | 48 | '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); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | /** |
| 256 | 256 | * Create a new the config manager |
| 257 | 257 | * |
| 258 | - * @return Jaxon\Utils\Config\Config The config manager |
|
| 258 | + * @return \Jaxon\Utils\Config\Config The config manager |
|
| 259 | 259 | */ |
| 260 | 260 | public function newConfig() |
| 261 | 261 | { |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | /** |
| 348 | 348 | * Create a new Jaxon response object |
| 349 | 349 | * |
| 350 | - * @return Jaxon\Response\Response |
|
| 350 | + * @return \Jaxon\Response\Response |
|
| 351 | 351 | */ |
| 352 | 352 | public function newResponse() |
| 353 | 353 | { |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | |
| 17 | 17 | use Lemon\Event\EventDispatcher; |
| 18 | 18 | use Jaxon\Sentry\View\Renderer; |
| 19 | - |
|
| 20 | 19 | use Jaxon\Request\Support\CallableRepository; |
| 21 | 20 | |
| 22 | 21 | class Container |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public static function getInstance() |
| 34 | 34 | { |
| 35 | - if(!self::$xInstance) |
|
| 35 | + if (!self::$xInstance) |
|
| 36 | 36 | { |
| 37 | 37 | self::$xInstance = new Container(); |
| 38 | 38 | } |
@@ -92,27 +92,27 @@ discard block |
||
| 92 | 92 | * Managers |
| 93 | 93 | */ |
| 94 | 94 | // Callable objects repository |
| 95 | - $this->coreContainer[CallableRepository::class] = function ($c) { |
|
| 95 | + $this->coreContainer[CallableRepository::class] = function($c) { |
|
| 96 | 96 | return new CallableRepository(); |
| 97 | 97 | }; |
| 98 | 98 | // Plugin Manager |
| 99 | - $this->coreContainer['jaxon.core.plugin_manager'] = function ($c) { |
|
| 99 | + $this->coreContainer['jaxon.core.plugin_manager'] = function($c) { |
|
| 100 | 100 | return new \Jaxon\Plugin\Manager(); |
| 101 | 101 | }; |
| 102 | 102 | // Request Manager |
| 103 | - $this->coreContainer['jaxon.core.request_manager'] = function ($c) { |
|
| 103 | + $this->coreContainer['jaxon.core.request_manager'] = function($c) { |
|
| 104 | 104 | return new \Jaxon\Request\Manager(); |
| 105 | 105 | }; |
| 106 | 106 | // Request Factory |
| 107 | - $this->coreContainer['jaxon.core.request_factory'] = function ($c) { |
|
| 107 | + $this->coreContainer['jaxon.core.request_factory'] = function($c) { |
|
| 108 | 108 | return new \Jaxon\Factory\Request($c[CallableRepository::class]); |
| 109 | 109 | }; |
| 110 | 110 | // Parameter Factory |
| 111 | - $this->coreContainer['jaxon.core.parameter_factory'] = function ($c) { |
|
| 111 | + $this->coreContainer['jaxon.core.parameter_factory'] = function($c) { |
|
| 112 | 112 | return new \Jaxon\Factory\Parameter(); |
| 113 | 113 | }; |
| 114 | 114 | // Response Manager |
| 115 | - $this->coreContainer['jaxon.core.response_manager'] = function ($c) { |
|
| 115 | + $this->coreContainer['jaxon.core.response_manager'] = function($c) { |
|
| 116 | 116 | return new \Jaxon\Response\Manager(); |
| 117 | 117 | }; |
| 118 | 118 | |
@@ -120,35 +120,35 @@ discard block |
||
| 120 | 120 | * Services |
| 121 | 121 | */ |
| 122 | 122 | // Config manager |
| 123 | - $this->coreContainer['jaxon.core.config'] = function ($c) { |
|
| 123 | + $this->coreContainer['jaxon.core.config'] = function($c) { |
|
| 124 | 124 | return new \Jaxon\Utils\Config\Config(); |
| 125 | 125 | }; |
| 126 | 126 | // Minifier |
| 127 | - $this->coreContainer['jaxon.core.minifier'] = function ($c) { |
|
| 127 | + $this->coreContainer['jaxon.core.minifier'] = function($c) { |
|
| 128 | 128 | return new \Jaxon\Utils\Template\Minifier(); |
| 129 | 129 | }; |
| 130 | 130 | // Translator |
| 131 | - $this->coreContainer['jaxon.core.translator'] = function ($c) { |
|
| 131 | + $this->coreContainer['jaxon.core.translator'] = function($c) { |
|
| 132 | 132 | return new \Jaxon\Utils\Translation\Translator($c['jaxon.core.translation_dir'], $c['jaxon.core.config']); |
| 133 | 133 | }; |
| 134 | 134 | // Template engine |
| 135 | - $this->coreContainer['jaxon.core.template'] = function ($c) { |
|
| 135 | + $this->coreContainer['jaxon.core.template'] = function($c) { |
|
| 136 | 136 | return new \Jaxon\Utils\Template\Template($c['jaxon.core.template_dir']); |
| 137 | 137 | }; |
| 138 | 138 | // Validator |
| 139 | - $this->coreContainer['jaxon.core.validator'] = function ($c) { |
|
| 139 | + $this->coreContainer['jaxon.core.validator'] = function($c) { |
|
| 140 | 140 | return new \Jaxon\Utils\Validation\Validator($c['jaxon.core.translator'], $c['jaxon.core.config']); |
| 141 | 141 | }; |
| 142 | 142 | // Pagination Renderer |
| 143 | - $this->coreContainer['jaxon.pagination.renderer'] = function ($c) { |
|
| 143 | + $this->coreContainer['jaxon.pagination.renderer'] = function($c) { |
|
| 144 | 144 | return new \Jaxon\Utils\Pagination\Renderer($c['jaxon.core.template']); |
| 145 | 145 | }; |
| 146 | 146 | // Pagination Paginator |
| 147 | - $this->coreContainer['jaxon.pagination.paginator'] = function ($c) { |
|
| 147 | + $this->coreContainer['jaxon.pagination.paginator'] = function($c) { |
|
| 148 | 148 | return new \Jaxon\Utils\Pagination\Paginator($c['jaxon.pagination.renderer']); |
| 149 | 149 | }; |
| 150 | 150 | // Event Dispatcher |
| 151 | - $this->coreContainer['jaxon.core.events'] = function ($c) { |
|
| 151 | + $this->coreContainer['jaxon.core.events'] = function($c) { |
|
| 152 | 152 | return new EventDispatcher(); |
| 153 | 153 | }; |
| 154 | 154 | |
@@ -156,15 +156,15 @@ discard block |
||
| 156 | 156 | * Core library objects |
| 157 | 157 | */ |
| 158 | 158 | // Global Response |
| 159 | - $this->coreContainer['jaxon.core.response'] = function ($c) { |
|
| 159 | + $this->coreContainer['jaxon.core.response'] = function($c) { |
|
| 160 | 160 | return new \Jaxon\Response\Response(); |
| 161 | 161 | }; |
| 162 | 162 | // Jaxon Core |
| 163 | - $this->coreContainer['jaxon.core.jaxon'] = function ($c) { |
|
| 163 | + $this->coreContainer['jaxon.core.jaxon'] = function($c) { |
|
| 164 | 164 | return new \Jaxon\Jaxon(); |
| 165 | 165 | }; |
| 166 | 166 | // View Renderer Facade |
| 167 | - $this->coreContainer['jaxon.sentry.view.renderer'] = function ($c) { |
|
| 167 | + $this->coreContainer['jaxon.sentry.view.renderer'] = function($c) { |
|
| 168 | 168 | $aRenderers = $c['jaxon.view.data.renderers']; |
| 169 | 169 | $sDefaultNamespace = $c['jaxon.view.data.namespace.default']; |
| 170 | 170 | return new \Jaxon\Sentry\View\Facade($aRenderers, $sDefaultNamespace); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function get($sClass) |
| 180 | 180 | { |
| 181 | - if($this->sentryContainer != null && $this->sentryContainer->has($sClass)) |
|
| 181 | + if ($this->sentryContainer != null && $this->sentryContainer->has($sClass)) |
|
| 182 | 182 | { |
| 183 | 183 | return $this->sentryContainer->get($sClass); |
| 184 | 184 | } |
@@ -463,14 +463,14 @@ discard block |
||
| 463 | 463 | $this->coreContainer['jaxon.sentry.view.base.' . $sId] = $xClosure; |
| 464 | 464 | |
| 465 | 465 | // Return the initialized view renderer |
| 466 | - $this->coreContainer['jaxon.sentry.view.' . $sId] = function ($c) use ($sId) { |
|
| 466 | + $this->coreContainer['jaxon.sentry.view.' . $sId] = function($c) use ($sId) { |
|
| 467 | 467 | // Get the defined renderer |
| 468 | 468 | $renderer = $c['jaxon.sentry.view.base.' . $sId]; |
| 469 | 469 | // Init the renderer with the template namespaces |
| 470 | 470 | $aNamespaces = $this->coreContainer['jaxon.view.data.namespaces']; |
| 471 | - if(key_exists($sId, $aNamespaces)) |
|
| 471 | + if (key_exists($sId, $aNamespaces)) |
|
| 472 | 472 | { |
| 473 | - foreach($aNamespaces[$sId] as $ns) |
|
| 473 | + foreach ($aNamespaces[$sId] as $ns) |
|
| 474 | 474 | { |
| 475 | 475 | $renderer->addNamespace($ns['namespace'], $ns['directory'], $ns['extension']); |
| 476 | 476 | } |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | public function getViewRenderer($sId = '') |
| 490 | 490 | { |
| 491 | - if(!$sId) |
|
| 491 | + if (!$sId) |
|
| 492 | 492 | { |
| 493 | 493 | // Return the view renderer facade |
| 494 | 494 | return $this->coreContainer['jaxon.sentry.view.renderer']; |
@@ -134,8 +134,7 @@ discard block |
||
| 134 | 134 | if(is_array($sValue)) |
| 135 | 135 | { |
| 136 | 136 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
| 137 | - } |
|
| 138 | - elseif(is_string($sValue)) |
|
| 137 | + } elseif(is_string($sValue)) |
|
| 139 | 138 | { |
| 140 | 139 | $this->aProtectedMethods[] = $sValue; |
| 141 | 140 | } |
@@ -192,8 +191,7 @@ discard block |
||
| 192 | 191 | $parameterInstances[] = $di->get($parameter->getClass()->getName()); |
| 193 | 192 | } |
| 194 | 193 | $this->registeredObject = $this->reflectionClass->newInstanceArgs($parameterInstances); |
| 195 | - } |
|
| 196 | - else |
|
| 194 | + } else |
|
| 197 | 195 | { |
| 198 | 196 | $this->registeredObject = $this->reflectionClass->newInstance(); |
| 199 | 197 | } |
@@ -120,22 +120,22 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function configure($sName, $sValue) |
| 122 | 122 | { |
| 123 | - switch($sName) |
|
| 123 | + switch ($sName) |
|
| 124 | 124 | { |
| 125 | 125 | // Set the separator |
| 126 | 126 | case 'separator': |
| 127 | - if($sValue == '_' || $sValue == '.') |
|
| 127 | + if ($sValue == '_' || $sValue == '.') |
|
| 128 | 128 | { |
| 129 | 129 | $this->separator = $sValue; |
| 130 | 130 | } |
| 131 | 131 | break; |
| 132 | 132 | // Set the protected methods |
| 133 | 133 | case 'protected': |
| 134 | - if(is_array($sValue)) |
|
| 134 | + if (is_array($sValue)) |
|
| 135 | 135 | { |
| 136 | 136 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue); |
| 137 | 137 | } |
| 138 | - elseif(is_string($sValue)) |
|
| 138 | + elseif (is_string($sValue)) |
|
| 139 | 139 | { |
| 140 | 140 | $this->aProtectedMethods[] = $sValue; |
| 141 | 141 | } |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | public function getMethods() |
| 154 | 154 | { |
| 155 | 155 | $aMethods = []; |
| 156 | - foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 156 | + foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 157 | 157 | { |
| 158 | 158 | $sMethodName = $xMethod->getShortName(); |
| 159 | 159 | // Don't take magic __call, __construct, __destruct methods |
| 160 | - if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 160 | + if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__') |
|
| 161 | 161 | { |
| 162 | 162 | continue; |
| 163 | 163 | } |
| 164 | 164 | // Don't take excluded methods |
| 165 | - if(in_array($sMethodName, $this->aProtectedMethods)) |
|
| 165 | + if (in_array($sMethodName, $this->aProtectedMethods)) |
|
| 166 | 166 | { |
| 167 | 167 | continue; |
| 168 | 168 | } |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function getRegisteredObject() |
| 180 | 180 | { |
| 181 | - if($this->registeredObject == null) |
|
| 181 | + if ($this->registeredObject == null) |
|
| 182 | 182 | { |
| 183 | 183 | $di = jaxon()->di(); |
| 184 | 184 | // Use the Reflection class to get the parameters of the constructor |
| 185 | - if(($constructor = $this->reflectionClass->getConstructor()) != null) |
|
| 185 | + if (($constructor = $this->reflectionClass->getConstructor()) != null) |
|
| 186 | 186 | { |
| 187 | 187 | $parameters = $constructor->getParameters(); |
| 188 | 188 | $parameterInstances = []; |
| 189 | - foreach($parameters as $parameter) |
|
| 189 | + foreach ($parameters as $parameter) |
|
| 190 | 190 | { |
| 191 | 191 | // Get the parameter instance from the DI |
| 192 | 192 | $parameterInstances[] = $di->get($parameter->getClass()->getName()); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function call($sMethod, $aArgs) |
| 225 | 225 | { |
| 226 | - if(!$this->hasMethod($sMethod)) |
|
| 226 | + if (!$this->hasMethod($sMethod)) |
|
| 227 | 227 | { |
| 228 | 228 | return; |
| 229 | 229 | } |
@@ -243,8 +243,7 @@ |
||
| 243 | 243 | if($sName == 'separator' || $sName == 'protected') |
| 244 | 244 | { |
| 245 | 245 | $xCallableObject->configure($sName, $xValue); |
| 246 | - } |
|
| 247 | - elseif(is_array($xValue) && $sName != 'include') |
|
| 246 | + } elseif(is_array($xValue) && $sName != 'include') |
|
| 248 | 247 | { |
| 249 | 248 | // These options are to be included in javascript code. |
| 250 | 249 | $this->aCallableOptions[$sClassName][$sName] = $xValue; |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | private function getClassOptions($sClassName, array $aDirectoryOptions, array $aDefaultOptions = []) |
| 89 | 89 | { |
| 90 | 90 | $aOptions = $aDefaultOptions; |
| 91 | - if(key_exists('separator', $aDirectoryOptions)) |
|
| 91 | + if (key_exists('separator', $aDirectoryOptions)) |
|
| 92 | 92 | { |
| 93 | 93 | $aOptions['separator'] = $aDirectoryOptions['separator']; |
| 94 | 94 | } |
| 95 | - if(key_exists('protected', $aDirectoryOptions)) |
|
| 95 | + if (key_exists('protected', $aDirectoryOptions)) |
|
| 96 | 96 | { |
| 97 | 97 | $aOptions['protected'] = $aDirectoryOptions['protected']; |
| 98 | 98 | } |
| 99 | - if(key_exists('*', $aDirectoryOptions)) |
|
| 99 | + if (key_exists('*', $aDirectoryOptions)) |
|
| 100 | 100 | { |
| 101 | 101 | $aOptions = array_merge($aOptions, $aDirectoryOptions['*']); |
| 102 | 102 | } |
| 103 | - if(key_exists($sClassName, $aDirectoryOptions)) |
|
| 103 | + if (key_exists($sClassName, $aDirectoryOptions)) |
|
| 104 | 104 | { |
| 105 | 105 | $aOptions = array_merge($aOptions, $aDirectoryOptions[$sClassName]); |
| 106 | 106 | } |
@@ -120,17 +120,17 @@ discard block |
||
| 120 | 120 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 121 | 121 | $itFile = new RecursiveIteratorIterator($itDir); |
| 122 | 122 | // Iterate on dir content |
| 123 | - foreach($itFile as $xFile) |
|
| 123 | + foreach ($itFile as $xFile) |
|
| 124 | 124 | { |
| 125 | 125 | // skip everything except PHP files |
| 126 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 126 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 127 | 127 | { |
| 128 | 128 | continue; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $aClassOptions = []; |
| 132 | 132 | // No more classmap autoloading. The file will be included when needed. |
| 133 | - if(($aOptions['autoload'])) |
|
| 133 | + if (($aOptions['autoload'])) |
|
| 134 | 134 | { |
| 135 | 135 | $aClassOptions['include'] = $xFile->getPathname(); |
| 136 | 136 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | private function getOptionsFromClass($sClassName) |
| 164 | 164 | { |
| 165 | - if(!key_exists($sClassName, $this->aClassOptions)) |
|
| 165 | + if (!key_exists($sClassName, $this->aClassOptions)) |
|
| 166 | 166 | { |
| 167 | 167 | return null; // Class not registered |
| 168 | 168 | } |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | // Find the corresponding namespace |
| 182 | 182 | $sNamespace = null; |
| 183 | - foreach(array_keys($this->aNamespaceOptions) as $_sNamespace) |
|
| 183 | + foreach (array_keys($this->aNamespaceOptions) as $_sNamespace) |
|
| 184 | 184 | { |
| 185 | - if(substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\') |
|
| 185 | + if (substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\') |
|
| 186 | 186 | { |
| 187 | 187 | $sNamespace = $_sNamespace; |
| 188 | 188 | break; |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | - if($sNamespace == null) |
|
| 191 | + if ($sNamespace == null) |
|
| 192 | 192 | { |
| 193 | 193 | return null; // Class not registered |
| 194 | 194 | } |
@@ -210,27 +210,27 @@ discard block |
||
| 210 | 210 | // at the beginning and the end of the class name. |
| 211 | 211 | $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\'); |
| 212 | 212 | |
| 213 | - if(key_exists($sClassName, $this->aCallableObjects)) |
|
| 213 | + if (key_exists($sClassName, $this->aCallableObjects)) |
|
| 214 | 214 | { |
| 215 | 215 | return $this->aCallableObjects[$sClassName]; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $aOptions = $this->getOptionsFromClass($sClassName); |
| 219 | - if($aOptions === null) |
|
| 219 | + if ($aOptions === null) |
|
| 220 | 220 | { |
| 221 | 221 | $aOptions = $this->getOptionsFromNamespace($sClassName); |
| 222 | 222 | } |
| 223 | - if($aOptions === null) |
|
| 223 | + if ($aOptions === null) |
|
| 224 | 224 | { |
| 225 | 225 | return null; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // Make sure the registered class exists |
| 229 | - if(key_exists('include', $aOptions)) |
|
| 229 | + if (key_exists('include', $aOptions)) |
|
| 230 | 230 | { |
| 231 | 231 | require_once($aOptions['include']); |
| 232 | 232 | } |
| 233 | - if(!class_exists('\\' . $sClassName)) |
|
| 233 | + if (!class_exists('\\' . $sClassName)) |
|
| 234 | 234 | { |
| 235 | 235 | return null; |
| 236 | 236 | } |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | // Create the callable object |
| 239 | 239 | $xCallableObject = new \Jaxon\Request\Support\CallableObject($sClassName); |
| 240 | 240 | $this->aCallableOptions[$sClassName] = []; |
| 241 | - foreach($aOptions as $sName => $xValue) |
|
| 241 | + foreach ($aOptions as $sName => $xValue) |
|
| 242 | 242 | { |
| 243 | - if($sName == 'separator' || $sName == 'protected') |
|
| 243 | + if ($sName == 'separator' || $sName == 'protected') |
|
| 244 | 244 | { |
| 245 | 245 | $xCallableObject->configure($sName, $xValue); |
| 246 | 246 | } |
| 247 | - elseif(is_array($xValue) && $sName != 'include') |
|
| 247 | + elseif (is_array($xValue) && $sName != 'include') |
|
| 248 | 248 | { |
| 249 | 249 | // These options are to be included in javascript code. |
| 250 | 250 | $this->aCallableOptions[$sClassName][$sName] = $xValue; |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | $this->aCallableObjects[$sClassName] = $xCallableObject; |
| 254 | 254 | |
| 255 | 255 | // Register the request factory for this callable object |
| 256 | - jaxon()->di()->set($sClassName . '_Factory_Rq', function () use ($sClassName) { |
|
| 256 | + jaxon()->di()->set($sClassName . '_Factory_Rq', function() use ($sClassName) { |
|
| 257 | 257 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 258 | 258 | return new \Jaxon\Factory\Request\Portable($xCallableObject); |
| 259 | 259 | }); |
| 260 | 260 | // Register the paginator factory for this callable object |
| 261 | - jaxon()->di()->set($sClassName . '_Factory_Pg', function () use ($sClassName) { |
|
| 261 | + jaxon()->di()->set($sClassName . '_Factory_Pg', function() use ($sClassName) { |
|
| 262 | 262 | $xCallableObject = $this->aCallableObjects[$sClassName]; |
| 263 | 263 | return new \Jaxon\Factory\Request\Paginator($xCallableObject); |
| 264 | 264 | }); |
@@ -274,16 +274,16 @@ discard block |
||
| 274 | 274 | private function createCallableObjects() |
| 275 | 275 | { |
| 276 | 276 | // Create callable objects for registered classes |
| 277 | - foreach(array_keys($this->aClassOptions) as $sClassName) |
|
| 277 | + foreach (array_keys($this->aClassOptions) as $sClassName) |
|
| 278 | 278 | { |
| 279 | 279 | $this->getCallableObject($sClassName); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // Create callable objects for registered namespaces |
| 283 | 283 | $sDS = DIRECTORY_SEPARATOR; |
| 284 | - foreach($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
| 284 | + foreach ($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
| 285 | 285 | { |
| 286 | - if(key_exists($sNamespace, $this->aNamespaces)) |
|
| 286 | + if (key_exists($sNamespace, $this->aNamespaces)) |
|
| 287 | 287 | { |
| 288 | 288 | continue; |
| 289 | 289 | } |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | $sDirectory = $aOptions['directory']; |
| 295 | 295 | $itDir = new RecursiveDirectoryIterator($sDirectory); |
| 296 | 296 | $itFile = new RecursiveIteratorIterator($itDir); |
| 297 | - foreach($itFile as $xFile) |
|
| 297 | + foreach ($itFile as $xFile) |
|
| 298 | 298 | { |
| 299 | 299 | // skip everything except PHP files |
| 300 | - if(!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 300 | + if (!$xFile->isFile() || $xFile->getExtension() != 'php') |
|
| 301 | 301 | { |
| 302 | 302 | continue; |
| 303 | 303 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $sClassPath = $sNamespace; |
| 307 | 307 | $sRelativePath = substr($xFile->getPath(), strlen($sDirectory)); |
| 308 | 308 | $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\'); |
| 309 | - if($sRelativePath != '') |
|
| 309 | + if ($sRelativePath != '') |
|
| 310 | 310 | { |
| 311 | 311 | $sClassPath .= '\\' . $sRelativePath; |
| 312 | 312 | } |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | $this->createCallableObjects(); |
| 343 | 343 | |
| 344 | 344 | $sHash = ''; |
| 345 | - foreach($this->aNamespaces as $sNamespace => $aOptions) |
|
| 345 | + foreach ($this->aNamespaces as $sNamespace => $aOptions) |
|
| 346 | 346 | { |
| 347 | 347 | $sHash .= $sNamespace . $aOptions['separator']; |
| 348 | 348 | } |
| 349 | - foreach($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 349 | + foreach ($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 350 | 350 | { |
| 351 | 351 | $sHash .= $sClassName . implode('|', $xCallableObject->getMethods()); |
| 352 | 352 | } |
@@ -367,16 +367,16 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | $aJsClasses = []; |
| 369 | 369 | $sCode = ''; |
| 370 | - foreach(array_keys($this->aNamespaces) as $sNamespace) |
|
| 370 | + foreach (array_keys($this->aNamespaces) as $sNamespace) |
|
| 371 | 371 | { |
| 372 | 372 | $offset = 0; |
| 373 | 373 | $sJsNamespace = str_replace('\\', '.', $sNamespace); |
| 374 | 374 | $sJsNamespace .= '.Null'; // This is a sentinel. The last token is not processed in the while loop. |
| 375 | - while(($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
| 375 | + while (($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
| 376 | 376 | { |
| 377 | 377 | $sJsClass = substr($sJsNamespace, 0, $dotPosition); |
| 378 | 378 | // Generate code for this object |
| 379 | - if(!key_exists($sJsClass, $aJsClasses)) |
|
| 379 | + if (!key_exists($sJsClass, $aJsClasses)) |
|
| 380 | 380 | { |
| 381 | 381 | $sCode .= "$sPrefix$sJsClass = {};\n"; |
| 382 | 382 | $aJsClasses[$sJsClass] = $sJsClass; |
@@ -385,13 +385,13 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - foreach($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 388 | + foreach ($this->aCallableObjects as $sClassName => $xCallableObject) |
|
| 389 | 389 | { |
| 390 | 390 | $aConfig = $this->aCallableOptions[$sClassName]; |
| 391 | 391 | $aCommonConfig = key_exists('*', $aConfig) ? $aConfig['*'] : []; |
| 392 | 392 | |
| 393 | 393 | $aMethods = []; |
| 394 | - foreach($xCallableObject->getMethods() as $sMethodName) |
|
| 394 | + foreach ($xCallableObject->getMethods() as $sMethodName) |
|
| 395 | 395 | { |
| 396 | 396 | // Specific options for this method |
| 397 | 397 | $aMethodConfig = key_exists($sMethodName, $aConfig) ? |
@@ -164,7 +164,7 @@ |
||
| 164 | 164 | } |
| 165 | 165 | else |
| 166 | 166 | { |
| 167 | - // Use underscore as separator, so there's no need to deal with namespace |
|
| 167 | + // Use underscore as separator, so there's no need to deal with namespace |
|
| 168 | 168 | // when generating javascript code. |
| 169 | 169 | $aOptions['separator'] = '_'; |
| 170 | 170 | $aOptions['autoload'] = $this->bAutoloadEnabled; |
@@ -105,33 +105,33 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function register($sType, $sDirectory, $aOptions) |
| 107 | 107 | { |
| 108 | - if($sType != $this->getName()) |
|
| 108 | + if ($sType != $this->getName()) |
|
| 109 | 109 | { |
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if(!is_string($sDirectory) || !is_dir($sDirectory)) |
|
| 113 | + if (!is_string($sDirectory) || !is_dir($sDirectory)) |
|
| 114 | 114 | { |
| 115 | 115 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 116 | 116 | } |
| 117 | - if(is_string($aOptions)) |
|
| 117 | + if (is_string($aOptions)) |
|
| 118 | 118 | { |
| 119 | 119 | $aOptions = ['namespace' => $aOptions]; |
| 120 | 120 | } |
| 121 | - if(!is_array($aOptions)) |
|
| 121 | + if (!is_array($aOptions)) |
|
| 122 | 122 | { |
| 123 | 123 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $sDirectory = rtrim(trim($sDirectory), DIRECTORY_SEPARATOR); |
| 127 | - if(!is_dir($sDirectory)) |
|
| 127 | + if (!is_dir($sDirectory)) |
|
| 128 | 128 | { |
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | $aOptions['directory'] = $sDirectory; |
| 132 | 132 | |
| 133 | 133 | $sNamespace = key_exists('namespace', $aOptions) ? $aOptions['namespace'] : ''; |
| 134 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 134 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
| 135 | 135 | { |
| 136 | 136 | $sNamespace = ''; |
| 137 | 137 | } |
@@ -145,17 +145,17 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | // Change the keys in $aOptions to have "\" as separator |
| 147 | 147 | $_aOptions = []; |
| 148 | - foreach($aOptions as $sName => $aOption) |
|
| 148 | + foreach ($aOptions as $sName => $aOption) |
|
| 149 | 149 | { |
| 150 | 150 | $sName = trim(str_replace('.', '\\', $sName), ' \\'); |
| 151 | 151 | $_aOptions[$sName] = $aOption; |
| 152 | 152 | } |
| 153 | 153 | $aOptions = $_aOptions; |
| 154 | 154 | |
| 155 | - if(($sNamespace)) |
|
| 155 | + if (($sNamespace)) |
|
| 156 | 156 | { |
| 157 | 157 | // Register the dir with PSR4 autoloading |
| 158 | - if(($this->xAutoloader)) |
|
| 158 | + if (($this->xAutoloader)) |
|
| 159 | 159 | { |
| 160 | 160 | $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory); |
| 161 | 161 | } |
@@ -161,8 +161,7 @@ |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $this->xRepository->addNamespace($sNamespace, $aOptions); |
| 164 | - } |
|
| 165 | - else |
|
| 164 | + } else |
|
| 166 | 165 | { |
| 167 | 166 | // Use underscore as separator, so there's no need to deal with namespace |
| 168 | 167 | // when generating javascript code. |