@@ -21,11 +21,11 @@ |
||
21 | 21 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
22 | 22 | |
23 | 23 | // filepath |
24 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
24 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
25 | 25 | if (!file_exists($abs_path)) { |
26 | - pre('→ ' . $class); |
|
27 | - pre('→ ' . $path); |
|
28 | - pre('→ ' . $abs_path); |
|
26 | + pre('→ '.$class); |
|
27 | + pre('→ '.$path); |
|
28 | + pre('→ '.$abs_path); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // require the file |
@@ -38,8 +38,8 @@ |
||
38 | 38 | //Generating the templates translations |
39 | 39 | $translations = $this->tpl->regenerateTemplates(); |
40 | 40 | |
41 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
42 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
41 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
42 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
43 | 43 | |
44 | 44 | //xgettext localizations |
45 | 45 | $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale)); |
@@ -35,7 +35,9 @@ |
||
35 | 35 | public function getTranslations($locale) |
36 | 36 | { |
37 | 37 | //Default locale |
38 | - if (null === $locale) $locale = $this->config->get("default.language", 'es_ES'); |
|
38 | + if (null === $locale) { |
|
39 | + $locale = $this->config->get("default.language", 'es_ES'); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | //Generating the templates translations |
41 | 43 | $translations = $this->tpl->regenerateTemplates(); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param string $msg |
89 | 89 | * @param array $context |
90 | 90 | * |
91 | - * @return bool |
|
91 | + * @return boolean|null |
|
92 | 92 | */ |
93 | 93 | public function debugLog($msg = '', $context = []) |
94 | 94 | { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Método que escribe un log de Error |
100 | - * @param $msg |
|
100 | + * @param string $msg |
|
101 | 101 | * @param array $context |
102 | 102 | * |
103 | 103 | * @return bool |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Método que escribe un log de Warning |
112 | - * @param $msg |
|
112 | + * @param string $msg |
|
113 | 113 | * @param array $context |
114 | 114 | * @return bool |
115 | 115 | */ |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | if (!defined("LOG_DIR")) { |
18 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
19 | - define("LOG_DIR", BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
18 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
19 | + define("LOG_DIR", BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $config = Config::getInstance(); |
50 | 50 | $args = func_get_args(); |
51 | 51 | list($logger, $debug, $path) = $this->setup($config, $args); |
52 | - $this->stream = fopen($path . DIRECTORY_SEPARATOR . date("Ymd") . ".log", "a+"); |
|
52 | + $this->stream = fopen($path.DIRECTORY_SEPARATOR.date("Ymd").".log", "a+"); |
|
53 | 53 | $this->addPushLogger($logger, $debug, $config); |
54 | 54 | $this->log_level = Config::getParam('log.level', 'info'); |
55 | 55 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | private function createLoggerPath(Config $config) |
204 | 204 | { |
205 | 205 | $logger = $this->setLoggerName($config); |
206 | - $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m'); |
|
206 | + $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m'); |
|
207 | 207 | GeneratorHelper::createDir($path); |
208 | 208 | |
209 | 209 | return $path; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public static function log($msg, $type = LOG_DEBUG, $context = []) |
219 | 219 | { |
220 | - if(Config::getParam('profiling.enable')) { |
|
220 | + if (Config::getParam('profiling.enable')) { |
|
221 | 221 | Inspector::stats($msg); |
222 | 222 | } |
223 | 223 | switch ($type) { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | private function addMinimalContext($context = []) |
267 | 267 | { |
268 | - if(!is_array($context)) { |
|
268 | + if (!is_array($context)) { |
|
269 | 269 | $context = []; |
270 | 270 | } |
271 | 271 | $context['uri'] = null !== $_SERVER && array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : 'Unknow'; |
@@ -393,8 +393,10 @@ |
||
393 | 393 | throw new RouterException(_("No existe la ruta especificada")); |
394 | 394 | } |
395 | 395 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
396 | - if (!empty($params)) foreach ($params as $key => $value) { |
|
396 | + if (!empty($params)) { |
|
397 | + foreach ($params as $key => $value) { |
|
397 | 398 | $url = str_replace("{" . $key . "}", $value, $url); |
399 | + } |
|
398 | 400 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
399 | 401 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
400 | 402 | } |
@@ -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 | */ |
@@ -4,7 +4,6 @@ |
||
4 | 4 | use PSFS\base\config\Config; |
5 | 5 | use PSFS\base\dto\JsonResponse; |
6 | 6 | use PSFS\base\exception\AccessDeniedException; |
7 | -use PSFS\base\exception\ApiException; |
|
8 | 7 | use PSFS\base\exception\ConfigException; |
9 | 8 | use PSFS\base\exception\RouterException; |
10 | 9 | use PSFS\base\types\helpers\AdminHelper; |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function init() |
65 | 65 | { |
66 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", $this->cacheType, TRUE); |
|
66 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", $this->cacheType, TRUE); |
|
67 | 67 | if (empty($this->routing) || Config::getInstance()->getDebugMode()) { |
68 | 68 | $this->debugLoad(); |
69 | - } else { |
|
70 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->cacheType, TRUE); |
|
69 | + }else { |
|
70 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->cacheType, TRUE); |
|
71 | 71 | } |
72 | 72 | $this->checkExternalModules(false); |
73 | 73 | $this->setLoaded(true); |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | if (preg_match('/json/i', Request::getInstance()->getServer('CONTENT_TYPE')) || $isJson) { |
103 | 103 | $response = new JsonResponse(null, false, 0, 0, $e->getMessage()); |
104 | 104 | return $template->output(json_encode($response), 'application/json'); |
105 | - } else { |
|
105 | + }else { |
|
106 | 106 | $not_found_route = Config::getParam('route.404'); |
107 | - if(null !== $not_found_route) { |
|
107 | + if (null !== $not_found_route) { |
|
108 | 108 | Request::getInstance()->redirect($this->getRoute($not_found_route, true)); |
109 | - } else { |
|
109 | + }else { |
|
110 | 110 | return $template->render('error.html.twig', array( |
111 | 111 | 'exception' => $e, |
112 | 112 | 'trace' => $e->getTraceAsString(), |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | try { |
162 | 162 | //Search action and execute |
163 | 163 | $this->searchAction($route); |
164 | - } catch (AccessDeniedException $e) { |
|
165 | - Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
164 | + }catch (AccessDeniedException $e) { |
|
165 | + Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
166 | 166 | return Admin::staticAdminLogon($route); |
167 | - } catch (RouterException $r) { |
|
167 | + }catch (RouterException $r) { |
|
168 | 168 | Logger::log($r->getMessage(), LOG_WARNING); |
169 | - } catch (\Exception $e) { |
|
169 | + }catch (\Exception $e) { |
|
170 | 170 | Logger::log($e->getMessage(), LOG_ERR); |
171 | 171 | throw $e; |
172 | 172 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | protected function searchAction($route) |
185 | 185 | { |
186 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
186 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
187 | 187 | //Revisamos si tenemos la ruta registrada |
188 | 188 | $parts = parse_url($route); |
189 | 189 | $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route; |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | /** @var $class \PSFS\base\types\Controller */ |
199 | 199 | $class = RouterHelper::getClassToCall($action); |
200 | 200 | try { |
201 | - if($this->checkRequirements($action, $get)) { |
|
201 | + if ($this->checkRequirements($action, $get)) { |
|
202 | 202 | $this->executeCachedRoute($route, $action, $class, $get); |
203 | - } else { |
|
203 | + }else { |
|
204 | 204 | throw new RouterException(_('La ruta no es válida'), 400); |
205 | 205 | } |
206 | - } catch (\Exception $e) { |
|
206 | + }catch (\Exception $e) { |
|
207 | 207 | Logger::log($e->getMessage(), LOG_ERR); |
208 | 208 | throw $e; |
209 | 209 | } |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | * @return bool |
219 | 219 | */ |
220 | 220 | private function checkRequirements(array $action, array $params = []) { |
221 | - if(!empty($action['requirements']) && !empty($params)) { |
|
221 | + if (!empty($action['requirements']) && !empty($params)) { |
|
222 | 222 | $checked = 0; |
223 | - foreach(array_keys($params) as $key) { |
|
224 | - if(in_array($key, $action['requirements'])) { |
|
223 | + foreach (array_keys($params) as $key) { |
|
224 | + if (in_array($key, $action['requirements'])) { |
|
225 | 225 | $checked++; |
226 | 226 | } |
227 | 227 | } |
228 | 228 | $valid = count($action['requirements']) == $checked; |
229 | - } else { |
|
229 | + }else { |
|
230 | 230 | $valid = true; |
231 | 231 | } |
232 | 232 | return $valid; |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
279 | 279 | foreach ($modules as $modulePath) { |
280 | 280 | $module = $modulePath->getBasename(); |
281 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
281 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
282 | 282 | } |
283 | 283 | } |
284 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
284 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $home_params = NULL; |
297 | 297 | foreach ($this->routing as $pattern => $params) { |
298 | 298 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
299 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
299 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
300 | 300 | $home_params = $params; |
301 | 301 | } |
302 | 302 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php"); |
322 | 322 | foreach ($files as $file) { |
323 | 323 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
324 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
324 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
325 | 325 | } |
326 | 326 | $this->finder = new Finder(); |
327 | 327 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | private function addRouting($namespace, &$routing, $module = 'PSFS') |
352 | 352 | { |
353 | 353 | if (self::exists($namespace)) { |
354 | - if(I18nHelper::checkI18Class($namespace)) { |
|
354 | + if (I18nHelper::checkI18Class($namespace)) { |
|
355 | 355 | return $routing; |
356 | 356 | } |
357 | 357 | $reflection = new \ReflectionClass($namespace); |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | if (!$this->domains) { |
395 | 395 | $this->domains = []; |
396 | 396 | } |
397 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
397 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
398 | 398 | if (!array_key_exists($domain, $this->domains)) { |
399 | 399 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
400 | 400 | } |
@@ -409,11 +409,11 @@ discard block |
||
409 | 409 | */ |
410 | 410 | public function simpatize() |
411 | 411 | { |
412 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
413 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
412 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
413 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
414 | 414 | $this->generateSlugs($absoluteTranslationFileName); |
415 | 415 | GeneratorHelper::createDir(CONFIG_DIR); |
416 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
416 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
417 | 417 | |
418 | 418 | return $this; |
419 | 419 | } |
@@ -431,16 +431,16 @@ discard block |
||
431 | 431 | public function getRoute($slug = '', $absolute = FALSE, $params = []) |
432 | 432 | { |
433 | 433 | if (strlen($slug) === 0) { |
434 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
434 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
435 | 435 | } |
436 | 436 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
437 | 437 | throw new RouterException(_("No existe la ruta especificada")); |
438 | 438 | } |
439 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
439 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
440 | 440 | if (!empty($params)) foreach ($params as $key => $value) { |
441 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
441 | + $url = str_replace("{".$key."}", $value, $url); |
|
442 | 442 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
443 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
443 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -485,17 +485,17 @@ discard block |
||
485 | 485 | */ |
486 | 486 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
487 | 487 | { |
488 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
488 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
489 | 489 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
490 | 490 | Security::getInstance()->setSessionKey("__CACHE__", $action); |
491 | 491 | $cache = Cache::needCache(); |
492 | 492 | $execute = TRUE; |
493 | 493 | if (FALSE !== $cache && Config::getParam('debug') === FALSE && $action['http'] === 'GET') { |
494 | 494 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
495 | - $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, |
|
495 | + $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, |
|
496 | 496 | $cache, null); |
497 | 497 | if (NULL !== $cachedData) { |
498 | - $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", |
|
498 | + $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", |
|
499 | 499 | $cache, null, Cache::JSON); |
500 | 500 | Template::getInstance()->renderCache($cachedData, $headers); |
501 | 501 | $execute = FALSE; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath) |
539 | 539 | { |
540 | 540 | $extModule = $modulePath->getBasename(); |
541 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
542 | - if(file_exists($moduleAutoloader)) { |
|
541 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
542 | + if (file_exists($moduleAutoloader)) { |
|
543 | 543 | include_once $moduleAutoloader; |
544 | 544 | if ($hydrateRoute) { |
545 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
545 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | } |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | { |
557 | 557 | try { |
558 | 558 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
559 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
559 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
560 | 560 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
561 | 561 | foreach ($externalModule as $modulePath) { |
562 | 562 | $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath); |
563 | 563 | } |
564 | - } catch (\Exception $e) { |
|
564 | + }catch (\Exception $e) { |
|
565 | 565 | Logger::log($e->getMessage(), LOG_WARNING); |
566 | 566 | $module = null; |
567 | 567 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | unset($_SERVER["PHP_AUTH_USER"]); |
39 | 39 | unset($_SERVER["PHP_AUTH_PW"]); |
40 | 40 | header_remove("Authorization"); |
41 | - } else { |
|
41 | + }else { |
|
42 | 42 | header('Authorization:'); |
43 | 43 | } |
44 | 44 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | Logger::log('Adding debug headers to render response'); |
67 | 67 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
68 | 68 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
69 | - header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
70 | - header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
71 | - header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
69 | + header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
70 | + header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
71 | + header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return $vars; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * Método que extrae los parámetros de una función |
142 | 142 | * |
143 | - * @param array $sr |
|
143 | + * @param string[] $sr |
|
144 | 144 | * @param \ReflectionMethod $method |
145 | 145 | * |
146 | 146 | * @return array |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param string $docComments |
209 | 209 | * |
210 | - * @return bool |
|
210 | + * @return string |
|
211 | 211 | */ |
212 | 212 | public static function extractReflectionCacheability($docComments) |
213 | 213 | { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public static function getClassToCall($action) |
23 | 23 | { |
24 | 24 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
25 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
25 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
26 | 26 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
27 | 27 | return $class; |
28 | 28 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $expr = preg_quote($expr, '/'); |
109 | 109 | $expr = str_replace('###', '(.*)', $expr); |
110 | 110 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
111 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
111 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
112 | 112 | return $matched; |
113 | 113 | } |
114 | 114 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
121 | 121 | { |
122 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
123 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
122 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
123 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
124 | 124 | $tpl_path = "templates"; |
125 | 125 | $public_path = "public"; |
126 | 126 | $model_path = "models"; |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | $model_path = ucfirst($model_path); |
131 | 131 | } |
132 | 132 | if ($class->hasConstant("TPL")) { |
133 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
133 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
134 | 134 | } |
135 | 135 | return [ |
136 | 136 | "base" => $path, |
137 | - "template" => $path . $tpl_path, |
|
138 | - "model" => $path . $model_path, |
|
139 | - "public" => $path . $public_path, |
|
137 | + "template" => $path.$tpl_path, |
|
138 | + "model" => $path.$model_path, |
|
139 | + "public" => $path.$public_path, |
|
140 | 140 | ]; |
141 | 141 | } |
142 | 142 | |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | if (count($parameters) > 0) foreach ($parameters as $param) { |
160 | 160 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
161 | 161 | $params[$param->getName()] = $param->getDefaultValue(); |
162 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
163 | - } elseif(!$param->isOptional()) { |
|
162 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
163 | + } elseif (!$param->isOptional()) { |
|
164 | 164 | $requirements[] = $param->getName(); |
165 | 165 | } |
166 | - } else $default = $regex; |
|
166 | + }else $default = $regex; |
|
167 | 167 | |
168 | 168 | return [$regex, $default, $params, $requirements]; |
169 | 169 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $default = str_replace('{__DOMAIN__}', $module, $default); |
244 | 244 | $httpMethod = RouterHelper::extractReflectionHttpMethod($docComments); |
245 | 245 | $label = RouterHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
246 | - $route = $httpMethod . "#|#" . $regex; |
|
246 | + $route = $httpMethod."#|#".$regex; |
|
247 | 247 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
248 | 248 | $info = [ |
249 | 249 | "method" => $method->getName(), |
@@ -59,8 +59,10 @@ discard block |
||
59 | 59 | $_route = explode("/", $url['path']); |
60 | 60 | $_pattern = explode("/", $pattern); |
61 | 61 | $get = array(); |
62 | - if (!empty($_pattern)) foreach ($_pattern as $index => $component) { |
|
62 | + if (!empty($_pattern)) { |
|
63 | + foreach ($_pattern as $index => $component) { |
|
63 | 64 | $_get = array(); |
65 | + } |
|
64 | 66 | preg_match_all('/^\{(.*)\}$/i', $component, $_get); |
65 | 67 | if (!empty($_get[1]) && isset($_route[$index])) { |
66 | 68 | $get[array_pop($_get[1])] = $_route[$index]; |
@@ -156,14 +158,18 @@ discard block |
||
156 | 158 | $parameters = $method->getParameters(); |
157 | 159 | $requirements = []; |
158 | 160 | /** @var \ReflectionParameter $param */ |
159 | - if (count($parameters) > 0) foreach ($parameters as $param) { |
|
161 | + if (count($parameters) > 0) { |
|
162 | + foreach ($parameters as $param) { |
|
160 | 163 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
161 | 164 | $params[$param->getName()] = $param->getDefaultValue(); |
165 | + } |
|
162 | 166 | $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
163 | 167 | } elseif(!$param->isOptional()) { |
164 | 168 | $requirements[] = $param->getName(); |
165 | 169 | } |
166 | - } else $default = $regex; |
|
170 | + } else { |
|
171 | + $default = $regex; |
|
172 | + } |
|
167 | 173 | |
168 | 174 | return [$regex, $default, $params, $requirements]; |
169 | 175 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * @route /admin/config/params |
23 | 23 | * @label Parámetros de configuración de PSGS |
24 | 24 | * @visible false |
25 | - * @return mixed |
|
25 | + * @return string|null |
|
26 | 26 | */ |
27 | 27 | public function getConfigParams() |
28 | 28 | { |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | foreach ($domains as $domain => $routes) { |
32 | 32 | $pDomain = str_replace('@', '', $domain); |
33 | 33 | $pDomain = str_replace('/', '', $pDomain); |
34 | - $response[] = strtolower($pDomain) . '.api.secret'; |
|
34 | + $response[] = strtolower($pDomain).'.api.secret'; |
|
35 | 35 | } |
36 | 36 | return $this->json($response); |
37 | 37 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function config() |
47 | 47 | { |
48 | - Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri()); |
|
48 | + Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri()); |
|
49 | 49 | /* @var $form \PSFS\base\config\ConfigForm */ |
50 | 50 | $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig()); |
51 | 51 | $form->build(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | Security::getInstance()->setFlash("callback_message", _("Configuración actualizada correctamente")); |
84 | 84 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true)); |
85 | - } else { |
|
85 | + }else { |
|
86 | 86 | throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403); |
87 | 87 | } |
88 | 88 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | * @route /admin/routes/show |
31 | 31 | * @label Servicio de rutas del sistema |
32 | 32 | * @visible false |
33 | - * @return mixed |
|
33 | + * @return string|null |
|
34 | 34 | */ |
35 | 35 | public function getRouting() |
36 | 36 | { |
@@ -55,7 +55,7 @@ |
||
55 | 55 | $router->simpatize(); |
56 | 56 | Security::getInstance()->setFlash("callback_message", _("Rutas generadas correctamente")); |
57 | 57 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true)); |
58 | - } catch (\Exception $e) { |
|
58 | + }catch (\Exception $e) { |
|
59 | 59 | Logger::log($e->getMessage(), LOG_ERR); |
60 | 60 | Security::getInstance()->setFlash("callback_message", _("Algo no ha salido bien, revisa los logs")); |
61 | 61 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true)); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | Logger::log('Configuration saved successful'); |
64 | 64 | Security::getInstance()->setFlash("callback_message", _("Usuario agregado correctamente")); |
65 | 65 | Security::getInstance()->setFlash("callback_route", Router::getInstance()->getRoute("admin", true)); |
66 | - } else { |
|
66 | + }else { |
|
67 | 67 | throw new ConfigException(_('Error al guardar los administradores, prueba a cambiar los permisos')); |
68 | 68 | } |
69 | 69 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | if ($this->isAdmin()) { |
101 | 101 | return $this->redirect('admin'); |
102 | - } else { |
|
102 | + }else { |
|
103 | 103 | return Admin::staticAdminLogon($route); |
104 | 104 | } |
105 | 105 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $cookies = array( |
132 | 132 | array( |
133 | 133 | "name" => Security::getInstance()->getHash(), |
134 | - "value" => base64_encode($form->getFieldValue("user") . ":" . $form->getFieldValue("pass")), |
|
134 | + "value" => base64_encode($form->getFieldValue("user").":".$form->getFieldValue("pass")), |
|
135 | 135 | "expire" => time() + 3600, |
136 | 136 | "http" => true, |
137 | 137 | ) |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | 'status_message' => _("Acceso permitido... redirigiendo!!"), |
143 | 143 | 'delay' => 1, |
144 | 144 | ); |
145 | - } else { |
|
145 | + }else { |
|
146 | 146 | $form->setError("user", _("El usuario no tiene acceso a la web")); |
147 | 147 | } |
148 | 148 | } |