@@ -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; |
@@ -142,16 +142,6 @@ |
||
| 142 | 142 | * - Jaxon::CALLABLE_OBJECT: an object who's methods are to be registered |
| 143 | 143 | * - Jaxon::BROWSER_EVENT: an event which will cause zero or more event handlers to be called |
| 144 | 144 | * - Jaxon::EVENT_HANDLER: register an event handler function. |
| 145 | - * @param mixed $sFunction | $objObject | $sEvent |
|
| 146 | - * When registering a function, this is the name of the function |
|
| 147 | - * When registering a callable object, this is the object being registered |
|
| 148 | - * When registering an event or event handler, this is the name of the event |
|
| 149 | - * @param mixed $sIncludeFile | $aCallOptions | $sEventHandler |
|
| 150 | - * When registering a function, this is the (optional) include file |
|
| 151 | - * When registering a callable object, this is an (optional) array |
|
| 152 | - * of call options for the functions being registered |
|
| 153 | - * When registering an event handler, this is the name of the function |
|
| 154 | - * |
|
| 155 | 145 | * @return mixed |
| 156 | 146 | */ |
| 157 | 147 | public function register($sType, $xArgs) |
@@ -25,14 +25,9 @@ |
||
| 25 | 25 | |
| 26 | 26 | namespace Jaxon; |
| 27 | 27 | |
| 28 | -use Jaxon\Plugin\Manager as PluginManager; |
|
| 29 | -use Jaxon\Request\Manager as RequestManager; |
|
| 30 | -use Jaxon\Response\Manager as ResponseManager; |
|
| 31 | - |
|
| 32 | -use Jaxon\Utils\URI; |
|
| 33 | -use Jaxon\Utils\Container; |
|
| 28 | +use Jaxon\Utils\URI; |
|
| 29 | +use Jaxon\Utils\Container; |
|
| 34 | 30 | use Exception; |
| 35 | -use Closure; |
|
| 36 | 31 | |
| 37 | 32 | class Jaxon |
| 38 | 33 | {
|
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | $aArgs = func_get_args(); |
| 160 | 160 | $nArgs = func_num_args(); |
| 161 | 161 | |
| 162 | - if(self::PROCESSING_EVENT == $sType) |
|
| 162 | + if (self::PROCESSING_EVENT == $sType) |
|
| 163 | 163 | {
|
| 164 | - if($nArgs > 2) |
|
| 164 | + if ($nArgs > 2) |
|
| 165 | 165 | {
|
| 166 | 166 | $sEvent = $xArgs; |
| 167 | 167 | $xUserFunction = $aArgs[2]; |
| 168 | - if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 168 | + if (!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 169 | 169 | $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
| 170 | 170 | $this->aProcessingEvents[$sEvent] = $xUserFunction; |
| 171 | 171 | } |
@@ -237,16 +237,16 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function getScript($bIncludeJs = false, $bIncludeCss = false) |
| 239 | 239 | {
|
| 240 | - if(!$this->getOption('core.request.uri'))
|
|
| 240 | + if (!$this->getOption('core.request.uri'))
|
|
| 241 | 241 | {
|
| 242 | 242 | $this->setOption('core.request.uri', URI::detect());
|
| 243 | 243 | } |
| 244 | 244 | $sCode = ''; |
| 245 | - if(($bIncludeCss)) |
|
| 245 | + if (($bIncludeCss)) |
|
| 246 | 246 | {
|
| 247 | 247 | $sCode .= $this->getPluginManager()->getCss() . "\n"; |
| 248 | 248 | } |
| 249 | - if(($bIncludeJs)) |
|
| 249 | + if (($bIncludeJs)) |
|
| 250 | 250 | {
|
| 251 | 251 | $sCode .= $this->getPluginManager()->getJs() . "\n"; |
| 252 | 252 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | public function processRequest() |
| 318 | 318 | {
|
| 319 | 319 | // Check to see if headers have already been sent out, in which case we can't do our job |
| 320 | - if(headers_sent($filename, $linenumber)) |
|
| 320 | + if (headers_sent($filename, $linenumber)) |
|
| 321 | 321 | {
|
| 322 | 322 | echo $this->trans('errors.output.already-sent', array(
|
| 323 | 323 | 'location' => $filename . ':' . $linenumber |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | // Check if there is a plugin to process this request |
| 329 | - if(!$this->canProcessRequest()) |
|
| 329 | + if (!$this->canProcessRequest()) |
|
| 330 | 330 | {
|
| 331 | 331 | return; |
| 332 | 332 | } |
@@ -335,18 +335,18 @@ discard block |
||
| 335 | 335 | $mResult = true; |
| 336 | 336 | |
| 337 | 337 | // Handle before processing event |
| 338 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 338 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE])) |
|
| 339 | 339 | {
|
| 340 | 340 | $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest)); |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if(!$bEndRequest) |
|
| 343 | + if (!$bEndRequest) |
|
| 344 | 344 | {
|
| 345 | 345 | try |
| 346 | 346 | {
|
| 347 | 347 | $mResult = $this->getPluginManager()->processRequest(); |
| 348 | 348 | } |
| 349 | - catch(Exception $e) |
|
| 349 | + catch (Exception $e) |
|
| 350 | 350 | {
|
| 351 | 351 | // An exception was thrown while processing the request. |
| 352 | 352 | // The request missed the corresponding handler function, |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $xResponseManager->debug($e->getMessage()); |
| 360 | 360 | $mResult = false; |
| 361 | 361 | |
| 362 | - if($e instanceof \Jaxon\Exception\Error) |
|
| 362 | + if ($e instanceof \Jaxon\Exception\Error) |
|
| 363 | 363 | {
|
| 364 | 364 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 365 | 365 | $aParams = array($e->getMessage()); |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | $aParams = array($e); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if(isset($this->aProcessingEvents[$sEvent])) |
|
| 373 | + if (isset($this->aProcessingEvents[$sEvent])) |
|
| 374 | 374 | {
|
| 375 | 375 | // Call the processing event |
| 376 | 376 | $this->aProcessingEvents[$sEvent]->call($aParams); |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | // Clean the processing buffer |
| 386 | - if(($this->getOption('core.process.clean')))
|
|
| 386 | + if (($this->getOption('core.process.clean')))
|
|
| 387 | 387 | {
|
| 388 | 388 | $er = error_reporting(0); |
| 389 | 389 | while (ob_get_level() > 0) |
@@ -393,10 +393,10 @@ discard block |
||
| 393 | 393 | error_reporting($er); |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - if($mResult === true) |
|
| 396 | + if ($mResult === true) |
|
| 397 | 397 | {
|
| 398 | 398 | // Handle after processing event |
| 399 | - if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 399 | + if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER])) |
|
| 400 | 400 | {
|
| 401 | 401 | $bEndRequest = false; |
| 402 | 402 | $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest)); |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | |
| 406 | 406 | $this->getResponseManager()->printDebug(); |
| 407 | 407 | |
| 408 | - if(($this->getOption('core.process.exit')))
|
|
| 408 | + if (($this->getOption('core.process.exit')))
|
|
| 409 | 409 | {
|
| 410 | 410 | $this->getResponseManager()->sendOutput(); |
| 411 | 411 | exit(); |
@@ -165,8 +165,9 @@ discard block |
||
| 165 | 165 | {
|
| 166 | 166 | $sEvent = $xArgs; |
| 167 | 167 | $xUserFunction = $aArgs[2]; |
| 168 | - if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) |
|
| 169 | - $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
|
| 168 | + if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) { |
|
| 169 | + $xUserFunction = new Request\Support\UserFunction($xUserFunction); |
|
| 170 | + } |
|
| 170 | 171 | $this->aProcessingEvents[$sEvent] = $xUserFunction; |
| 171 | 172 | } |
| 172 | 173 | /*else |
@@ -345,8 +346,7 @@ discard block |
||
| 345 | 346 | try |
| 346 | 347 | {
|
| 347 | 348 | $mResult = $this->getPluginManager()->processRequest(); |
| 348 | - } |
|
| 349 | - catch(Exception $e) |
|
| 349 | + } catch(Exception $e) |
|
| 350 | 350 | {
|
| 351 | 351 | // An exception was thrown while processing the request. |
| 352 | 352 | // The request missed the corresponding handler function, |
@@ -363,8 +363,7 @@ discard block |
||
| 363 | 363 | {
|
| 364 | 364 | $sEvent = self::PROCESSING_EVENT_INVALID; |
| 365 | 365 | $aParams = array($e->getMessage()); |
| 366 | - } |
|
| 367 | - else |
|
| 366 | + } else |
|
| 368 | 367 | {
|
| 369 | 368 | $sEvent = self::PROCESSING_EVENT_ERROR; |
| 370 | 369 | $aParams = array($e); |
@@ -374,8 +373,7 @@ discard block |
||
| 374 | 373 | {
|
| 375 | 374 | // Call the processing event |
| 376 | 375 | $this->aProcessingEvents[$sEvent]->call($aParams); |
| 377 | - } |
|
| 378 | - else |
|
| 376 | + } else |
|
| 379 | 377 | {
|
| 380 | 378 | // The exception is not to be processed here. |
| 381 | 379 | throw $e; |
@@ -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 | {
|
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | |
| 20 | 20 | namespace Jaxon\Traits; |
| 21 | 21 | |
| 22 | -use Jaxon\Utils\Config\Php; |
|
| 23 | -use Jaxon\Utils\Config\Yaml; |
|
| 22 | +use Jaxon\Utils\Config\Php; |
|
| 23 | +use Jaxon\Utils\Config\Yaml; |
|
| 24 | 24 | use Jaxon\Utils\Config\Json; |
| 25 | 25 | |
| 26 | 26 | trait Config |
@@ -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.debug.on' => false, |
| 48 | 48 | 'core.debug.verbose' => false, |
| 49 | 49 | 'core.process.exit' => true, |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | public function readConfigFile($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 117 | 117 | {
|
| 118 | 118 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
| 119 | - switch($sExt) |
|
| 119 | + switch ($sExt) |
|
| 120 | 120 | {
|
| 121 | 121 | case 'php': |
| 122 | 122 | return $this->readPhpConfigFile($sConfigFile, $sLibKey, $sAppKey); |
@@ -212,7 +212,7 @@ |
||
| 212 | 212 | /** |
| 213 | 213 | * Create a new the config manager |
| 214 | 214 | * |
| 215 | - * @return Jaxon\Utils\Config\Config The config manager |
|
| 215 | + * @return Config\Config The config manager |
|
| 216 | 216 | */ |
| 217 | 217 | public function newConfig() |
| 218 | 218 | {
|
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | namespace Jaxon\Utils; |
| 16 | 16 | |
| 17 | -use Lemon\Event\EventDispatcher; |
|
| 17 | +use Lemon\Event\EventDispatcher; |
|
| 18 | 18 | use Jaxon\Sentry\View\Renderer; |
| 19 | 19 | |
| 20 | 20 | class Container |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public static function getInstance() |
| 29 | 29 | {
|
| 30 | - if(!self::$xInstance) |
|
| 30 | + if (!self::$xInstance) |
|
| 31 | 31 | {
|
| 32 | 32 | self::$xInstance = new Container(); |
| 33 | 33 | } |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | * Managers |
| 66 | 66 | */ |
| 67 | 67 | // Plugin Manager |
| 68 | - $this->di['plugin_manager'] = function ($c) {
|
|
| 68 | + $this->di['plugin_manager'] = function($c) {
|
|
| 69 | 69 | return new \Jaxon\Plugin\Manager(); |
| 70 | 70 | }; |
| 71 | 71 | // Request Manager |
| 72 | - $this->di['request_manager'] = function ($c) {
|
|
| 72 | + $this->di['request_manager'] = function($c) {
|
|
| 73 | 73 | return new \Jaxon\Request\Manager(); |
| 74 | 74 | }; |
| 75 | 75 | // Request Factory |
| 76 | - $this->di['request_factory'] = function ($c) {
|
|
| 76 | + $this->di['request_factory'] = function($c) {
|
|
| 77 | 77 | return new \Jaxon\Request\Factory(); |
| 78 | 78 | }; |
| 79 | 79 | // Response Manager |
| 80 | - $this->di['response_manager'] = function ($c) {
|
|
| 80 | + $this->di['response_manager'] = function($c) {
|
|
| 81 | 81 | return new \Jaxon\Response\Manager(); |
| 82 | 82 | }; |
| 83 | 83 | |
@@ -85,35 +85,35 @@ discard block |
||
| 85 | 85 | * Services |
| 86 | 86 | */ |
| 87 | 87 | // Config manager |
| 88 | - $this->di['config'] = function ($c) {
|
|
| 88 | + $this->di['config'] = function($c) {
|
|
| 89 | 89 | return new Config\Config(); |
| 90 | 90 | }; |
| 91 | 91 | // Minifier |
| 92 | - $this->di['minifier'] = function ($c) {
|
|
| 92 | + $this->di['minifier'] = function($c) {
|
|
| 93 | 93 | return new Template\Minifier(); |
| 94 | 94 | }; |
| 95 | 95 | // Translator |
| 96 | - $this->di['translator'] = function ($c) {
|
|
| 96 | + $this->di['translator'] = function($c) {
|
|
| 97 | 97 | return new Translation\Translator($c['translation_dir'], $c['config']); |
| 98 | 98 | }; |
| 99 | 99 | // Template engine |
| 100 | - $this->di['template'] = function ($c) {
|
|
| 100 | + $this->di['template'] = function($c) {
|
|
| 101 | 101 | return new Template\Template($c['template_dir']); |
| 102 | 102 | }; |
| 103 | 103 | // Validator |
| 104 | - $this->di['validator'] = function ($c) {
|
|
| 104 | + $this->di['validator'] = function($c) {
|
|
| 105 | 105 | return new Validation\Validator($c['translator'], $c['config']); |
| 106 | 106 | }; |
| 107 | 107 | // Pagination Renderer |
| 108 | - $this->di['pagination.renderer'] = function ($c) {
|
|
| 108 | + $this->di['pagination.renderer'] = function($c) {
|
|
| 109 | 109 | return new Pagination\Renderer(); |
| 110 | 110 | }; |
| 111 | 111 | // Pagination Paginator |
| 112 | - $this->di['pagination.paginator'] = function ($c) {
|
|
| 112 | + $this->di['pagination.paginator'] = function($c) {
|
|
| 113 | 113 | return new Pagination\Paginator($c['pagination.renderer']); |
| 114 | 114 | }; |
| 115 | 115 | // Event Dispatcher |
| 116 | - $this->di['events'] = function ($c) {
|
|
| 116 | + $this->di['events'] = function($c) {
|
|
| 117 | 117 | return new EventDispatcher(); |
| 118 | 118 | }; |
| 119 | 119 | |
@@ -121,15 +121,15 @@ discard block |
||
| 121 | 121 | * Core library objects |
| 122 | 122 | */ |
| 123 | 123 | // Global Response |
| 124 | - $this->di['response'] = function ($c) {
|
|
| 124 | + $this->di['response'] = function($c) {
|
|
| 125 | 125 | return new \Jaxon\Response\Response(); |
| 126 | 126 | }; |
| 127 | 127 | // Jaxon Core |
| 128 | - $this->di['jaxon'] = function ($c) {
|
|
| 128 | + $this->di['jaxon'] = function($c) {
|
|
| 129 | 129 | return new \Jaxon\Jaxon(); |
| 130 | 130 | }; |
| 131 | 131 | // View Renderer Facade |
| 132 | - $this->di['sentry.view.renderer'] = function ($c) {
|
|
| 132 | + $this->di['sentry.view.renderer'] = function($c) {
|
|
| 133 | 133 | $aRenderers = $c['view.data.renderers']; |
| 134 | 134 | $sDefaultNamespace = $c['view.data.namespace.default']; |
| 135 | 135 | return new \Jaxon\Sentry\View\Facade($aRenderers, $sDefaultNamespace); |
@@ -414,14 +414,14 @@ discard block |
||
| 414 | 414 | $this->di['sentry.view.base.' . $sId] = $xClosure; |
| 415 | 415 | |
| 416 | 416 | // Return the initialized view renderer |
| 417 | - $this->di['sentry.view.' . $sId] = function ($c) use ($sId) {
|
|
| 417 | + $this->di['sentry.view.' . $sId] = function($c) use ($sId) {
|
|
| 418 | 418 | // Get the defined renderer |
| 419 | 419 | $renderer = $c['sentry.view.base.' . $sId]; |
| 420 | 420 | // Init the renderer with the template namespaces |
| 421 | 421 | $aNamespaces = $this->di['view.data.namespaces']; |
| 422 | - if(key_exists($sId, $aNamespaces)) |
|
| 422 | + if (key_exists($sId, $aNamespaces)) |
|
| 423 | 423 | {
|
| 424 | - foreach($aNamespaces[$sId] as $ns) |
|
| 424 | + foreach ($aNamespaces[$sId] as $ns) |
|
| 425 | 425 | {
|
| 426 | 426 | $renderer->addNamespace($ns['namespace'], $ns['directory'], $ns['extension']); |
| 427 | 427 | } |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | public function getViewRenderer($sId = '') |
| 441 | 441 | {
|
| 442 | - if(!$sId) |
|
| 442 | + if (!$sId) |
|
| 443 | 443 | {
|
| 444 | 444 | // Return the view renderer facade |
| 445 | 445 | return $this->di['sentry.view.renderer']; |
@@ -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 | $parameterInstance[] = $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 | - $this->reflectionClass = new \ReflectionClass($xCallable); |
|
| 99 | + $this->reflectionClass = new \ReflectionClass($xCallable); |
|
| 100 | + } |
|
| 99 | 101 | $this->callableObject = null; |
| 100 | - } |
|
| 101 | - else // if(is_object($xCallable)) // Received a class instance |
|
| 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 | $parameterInstance[] = $this->diGet($parameter->getClass()->getName()); |
| 133 | 134 | } |
| 134 | 135 | $xCallable = $this->reflectionClass->newInstanceArgs($parameterInstance); |
| 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)); |