@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function init() |
61 | 61 | { |
62 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) { |
|
62 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) { |
|
63 | 63 | $this->hydrateRouting(); |
64 | 64 | $this->simpatize(); |
65 | - } else { |
|
66 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE); |
|
67 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE); |
|
65 | + }else { |
|
66 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE); |
|
67 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | "success" => FALSE, |
85 | 85 | "error" => $e->getMessage(), |
86 | 86 | )), 'application/json'); |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | if (NULL === $e) { |
89 | 89 | Logger::log('Not found page throwed without previous exception', LOG_WARNING); |
90 | 90 | $e = new \Exception(_('Page not found'), 404); |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getAllRoutes() { |
115 | 115 | $routes = []; |
116 | - foreach($this->routing as $path => $route) { |
|
117 | - if(array_key_exists('slug', $route)) { |
|
116 | + foreach ($this->routing as $path => $route) { |
|
117 | + if (array_key_exists('slug', $route)) { |
|
118 | 118 | $routes[$route['slug']] = $path; |
119 | 119 | } |
120 | 120 | } |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | SecurityHelper::checkRestrictedAccess($route); |
140 | 140 | //Search action and execute |
141 | 141 | $this->searchAction($route); |
142 | - } catch (AccessDeniedException $e) { |
|
142 | + }catch (AccessDeniedException $e) { |
|
143 | 143 | Logger::log(_('Solicitamos credenciales de acceso a zona restringida')); |
144 | 144 | return Admin::staticAdminLogon($route); |
145 | - } catch (RouterException $r) { |
|
146 | - if(null === RouterHelper::checkDefaultRoute($route)) { |
|
145 | + }catch (RouterException $r) { |
|
146 | + if (null === RouterHelper::checkDefaultRoute($route)) { |
|
147 | 147 | Logger::log($r->getMessage(), LOG_WARNING); |
148 | 148 | throw $r; |
149 | 149 | } |
150 | - } catch (\Exception $e) { |
|
150 | + }catch (\Exception $e) { |
|
151 | 151 | Logger::log($e->getMessage(), LOG_ERR); |
152 | 152 | throw $e; |
153 | 153 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | protected function searchAction($route) |
166 | 166 | { |
167 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
167 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
168 | 168 | //Revisamos si tenemos la ruta registrada |
169 | 169 | $parts = parse_url($route); |
170 | 170 | $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $class = RouterHelper::getClassToCall($action); |
179 | 179 | try { |
180 | 180 | $this->executeCachedRoute($route, $action, $class, $get); |
181 | - } catch (\Exception $e) { |
|
181 | + }catch (\Exception $e) { |
|
182 | 182 | Logger::log($e->getMessage(), LOG_ERR); |
183 | 183 | throw new RouterException($e->getMessage(), 404, $e); |
184 | 184 | } |
@@ -206,13 +206,13 @@ discard block |
||
206 | 206 | $this->routing = $this->inspectDir($base, "PSFS", array()); |
207 | 207 | if (file_exists($modules)) { |
208 | 208 | $module = ""; |
209 | - if(file_exists($modules . DIRECTORY_SEPARATOR . 'module.json')) { |
|
210 | - $mod_cfg = json_decode(file_get_contents($modules . DIRECTORY_SEPARATOR . 'module.json'), true); |
|
209 | + if (file_exists($modules.DIRECTORY_SEPARATOR.'module.json')) { |
|
210 | + $mod_cfg = json_decode(file_get_contents($modules.DIRECTORY_SEPARATOR.'module.json'), true); |
|
211 | 211 | $module = $mod_cfg['module']; |
212 | 212 | } |
213 | 213 | $this->routing = $this->inspectDir($modules, $module, $this->routing); |
214 | 214 | } |
215 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
215 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $home_params = NULL; |
228 | 228 | foreach ($this->routing as $pattern => $params) { |
229 | 229 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
230 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
230 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
231 | 231 | $home_params = $params; |
232 | 232 | } |
233 | 233 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php"); |
253 | 253 | foreach ($files as $file) { |
254 | 254 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
255 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing); |
|
255 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing); |
|
256 | 256 | } |
257 | 257 | $this->finder = new Finder(); |
258 | 258 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
293 | 293 | list($route, $info) = RouterHelper::extractRouteInfo($method, $api); |
294 | - if(null !== $route && null !== $info) { |
|
294 | + if (null !== $route && null !== $info) { |
|
295 | 295 | $info['class'] = $namespace; |
296 | 296 | $routing[$route] = $info; |
297 | 297 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | { |
315 | 315 | //Calculamos los dominios para las plantillas |
316 | 316 | if ($class->hasConstant("DOMAIN")) { |
317 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
317 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
318 | 318 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
319 | 319 | } |
320 | 320 | |
@@ -327,11 +327,11 @@ discard block |
||
327 | 327 | */ |
328 | 328 | public function simpatize() |
329 | 329 | { |
330 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
331 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
330 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
331 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
332 | 332 | $this->generateSlugs($absoluteTranslationFileName); |
333 | 333 | Config::createDir(CONFIG_DIR); |
334 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
334 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
335 | 335 | |
336 | 336 | return $this; |
337 | 337 | } |
@@ -349,16 +349,16 @@ discard block |
||
349 | 349 | public function getRoute($slug = '', $absolute = FALSE, $params = []) |
350 | 350 | { |
351 | 351 | if (strlen($slug) === 0) { |
352 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
352 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
353 | 353 | } |
354 | 354 | if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { |
355 | 355 | throw new RouterException(_("No existe la ruta especificada")); |
356 | 356 | } |
357 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
357 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
358 | 358 | if (!empty($params)) foreach ($params as $key => $value) { |
359 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
359 | + $url = str_replace("{".$key."}", $value, $url); |
|
360 | 360 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
361 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
361 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -401,17 +401,17 @@ discard block |
||
401 | 401 | */ |
402 | 402 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
403 | 403 | { |
404 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
404 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
405 | 405 | Security::getInstance()->setSessionKey("__CACHE__", $action); |
406 | 406 | $cache = Cache::needCache(); |
407 | 407 | $execute = TRUE; |
408 | 408 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
409 | 409 | $cacheDataName = $this->cache->getRequestCacheHash(); |
410 | - $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, |
|
411 | - $cache, function () {}); |
|
410 | + $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, |
|
411 | + $cache, function() {}); |
|
412 | 412 | if (NULL !== $cachedData) { |
413 | - $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", |
|
414 | - $cache, function () {}, Cache::JSON); |
|
413 | + $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", |
|
414 | + $cache, function() {}, Cache::JSON); |
|
415 | 415 | Template::getInstance()->renderCache($cachedData, $headers); |
416 | 416 | $execute = FALSE; |
417 | 417 | } |
@@ -131,7 +131,7 @@ |
||
131 | 131 | if (null !== $function && $this->hasExpiredCache($path, $expires)) { |
132 | 132 | $data = call_user_func($function); |
133 | 133 | $this->storeData($path, $data, $transform); |
134 | - } else { |
|
134 | + }else { |
|
135 | 135 | $data = $this->getDataFromFile($path, $transform); |
136 | 136 | } |
137 | 137 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | $translations = array(); |
22 | 22 | if (file_exists($absoluteTranslationFileName)) { |
23 | 23 | @include($absoluteTranslationFileName); |
24 | - } else { |
|
24 | + }else { |
|
25 | 25 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
26 | 26 | } |
27 | 27 |