@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | /** |
540 | 540 | * @param bool $hydrateRoute |
541 | 541 | * @param $modulePath |
542 | - * @param $externalModulePath |
|
542 | + * @param string $externalModulePath |
|
543 | 543 | */ |
544 | 544 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath) |
545 | 545 | { |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
557 | - * @param $hydrateRoute |
|
557 | + * @param boolean $hydrateRoute |
|
558 | 558 | * @param $module |
559 | 559 | * @return mixed |
560 | 560 | */ |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function init() |
66 | 66 | { |
67 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", $this->cacheType, TRUE); |
|
67 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", $this->cacheType, TRUE); |
|
68 | 68 | if (empty($this->routing) || Config::getInstance()->getDebugMode()) { |
69 | 69 | $this->debugLoad(); |
70 | - } else { |
|
71 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->cacheType, TRUE); |
|
70 | + }else { |
|
71 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->cacheType, TRUE); |
|
72 | 72 | } |
73 | 73 | $this->checkExternalModules(false); |
74 | 74 | $this->setLoaded(true); |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | if (preg_match('/json/i', Request::getInstance()->getServer('CONTENT_TYPE')) || $isJson) { |
104 | 104 | $response = new JsonResponse(null, false, 0, 0, $e->getMessage()); |
105 | 105 | return $template->output(json_encode($response), 'application/json'); |
106 | - } else { |
|
106 | + }else { |
|
107 | 107 | $not_found_rouote = Config::getParam('route.404'); |
108 | - if(null !== $not_found_rouote) { |
|
108 | + if (null !== $not_found_rouote) { |
|
109 | 109 | Request::getInstance()->redirect($this->getRoute($not_found_rouote, true)); |
110 | - } else { |
|
110 | + }else { |
|
111 | 111 | return $template->render('error.html.twig', array( |
112 | 112 | 'exception' => $e, |
113 | 113 | 'trace' => $e->getTraceAsString(), |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | try { |
163 | 163 | //Search action and execute |
164 | 164 | $this->searchAction($route); |
165 | - } catch (AccessDeniedException $e) { |
|
165 | + }catch (AccessDeniedException $e) { |
|
166 | 166 | Logger::log(_('Solicitamos credenciales de acceso a zona restringida')); |
167 | 167 | return Admin::staticAdminLogon($route); |
168 | - } catch (RouterException $r) { |
|
168 | + }catch (RouterException $r) { |
|
169 | 169 | Logger::log($r->getMessage(), LOG_WARNING); |
170 | - } catch (\Exception $e) { |
|
170 | + }catch (\Exception $e) { |
|
171 | 171 | Logger::log($e->getMessage(), LOG_ERR); |
172 | 172 | throw $e; |
173 | 173 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | protected function searchAction($route) |
186 | 186 | { |
187 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
187 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
188 | 188 | //Revisamos si tenemos la ruta registrada |
189 | 189 | $parts = parse_url($route); |
190 | 190 | $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route; |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | /** @var $class \PSFS\base\types\Controller */ |
200 | 200 | $class = RouterHelper::getClassToCall($action); |
201 | 201 | try { |
202 | - if($this->checkRequirements($action, $get)) { |
|
202 | + if ($this->checkRequirements($action, $get)) { |
|
203 | 203 | $this->executeCachedRoute($route, $action, $class, $get); |
204 | - } else { |
|
204 | + }else { |
|
205 | 205 | throw new RouterException(_('La ruta no es válida'), 400); |
206 | 206 | } |
207 | - } catch (\Exception $e) { |
|
207 | + }catch (\Exception $e) { |
|
208 | 208 | Logger::log($e->getMessage(), LOG_ERR); |
209 | 209 | throw new \RuntimeException($e->getMessage(), 404, $e); |
210 | 210 | } |
@@ -220,16 +220,16 @@ discard block |
||
220 | 220 | */ |
221 | 221 | private function checkRequirements(array $action, array $params = []) { |
222 | 222 | $valid = true; |
223 | - if(!empty($action['requirements'])) { |
|
224 | - if(!empty($params)) { |
|
223 | + if (!empty($action['requirements'])) { |
|
224 | + if (!empty($params)) { |
|
225 | 225 | $checked = 0; |
226 | - foreach(array_keys($params) as $key) { |
|
227 | - if(in_array($key, $action['requirements'])) { |
|
226 | + foreach (array_keys($params) as $key) { |
|
227 | + if (in_array($key, $action['requirements'])) { |
|
228 | 228 | $checked++; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | $valid = count($action['requirements']) == $checked; |
232 | - } else { |
|
232 | + }else { |
|
233 | 233 | $valid = false; |
234 | 234 | } |
235 | 235 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | private function getExternalModules() { |
252 | 252 | $externalModules = Config::getParam('modules.extend', ''); |
253 | - if(Config::getParam('psfs.auth', false)) { |
|
253 | + if (Config::getParam('psfs.auth', false)) { |
|
254 | 254 | $externalModules .= ',psfs/auth'; |
255 | 255 | } |
256 | 256 | return $externalModules; |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
285 | 285 | foreach ($modules as $modulePath) { |
286 | 286 | $module = $modulePath->getBasename(); |
287 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
287 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
288 | 288 | } |
289 | 289 | } |
290 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
290 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | $home_params = NULL; |
303 | 303 | foreach ($this->routing as $pattern => $params) { |
304 | 304 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
305 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
305 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
306 | 306 | $home_params = $params; |
307 | 307 | } |
308 | 308 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php"); |
328 | 328 | foreach ($files as $file) { |
329 | 329 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
330 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
330 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
331 | 331 | } |
332 | 332 | $this->finder = new Finder(); |
333 | 333 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | if (!$this->domains) { |
398 | 398 | $this->domains = []; |
399 | 399 | } |
400 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
400 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
401 | 401 | if (!array_key_exists($domain, $this->domains)) { |
402 | 402 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
403 | 403 | } |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function simpatize() |
414 | 414 | { |
415 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
416 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
415 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
416 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
417 | 417 | $this->generateSlugs($absoluteTranslationFileName); |
418 | 418 | GeneratorHelper::createDir(CONFIG_DIR); |
419 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
419 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
420 | 420 | |
421 | 421 | return $this; |
422 | 422 | } |
@@ -434,16 +434,16 @@ discard block |
||
434 | 434 | public function getRoute($slug = '', $absolute = FALSE, $params = []) |
435 | 435 | { |
436 | 436 | if (strlen($slug) === 0) { |
437 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
437 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
438 | 438 | } |
439 | 439 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
440 | 440 | throw new RouterException(_("No existe la ruta especificada")); |
441 | 441 | } |
442 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
442 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
443 | 443 | if (!empty($params)) foreach ($params as $key => $value) { |
444 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
444 | + $url = str_replace("{".$key."}", $value, $url); |
|
445 | 445 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
446 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
446 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -488,17 +488,17 @@ discard block |
||
488 | 488 | */ |
489 | 489 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
490 | 490 | { |
491 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
491 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
492 | 492 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
493 | 493 | Security::getInstance()->setSessionKey("__CACHE__", $action); |
494 | 494 | $cache = Cache::needCache(); |
495 | 495 | $execute = TRUE; |
496 | 496 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE && $action['http'] === 'GET') { |
497 | 497 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
498 | - $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, |
|
498 | + $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, |
|
499 | 499 | $cache, null); |
500 | 500 | if (NULL !== $cachedData) { |
501 | - $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", |
|
501 | + $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", |
|
502 | 502 | $cache, null, Cache::JSON); |
503 | 503 | Template::getInstance()->renderCache($cachedData, $headers); |
504 | 504 | $execute = FALSE; |
@@ -544,11 +544,11 @@ discard block |
||
544 | 544 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath) |
545 | 545 | { |
546 | 546 | $extModule = $modulePath->getBasename(); |
547 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
547 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
548 | 548 | if (file_exists($moduleAutoloader)) { |
549 | 549 | @include $moduleAutoloader; |
550 | 550 | if ($hydrateRoute) { |
551 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
551 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | } |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | private function loadExternalModule($hydrateRoute, $module) |
562 | 562 | { |
563 | 563 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
564 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
564 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
565 | 565 | if (file_exists($externalModulePath)) { |
566 | 566 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
567 | 567 | if (!empty($externalModule)) { |