@@ -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 | } |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | try { |
| 99 | 99 | //Search action and execute |
| 100 | 100 | return $this->searchAction($route); |
| 101 | - } catch (AccessDeniedException $e) { |
|
| 102 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
| 101 | + }catch (AccessDeniedException $e) { |
|
| 102 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
| 103 | 103 | return Admin::staticAdminLogon(); |
| 104 | - } catch (RouterException $r) { |
|
| 104 | + }catch (RouterException $r) { |
|
| 105 | 105 | Logger::log($r->getMessage(), LOG_WARNING); |
| 106 | 106 | $code = $r->getCode(); |
| 107 | - } catch (Exception $e) { |
|
| 107 | + }catch (Exception $e) { |
|
| 108 | 108 | Logger::log($e->getMessage(), LOG_ERR); |
| 109 | 109 | throw $e; |
| 110 | 110 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | protected function searchAction($route) |
| 124 | 124 | { |
| 125 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
| 125 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
| 126 | 126 | //Revisamos si tenemos la ruta registrada |
| 127 | 127 | $parts = parse_url($route); |
| 128 | 128 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | try { |
| 140 | 140 | if ($this->checkRequirements($action, $get)) { |
| 141 | 141 | return $this->executeCachedRoute($route, $action, $class, $get); |
| 142 | - } else { |
|
| 142 | + }else { |
|
| 143 | 143 | throw new RouterException(t('Preconditions failed'), 412); |
| 144 | 144 | } |
| 145 | - } catch (Exception $e) { |
|
| 145 | + }catch (Exception $e) { |
|
| 146 | 146 | Logger::log($e->getMessage(), LOG_ERR); |
| 147 | 147 | throw $e; |
| 148 | 148 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | $valid = count($action['requirements']) === $checked; |
| 170 | - } else { |
|
| 170 | + }else { |
|
| 171 | 171 | $valid = true; |
| 172 | 172 | } |
| 173 | 173 | return $valid; |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | if ($modules->hasResults()) { |
| 191 | 191 | foreach ($modules->getIterator() as $modulePath) { |
| 192 | 192 | $module = $modulePath->getBasename(); |
| 193 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
| 193 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 197 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $homeParams = NULL; |
| 212 | 212 | foreach ($this->routing as $pattern => $params) { |
| 213 | 213 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
| 214 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
| 214 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
| 215 | 215 | $homeParams = $params; |
| 216 | 216 | } |
| 217 | 217 | unset($method); |
@@ -243,18 +243,18 @@ discard block |
||
| 243 | 243 | { |
| 244 | 244 | $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : ''; |
| 245 | 245 | if ('' === $slug) { |
| 246 | - return $baseUrl . '/'; |
|
| 246 | + return $baseUrl.'/'; |
|
| 247 | 247 | } |
| 248 | 248 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
| 249 | 249 | throw new RouterException(t('No existe la ruta especificada')); |
| 250 | 250 | } |
| 251 | - $url = $baseUrl . $this->slugs[$slug]; |
|
| 251 | + $url = $baseUrl.$this->slugs[$slug]; |
|
| 252 | 252 | if (!empty($params)) { |
| 253 | 253 | foreach ($params as $key => $value) { |
| 254 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
| 254 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
| 255 | 255 | } |
| 256 | 256 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
| 257 | - $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default']; |
|
| 257 | + $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default']; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | private function checkPreActions($class, $method) |
| 268 | 268 | { |
| 269 | - $preAction = 'pre' . ucfirst($method); |
|
| 269 | + $preAction = 'pre'.ucfirst($method); |
|
| 270 | 270 | if (method_exists($class, $preAction)) { |
| 271 | 271 | Inspector::stats('[Router] Pre action invoked', Inspector::SCOPE_DEBUG); |
| 272 | 272 | try { |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]); |
| 275 | 275 | error_clear_last(); |
| 276 | 276 | } |
| 277 | - } catch (Exception $e) { |
|
| 277 | + }catch (Exception $e) { |
|
| 278 | 278 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
| 293 | 293 | { |
| 294 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
| 294 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
| 295 | 295 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
| 296 | 296 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
| 297 | 297 | $cache = Cache::needCache(); |
@@ -299,15 +299,15 @@ discard block |
||
| 299 | 299 | $return = null; |
| 300 | 300 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
| 301 | 301 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
| 302 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
| 302 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
| 303 | 303 | if (NULL !== $cachedData) { |
| 304 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
| 304 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
| 305 | 305 | Template::getInstance()->renderCache($cachedData, $headers); |
| 306 | 306 | $execute = FALSE; |
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | 309 | if ($execute) { |
| 310 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
| 310 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
| 311 | 311 | $this->checkPreActions($class, $action['method']); |
| 312 | 312 | $return = call_user_func_array([$class, $action['method']], $params); |
| 313 | 313 | if (false === $return) { |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | { |
| 51 | 51 | $this->generateSlugs(); |
| 52 | 52 | GeneratorHelper::createDir(CONFIG_DIR); |
| 53 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', [$this->routing, $this->getSlugs()], Cache::JSON, TRUE); |
|
| 53 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', [$this->routing, $this->getSlugs()], Cache::JSON, TRUE); |
|
| 54 | 54 | |
| 55 | 55 | return $this; |
| 56 | 56 | } |