@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function init() |
| 64 | 64 | { |
| 65 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
| 66 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
| 65 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
| 66 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
| 67 | 67 | if (empty($this->routing) || Config::getParam('debug', true)) { |
| 68 | 68 | $this->debugLoad(); |
| 69 | 69 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $this->hydrateRouting(); |
| 85 | 85 | $this->simpatize(); |
| 86 | 86 | Logger::log('End routes load'); |
| 87 | - } else { |
|
| 87 | + }else { |
|
| 88 | 88 | Logger::log('Routes generation skipped'); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -101,13 +101,13 @@ discard block |
||
| 101 | 101 | try { |
| 102 | 102 | //Search action and execute |
| 103 | 103 | return $this->searchAction($route); |
| 104 | - } catch (AccessDeniedException $e) { |
|
| 105 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
| 104 | + }catch (AccessDeniedException $e) { |
|
| 105 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
| 106 | 106 | return Admin::staticAdminLogon(); |
| 107 | - } catch (RouterException $r) { |
|
| 107 | + }catch (RouterException $r) { |
|
| 108 | 108 | Logger::log($r->getMessage(), LOG_WARNING); |
| 109 | 109 | $code = $r->getCode(); |
| 110 | - } catch (Exception $e) { |
|
| 110 | + }catch (Exception $e) { |
|
| 111 | 111 | Logger::log($e->getMessage(), LOG_ERR); |
| 112 | 112 | throw $e; |
| 113 | 113 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | protected function searchAction($route) |
| 127 | 127 | { |
| 128 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
| 128 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
| 129 | 129 | //Revisamos si tenemos la ruta registrada |
| 130 | 130 | $parts = parse_url($route); |
| 131 | 131 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | throw new RouterException(t('Preconditions failed'), 412); |
| 148 | - } catch (Exception $e) { |
|
| 148 | + }catch (Exception $e) { |
|
| 149 | 149 | Logger::log($e->getMessage(), LOG_ERR); |
| 150 | 150 | throw $e; |
| 151 | 151 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | $valid = count($action['requirements']) === $checked; |
| 173 | - } else { |
|
| 173 | + }else { |
|
| 174 | 174 | $valid = true; |
| 175 | 175 | } |
| 176 | 176 | return $valid; |
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | if ($modules->hasResults()) { |
| 194 | 194 | foreach ($modules->getIterator() as $modulePath) { |
| 195 | 195 | $module = $modulePath->getBasename(); |
| 196 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
| 196 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 200 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $homeParams = NULL; |
| 215 | 215 | foreach ($this->routing as $pattern => $params) { |
| 216 | 216 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
| 217 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
| 217 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
| 218 | 218 | $homeParams = $params; |
| 219 | 219 | } |
| 220 | 220 | unset($method); |
@@ -246,18 +246,18 @@ discard block |
||
| 246 | 246 | { |
| 247 | 247 | $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : ''; |
| 248 | 248 | if ('' === $slug) { |
| 249 | - return $baseUrl . '/'; |
|
| 249 | + return $baseUrl.'/'; |
|
| 250 | 250 | } |
| 251 | 251 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
| 252 | 252 | throw new RouterException(t('No existe la ruta especificada')); |
| 253 | 253 | } |
| 254 | - $url = $baseUrl . $this->slugs[$slug]; |
|
| 254 | + $url = $baseUrl.$this->slugs[$slug]; |
|
| 255 | 255 | if (!empty($params)) { |
| 256 | 256 | foreach ($params as $key => $value) { |
| 257 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
| 257 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
| 258 | 258 | } |
| 259 | 259 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
| 260 | - $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default']; |
|
| 260 | + $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default']; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | if ($this->hasToRunPreChecks($class)) { |
| 273 | 273 | self::run($class, '__check', true); |
| 274 | 274 | } |
| 275 | - $preAction = 'pre' . ucfirst($method); |
|
| 275 | + $preAction = 'pre'.ucfirst($method); |
|
| 276 | 276 | if (method_exists($class, $preAction)) { |
| 277 | 277 | self::run($class, $preAction); |
| 278 | 278 | } |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public static function run($class, $method, $throwExceptions = false): void |
| 289 | 289 | { |
| 290 | - Inspector::stats("[Router] Pre action invoked " . get_class($class) . "::{$method}", Inspector::SCOPE_DEBUG); |
|
| 290 | + Inspector::stats("[Router] Pre action invoked ".get_class($class)."::{$method}", Inspector::SCOPE_DEBUG); |
|
| 291 | 291 | try { |
| 292 | 292 | if (false === call_user_func_array([$class, $method], [])) { |
| 293 | - Logger::log(t("[Router] action " . get_class($class) . "::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
| 293 | + Logger::log(t("[Router] action ".get_class($class)."::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
| 294 | 294 | error_clear_last(); |
| 295 | 295 | } |
| 296 | - } catch (Exception $e) { |
|
| 296 | + }catch (Exception $e) { |
|
| 297 | 297 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
| 298 | 298 | if ($throwExceptions) { |
| 299 | 299 | throw $e; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
| 324 | 324 | { |
| 325 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
| 325 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
| 326 | 326 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
| 327 | 327 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
| 328 | 328 | $cache = Cache::needCache(); |
@@ -330,15 +330,15 @@ discard block |
||
| 330 | 330 | $return = null; |
| 331 | 331 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
| 332 | 332 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
| 333 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
| 333 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
| 334 | 334 | if (NULL !== $cachedData) { |
| 335 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
| 335 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
| 336 | 336 | Template::getInstance()->renderCache($cachedData, $headers); |
| 337 | 337 | $execute = FALSE; |
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | if ($execute) { |
| 341 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
| 341 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
| 342 | 342 | $this->checkPreActions($class, $action['method']); |
| 343 | 343 | $return = call_user_func_array([$class, $action['method']], $params); |
| 344 | 344 | if (false === $return) { |