@@ -107,7 +107,7 @@ |
||
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Método que guarda en fichero los datos pasados |
110 | - * @param $path |
|
110 | + * @param string $path |
|
111 | 111 | * @param $data |
112 | 112 | * @param int $transform |
113 | 113 | * @param boolean $absolutePath |
@@ -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 | } |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | /** |
589 | 589 | * Método que extrae los parámetros de una función |
590 | 590 | * |
591 | - * @param array $sr |
|
591 | + * @param string[] $sr |
|
592 | 592 | * @param \ReflectionMethod $method |
593 | 593 | * |
594 | 594 | * @return array |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * |
643 | 643 | * @param string $docComments |
644 | 644 | * |
645 | - * @return bool |
|
645 | + * @return string |
|
646 | 646 | */ |
647 | 647 | private function extractReflectionCacheability($docComments) |
648 | 648 | { |
@@ -260,8 +260,10 @@ discard block |
||
260 | 260 | $_route = explode("/", $url['path']); |
261 | 261 | $_pattern = explode("/", $pattern); |
262 | 262 | $get = array(); |
263 | - if (!empty($_pattern)) foreach ($_pattern as $index => $component) { |
|
263 | + if (!empty($_pattern)) { |
|
264 | + foreach ($_pattern as $index => $component) { |
|
264 | 265 | $_get = array(); |
266 | + } |
|
265 | 267 | preg_match_all('/^\{(.*)\}$/i', $component, $_get); |
266 | 268 | if (!empty($_get[1]) && isset($_route[$index])) { |
267 | 269 | $get[array_pop($_get[1])] = $_route[$index]; |
@@ -476,8 +478,10 @@ discard block |
||
476 | 478 | throw new RouterException(_("No existe la ruta especificada")); |
477 | 479 | } |
478 | 480 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
479 | - if (!empty($params)) foreach ($params as $key => $value) { |
|
481 | + if (!empty($params)) { |
|
482 | + foreach ($params as $key => $value) { |
|
480 | 483 | $url = str_replace("{" . $key . "}", $value, $url); |
484 | + } |
|
481 | 485 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
482 | 486 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
483 | 487 | } |
@@ -599,12 +603,16 @@ discard block |
||
599 | 603 | $default = ''; |
600 | 604 | $params = array(); |
601 | 605 | $parameters = $method->getParameters(); |
602 | - if (count($parameters) > 0) foreach ($parameters as $param) { |
|
606 | + if (count($parameters) > 0) { |
|
607 | + foreach ($parameters as $param) { |
|
603 | 608 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
604 | 609 | $params[$param->getName()] = $param->getDefaultValue(); |
610 | + } |
|
605 | 611 | $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
606 | 612 | } |
607 | - } else $default = $regex; |
|
613 | + } else { |
|
614 | + $default = $regex; |
|
615 | + } |
|
608 | 616 | |
609 | 617 | return array($regex, $default, $params); |
610 | 618 | } |
@@ -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 previus exception'); |
90 | 90 | $e = new \Exception(_('Page not found'), 404); |
@@ -125,24 +125,24 @@ discard block |
||
125 | 125 | $this->checkRestrictedAccess($route); |
126 | 126 | //Search action and execute |
127 | 127 | return $this->searchAction($route); |
128 | - } catch (AccessDeniedException $e) { |
|
128 | + }catch (AccessDeniedException $e) { |
|
129 | 129 | Logger::getInstance()->debugLog(_('Solicitamos credenciales de acceso a zona restringida')); |
130 | 130 | if ('login' === Config::getInstance()->get('admin_login')) { |
131 | 131 | return $this->redirectLogin($route); |
132 | - } else { |
|
132 | + }else { |
|
133 | 133 | return $this->sentAuthHeader(); |
134 | 134 | } |
135 | - } catch (RouterException $r) { |
|
135 | + }catch (RouterException $r) { |
|
136 | 136 | if (FALSE !== preg_match('/\/$/', $route)) { |
137 | 137 | if (preg_match('/admin/', $route)) { |
138 | 138 | $default = Config::getInstance()->get('admin_action'); |
139 | - } else { |
|
139 | + }else { |
|
140 | 140 | $default = Config::getInstance()->get('home_action'); |
141 | 141 | } |
142 | 142 | |
143 | 143 | return $this->execute($this->getRoute($default)); |
144 | 144 | } |
145 | - } catch (\Exception $e) { |
|
145 | + }catch (\Exception $e) { |
|
146 | 146 | Logger::getInstance()->errorLog($e->getMessage()); |
147 | 147 | throw $e; |
148 | 148 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $corsEnabled = Config::getInstance()->get('cors.enabled'); |
160 | 160 | $request = Request::getInstance(); |
161 | 161 | if (NULL !== $corsEnabled && null !== $request->getServer('HTTP_REFERER')) { |
162 | - if($corsEnabled == '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) { |
|
162 | + if ($corsEnabled == '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) { |
|
163 | 163 | if (!$this->headersSent) { |
164 | 164 | // TODO include this headers in Template class output method |
165 | 165 | header("Access-Control-Allow-Credentials: true"); |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | header("Access-Control-Allow-Headers: Access-Control-Allow-Methods, Access-Control-Allow-Headers, Access-Control-Allow-Origin, Origin, X-Requested-With, Content-Type, Accept, Authorization, X-API-SEC-TOKEN, X-API-USER-TOKEN"); |
169 | 169 | $this->headersSent = true; |
170 | 170 | } |
171 | - if(Request::getInstance()->getMethod() == 'OPTIONS') { |
|
171 | + if (Request::getInstance()->getMethod() == 'OPTIONS') { |
|
172 | 172 | Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests'); |
173 | - header( "HTTP/1.1 200 OK" ); |
|
173 | + header("HTTP/1.1 200 OK"); |
|
174 | 174 | exit(); |
175 | 175 | } |
176 | 176 | } |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | */ |
186 | 186 | private function compareSlashes($routePattern, $path) { |
187 | 187 | $pattern_sep = count(explode('/', $routePattern)); |
188 | - if(preg_match('/\/$/', $routePattern)) { |
|
188 | + if (preg_match('/\/$/', $routePattern)) { |
|
189 | 189 | $pattern_sep--; |
190 | 190 | } |
191 | 191 | $path_sep = count(explode('/', $path)); |
192 | - if(preg_match('/\/$/', $path)) { |
|
192 | + if (preg_match('/\/$/', $path)) { |
|
193 | 193 | $path_sep--; |
194 | 194 | } |
195 | 195 | return abs($pattern_sep - $path_sep) < 1; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $class = $this->getClassToCall($action); |
219 | 219 | try { |
220 | 220 | return $this->executeCachedRoute($route, $action, $class, $get); |
221 | - } catch (\Exception $e) { |
|
221 | + }catch (\Exception $e) { |
|
222 | 222 | Logger::log($e->getMessage(), LOG_ERR); |
223 | 223 | throw new RouterException($e->getMessage(), 404, $e); |
224 | 224 | } |
@@ -308,13 +308,13 @@ discard block |
||
308 | 308 | if (file_exists($modules)) { |
309 | 309 | $this->routing = $this->inspectDir($modules, "", $this->routing); |
310 | 310 | } |
311 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
311 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
312 | 312 | $home = Config::getInstance()->get('home_action'); |
313 | 313 | if (NULL !== $home || $home !== '') { |
314 | 314 | $home_params = NULL; |
315 | 315 | foreach ($this->routing as $pattern => $params) { |
316 | 316 | list($method, $route) = $this->extractHttpRoute($pattern); |
317 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
317 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
318 | 318 | $home_params = $params; |
319 | 319 | } |
320 | 320 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php"); |
340 | 340 | foreach ($files as $file) { |
341 | 341 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
342 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing); |
|
342 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing); |
|
343 | 343 | } |
344 | 344 | $this->finder = new Finder(); |
345 | 345 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $httpMethod = $this->extractReflectionHttpMethod($docComments); |
381 | 381 | $visible = $this->extractReflectionVisibility($docComments); |
382 | 382 | $expiration = $this->extractReflectionCacheability($docComments); |
383 | - $routing[$httpMethod . "#|#" . $regex] = array( |
|
383 | + $routing[$httpMethod."#|#".$regex] = array( |
|
384 | 384 | "class" => $namespace, |
385 | 385 | "method" => $method->getName(), |
386 | 386 | "params" => $params, |
@@ -410,9 +410,9 @@ discard block |
||
410 | 410 | { |
411 | 411 | //Calculamos los dominios para las plantillas |
412 | 412 | if ($class->hasConstant("DOMAIN")) { |
413 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
414 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
415 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
413 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
414 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
415 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
416 | 416 | $tpl_path = "templates"; |
417 | 417 | $public_path = "public"; |
418 | 418 | $model_path = "models"; |
@@ -422,12 +422,12 @@ discard block |
||
422 | 422 | $model_path = ucfirst($model_path); |
423 | 423 | } |
424 | 424 | if ($class->hasConstant("TPL")) { |
425 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
425 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
426 | 426 | } |
427 | 427 | $this->domains[$domain] = array( |
428 | - "template" => $path . $tpl_path, |
|
429 | - "model" => $path . $model_path, |
|
430 | - "public" => $path . $public_path, |
|
428 | + "template" => $path.$tpl_path, |
|
429 | + "model" => $path.$model_path, |
|
430 | + "public" => $path.$public_path, |
|
431 | 431 | ); |
432 | 432 | } |
433 | 433 | |
@@ -440,11 +440,11 @@ discard block |
||
440 | 440 | */ |
441 | 441 | public function simpatize() |
442 | 442 | { |
443 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
444 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
443 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
444 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
445 | 445 | $this->generateSlugs($absoluteTranslationFileName); |
446 | 446 | Config::createDir(CONFIG_DIR); |
447 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
447 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
448 | 448 | |
449 | 449 | return $this; |
450 | 450 | } |
@@ -495,16 +495,16 @@ discard block |
||
495 | 495 | public function getRoute($slug = '', $absolute = FALSE, $params = NULL) |
496 | 496 | { |
497 | 497 | if (strlen($slug) === 0) { |
498 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
498 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
499 | 499 | } |
500 | 500 | if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { |
501 | 501 | throw new RouterException(_("No existe la ruta especificada")); |
502 | 502 | } |
503 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
503 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
504 | 504 | if (!empty($params)) foreach ($params as $key => $value) { |
505 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
505 | + $url = str_replace("{".$key."}", $value, $url); |
|
506 | 506 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
507 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
507 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -522,12 +522,12 @@ discard block |
||
522 | 522 | if (preg_match('/^\/admin(\/|$)/', $routePattern)) { |
523 | 523 | if (preg_match('/^PSFS/', $params["class"])) { |
524 | 524 | $profile = "superadmin"; |
525 | - } else { |
|
525 | + }else { |
|
526 | 526 | $profile = "admin"; |
527 | 527 | } |
528 | 528 | if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) { |
529 | 529 | $_profile = ($params["visible"]) ? $profile : 'adminhidden'; |
530 | - if(!array_key_exists($_profile, $routes)) { |
|
530 | + if (!array_key_exists($_profile, $routes)) { |
|
531 | 531 | $routes[$_profile] = array(); |
532 | 532 | } |
533 | 533 | $routes[$_profile][] = $params["slug"]; |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | protected function getClassToCall($action) |
575 | 575 | { |
576 | 576 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
577 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
577 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
578 | 578 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
579 | 579 | return $class; |
580 | 580 | } |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | $expr = preg_quote($expr, '/'); |
594 | 594 | $expr = str_replace('###', '(.*)', $expr); |
595 | 595 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
596 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
596 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
597 | 597 | return $matched; |
598 | 598 | } |
599 | 599 | |
@@ -630,9 +630,9 @@ discard block |
||
630 | 630 | if (count($parameters) > 0) foreach ($parameters as $param) { |
631 | 631 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
632 | 632 | $params[$param->getName()] = $param->getDefaultValue(); |
633 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
633 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
634 | 634 | } |
635 | - } else $default = $regex; |
|
635 | + }else $default = $regex; |
|
636 | 636 | |
637 | 637 | return array($regex, $default, $params); |
638 | 638 | } |
@@ -688,16 +688,16 @@ discard block |
||
688 | 688 | */ |
689 | 689 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
690 | 690 | { |
691 | - Logger::log('Executing route ' . $route); |
|
691 | + Logger::log('Executing route '.$route); |
|
692 | 692 | $this->session->setSessionKey("__CACHE__", $action); |
693 | 693 | $cache = Cache::needCache(); |
694 | 694 | $execute = TRUE; |
695 | 695 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
696 | 696 | $cacheDataName = $this->cache->getRequestCacheHash(); |
697 | - $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, $cache, function () { |
|
697 | + $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, $cache, function() { |
|
698 | 698 | }); |
699 | 699 | if (NULL !== $cachedData) { |
700 | - $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", $cache, function () { |
|
700 | + $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", $cache, function() { |
|
701 | 701 | }, Cache::JSON); |
702 | 702 | Template::getInstance()->renderCache($cachedData, $headers); |
703 | 703 | $execute = FALSE; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | $translations = array(); |
747 | 747 | if (file_exists($absoluteTranslationFileName)) { |
748 | 748 | include($absoluteTranslationFileName); |
749 | - } else { |
|
749 | + }else { |
|
750 | 750 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
751 | 751 | } |
752 | 752 |
@@ -371,7 +371,7 @@ |
||
371 | 371 | * @param array $parts |
372 | 372 | * @param int $partLength |
373 | 373 | * |
374 | - * @return array |
|
374 | + * @return string[] |
|
375 | 375 | */ |
376 | 376 | private static function extractTsAndMod(array &$parts, $partLength) |
377 | 377 | { |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | public static function save($user) |
98 | 98 | { |
99 | 99 | $admins = array(); |
100 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
101 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
100 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
101 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
102 | 102 | } |
103 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
103 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
104 | 104 | $admins[$user['username']]['profile'] = $user['profile']; |
105 | 105 | |
106 | - return (FALSE !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
106 | + return (FALSE !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function saveUser($user) { |
115 | 115 | $saved = false; |
116 | - if(!empty($user)) { |
|
116 | + if (!empty($user)) { |
|
117 | 117 | $saved = static::save($user); |
118 | 118 | } |
119 | 119 | return $saved; |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | public function getAdmins() |
137 | 137 | { |
138 | 138 | $admins = array(); |
139 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
140 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
139 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
140 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | return $admins; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | Logger::log('Checking admin session'); |
158 | 158 | if (!$this->authorized) { |
159 | 159 | $request = Request::getInstance(); |
160 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
160 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
161 | 161 | //Si no hay fichero de usuarios redirigimos directamente al gestor |
162 | 162 | return Router::getInstance()->getAdmin()->adminers(); |
163 | 163 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | if (!empty($user) && !empty($admins[$user])) { |
172 | 172 | $auth = $admins[$user]['hash']; |
173 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
173 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
174 | 174 | $this->admin = array( |
175 | 175 | 'alias' => $user, |
176 | 176 | 'profile' => $admins[$user]['profile'], |
@@ -389,12 +389,12 @@ discard block |
||
389 | 389 | $axis = 0; |
390 | 390 | $parts = array(); |
391 | 391 | try { |
392 | - $partLength = floor(strlen($token) / 10); |
|
393 | - for ($i = 0, $ct = ceil(strlen($token) / $partLength); $i < $ct; $i++) { |
|
392 | + $partLength = floor(strlen($token)/10); |
|
393 | + for ($i = 0, $ct = ceil(strlen($token)/$partLength); $i < $ct; $i++) { |
|
394 | 394 | $parts[] = substr($token, $axis, $partLength); |
395 | 395 | $axis += $partLength; |
396 | 396 | } |
397 | - } catch(\Exception $e) { |
|
397 | + }catch (\Exception $e) { |
|
398 | 398 | $partLength = 0; |
399 | 399 | } |
400 | 400 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | $decoded = NULL; |
435 | 435 | list($partLength, $parts) = self::extractTokenParts($token); |
436 | 436 | list($ts, $mod) = self::extractTsAndMod($parts, $partLength); |
437 | - $hashMod = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
437 | + $hashMod = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
438 | 438 | if (time() - (integer)$ts < 300 && $hashMod === $mod) { |
439 | 439 | $decoded = implode('', $parts); |
440 | 440 | } |
@@ -451,16 +451,16 @@ discard block |
||
451 | 451 | public static function generateToken($secret, $module = 'PSFS') |
452 | 452 | { |
453 | 453 | $ts = time(); |
454 | - $hashModule = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
454 | + $hashModule = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
455 | 455 | $hash = hash('sha256', $secret); |
456 | - $insert = floor(strlen($hash) / strlen($ts)); |
|
456 | + $insert = floor(strlen($hash)/strlen($ts)); |
|
457 | 457 | $j = 0; |
458 | 458 | $token = ''; |
459 | 459 | for ($i = 0, $ct = strlen($ts); $i < $ct; $i++) { |
460 | - $token .= substr($ts, $i, 1) . substr($hash, $j, $insert) . substr($hashModule, $i, 2); |
|
460 | + $token .= substr($ts, $i, 1).substr($hash, $j, $insert).substr($hashModule, $i, 2); |
|
461 | 461 | $j += $insert; |
462 | 462 | } |
463 | - $token .= substr($hash, ($insert * strlen($ts)), strlen($hash) - ($insert * strlen($ts))); |
|
463 | + $token .= substr($hash, ($insert*strlen($ts)), strlen($hash) - ($insert*strlen($ts))); |
|
464 | 464 | return $token; |
465 | 465 | } |
466 | 466 |
@@ -125,8 +125,8 @@ |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | - * @param $header |
|
129 | - * @param null $content |
|
128 | + * @param string $header |
|
129 | + * @param string $content |
|
130 | 130 | * |
131 | 131 | * @return $this |
132 | 132 | */ |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->url = NULL; |
178 | 178 | $this->params = array(); |
179 | 179 | $this->headers = array(); |
180 | - Logger::log("Context service for " . get_called_class() . " cleared!"); |
|
180 | + Logger::log("Context service for ".get_called_class()." cleared!"); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | protected function setOpts() |
210 | 210 | { |
211 | - switch(strtoupper($this->type)) { |
|
211 | + switch (strtoupper($this->type)) { |
|
212 | 212 | case 'GET': |
213 | 213 | default: |
214 | 214 | curl_setopt($this->con, CURLOPT_CUSTOMREQUEST, "GET"); |
@@ -42,6 +42,10 @@ discard block |
||
42 | 42 | * @return Form |
43 | 43 | */ |
44 | 44 | public function setEncType($enctype) { $this->enctype = $enctype; return $this; } |
45 | + |
|
46 | + /** |
|
47 | + * @param string|null $action |
|
48 | + */ |
|
45 | 49 | public function setAction($action) { $this->action = $action; return $this; } |
46 | 50 | public function setMethod($method) { $this->method = $method; return $this; } |
47 | 51 | public function setAttrs(array $attrs) { $this->attrs = $attrs; return $this; } |
@@ -466,7 +470,7 @@ discard block |
||
466 | 470 | } |
467 | 471 | |
468 | 472 | /** |
469 | - * @param $token_field |
|
473 | + * @param string $token_field |
|
470 | 474 | * @return bool |
471 | 475 | */ |
472 | 476 | protected function existsFormToken($token_field) { |
@@ -494,7 +498,7 @@ discard block |
||
494 | 498 | /** |
495 | 499 | * Método que extrae el valor de un campo del formulario del modelo |
496 | 500 | * @param $field |
497 | - * @param $value |
|
501 | + * @param ObjectCollection $value |
|
498 | 502 | * @param $type |
499 | 503 | * @return mixed |
500 | 504 | */ |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use PSFS\base\Singleton; |
13 | 13 | use PSFS\base\types\interfaces\FormType; |
14 | 14 | |
15 | - abstract class Form extends Singleton implements FormType{ |
|
15 | + abstract class Form extends Singleton implements FormType { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Variables de formulario |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | public function __construct($model = null) |
33 | 33 | { |
34 | - if(null !== $model) { |
|
34 | + if (null !== $model) { |
|
35 | 35 | $this->model = $model; |
36 | 36 | } |
37 | 37 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getFieldValue($name) { |
124 | 124 | $value = null; |
125 | - if (null !== $this->getField($name)){ |
|
125 | + if (null !== $this->getField($name)) { |
|
126 | 126 | $field = $this->getField($name); |
127 | 127 | $value = (array_key_exists('value', $field) && null !== $field['value']) ? $field['value'] : null; |
128 | 128 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $model->save(); |
324 | 324 | $save = true; |
325 | 325 | Logger::getInstance()->infoLog(get_class($this->model)." guardado con id ".$this->model->getPrimaryKey()); |
326 | - } catch (\Exception $e) { |
|
326 | + }catch (\Exception $e) { |
|
327 | 327 | Logger::getInstance()->errorLog($e->getMessage()); |
328 | 328 | throw new FormException($e->getMessage(), $e->getCode(), $e); |
329 | 329 | } |
@@ -369,10 +369,10 @@ discard block |
||
369 | 369 | if (array_key_exists($key, $data[$form_name])) { |
370 | 370 | if (preg_match("/id/i", $key) && ($data[$form_name][$key] === 0 || $data[$form_name][$key] === "%" || $data[$form_name][$key] === "")) { |
371 | 371 | $field["value"] = null; |
372 | - } else { |
|
372 | + }else { |
|
373 | 373 | $field["value"] = $data[$form_name][$key]; |
374 | 374 | } |
375 | - } else { |
|
375 | + }else { |
|
376 | 376 | unset($field["value"]); |
377 | 377 | } |
378 | 378 | return array($data, $field); |
@@ -416,10 +416,10 @@ discard block |
||
416 | 416 | if (array_key_exists('class_id', $field) && method_exists($class, "get".$field["class_id"])) { |
417 | 417 | $method = "get".$field["class_id"]; |
418 | 418 | $data[] = $class->$method(); |
419 | - } else { |
|
419 | + }else { |
|
420 | 420 | $data[] = $class->getPrimaryKey(); |
421 | 421 | } |
422 | - } else { |
|
422 | + }else { |
|
423 | 423 | $data[] = $val; |
424 | 424 | } |
425 | 425 | |
@@ -449,11 +449,11 @@ discard block |
||
449 | 449 | $field["value"] = $value; |
450 | 450 | } elseif ($value instanceof \DateTime) { |
451 | 451 | $field["value"] = $value->format("Y-m-d H:i:s"); |
452 | - } else { |
|
452 | + }else { |
|
453 | 453 | $field["value"] = $value->getPrimaryKey(); |
454 | 454 | } |
455 | 455 | } |
456 | - } else { |
|
456 | + }else { |
|
457 | 457 | $field["value"] = $value; |
458 | 458 | } |
459 | 459 | } |
@@ -156,7 +156,9 @@ discard block |
||
156 | 156 | //Validamos los campos del formulario |
157 | 157 | if ($valid && count($this->fields) > 0) { |
158 | 158 | foreach ($this->fields as $key => &$field) { |
159 | - if ($key === $token_field || $key === self::SEPARATOR) continue; |
|
159 | + if ($key === $token_field || $key === self::SEPARATOR) { |
|
160 | + continue; |
|
161 | + } |
|
160 | 162 | list($field, $valid) = $this->checkFieldValidation($field, $key); |
161 | 163 | } |
162 | 164 | } |
@@ -442,7 +444,7 @@ discard block |
||
442 | 444 | //Si es una relación múltiple |
443 | 445 | if ($value instanceof ObjectCollection) { |
444 | 446 | $field = $this->computeModelFieldValue($field, $value, $type); |
445 | - }else { //O una relación unitaria |
|
447 | + } else { //O una relación unitaria |
|
446 | 448 | if (method_exists($value, "__toString")) { |
447 | 449 | $field["value"] = $value; |
448 | 450 | } elseif ($value instanceof \DateTime) { |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * Servicio que devuelve los parámetros disponibles |
303 | 303 | * @route /admin/config/params |
304 | 304 | * @visible false |
305 | - * @return mixed |
|
305 | + * @return string|null |
|
306 | 306 | */ |
307 | 307 | public function getConfigParams() { |
308 | 308 | $response = array_merge(Config::$required, Config::$optional); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * Servicio que devuelve los parámetros disponibles |
331 | 331 | * @route /admin/routes/show |
332 | 332 | * @visible false |
333 | - * @return mixed |
|
333 | + * @return string|null |
|
334 | 334 | */ |
335 | 335 | public function getRouting() |
336 | 336 | { |
@@ -175,7 +175,9 @@ |
||
175 | 175 | */ |
176 | 176 | public function getTranslations($locale = '') { |
177 | 177 | //Idioma por defecto |
178 | - if(empty($locale)) $locale = $this->config->get("default_language"); |
|
178 | + if(empty($locale)) { |
|
179 | + $locale = $this->config->get("default_language"); |
|
180 | + } |
|
179 | 181 | |
180 | 182 | //Generamos las traducciones de las plantillas |
181 | 183 | $translations = $this->tpl->regenerateTemplates(); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @package PSFS\controller |
21 | 21 | * @domain ROOT |
22 | 22 | */ |
23 | -class Admin extends AuthAdminController{ |
|
23 | +class Admin extends AuthAdminController { |
|
24 | 24 | |
25 | 25 | const DOMAIN = 'ROOT'; |
26 | 26 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | Logger::getInstance()->infoLog("Configuración guardada correctamente"); |
85 | 85 | $this->security->setFlash("callback_message", _("Usuario agregado correctamente")); |
86 | 86 | $this->security->setFlash("callback_route", $this->getRoute("admin"), true); |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | throw new \HttpException('Error al guardar los administradores, prueba a cambiar los permisos', 403); |
89 | 89 | } |
90 | 90 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $cookies = array( |
151 | 151 | array( |
152 | 152 | "name" => Security::getInstance()->getHash(), |
153 | - "value" => base64_encode($form->getFieldValue("user") . ":" . $form->getFieldValue("pass")), |
|
153 | + "value" => base64_encode($form->getFieldValue("user").":".$form->getFieldValue("pass")), |
|
154 | 154 | "expire" => time() + 3600, |
155 | 155 | "http" => true, |
156 | 156 | ) |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'status_message' => _("Acceso permitido... redirigiendo!!"), |
162 | 162 | 'delay' => 1, |
163 | 163 | ); |
164 | - } else { |
|
164 | + }else { |
|
165 | 165 | $form->setError("user", _("El usuario no tiene acceso a la web")); |
166 | 166 | } |
167 | 167 | } |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function getTranslations($locale = '') { |
179 | 179 | //Idioma por defecto |
180 | - if(empty($locale)) $locale = $this->config->get("default_language"); |
|
180 | + if (empty($locale)) $locale = $this->config->get("default_language"); |
|
181 | 181 | |
182 | 182 | //Generamos las traducciones de las plantillas |
183 | 183 | $translations = $this->tpl->regenerateTemplates(); |
184 | 184 | |
185 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
186 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
185 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
186 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
187 | 187 | |
188 | 188 | //Localizamos xgettext |
189 | 189 | $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale)); |
@@ -230,18 +230,18 @@ discard block |
||
230 | 230 | $form = new ConfigForm(); |
231 | 231 | $form->build(); |
232 | 232 | $form->hydrate(); |
233 | - if($form->isValid()) { |
|
233 | + if ($form->isValid()) { |
|
234 | 234 | $debug = Config::getInstance()->getDebugMode(); |
235 | 235 | $newDebug = $form->getFieldValue("debug"); |
236 | - if(Config::save($form->getData(), $form->getExtraData())) { |
|
236 | + if (Config::save($form->getData(), $form->getExtraData())) { |
|
237 | 237 | Logger::getInstance()->infoLog(_('Configuración guardada correctamente')); |
238 | 238 | //Verificamos si tenemos que limpiar la cache del DocumentRoot |
239 | - if(boolval($debug) !== boolval($newDebug)) { |
|
239 | + if (boolval($debug) !== boolval($newDebug)) { |
|
240 | 240 | Config::clearDocumentRoot(); |
241 | 241 | } |
242 | 242 | $this->security->setFlash("callback_message", _("Configuración actualizada correctamente")); |
243 | 243 | $this->security->setFlash("callback_route", $this->getRoute("admin-config", true)); |
244 | - } else { |
|
244 | + }else { |
|
245 | 245 | throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403); |
246 | 246 | } |
247 | 247 | } |
@@ -300,10 +300,10 @@ discard block |
||
300 | 300 | $type = $form->getFieldValue("controllerType"); |
301 | 301 | try { |
302 | 302 | $this->gen->createStructureModule($module, $force, $type); |
303 | - $this->security->setFlash("callback_message", str_replace("%s",$module, _("Módulo %s generado correctamente"))); |
|
303 | + $this->security->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente"))); |
|
304 | 304 | $this->security->setFlash("callback_route", $this->getRoute("admin-module", true)); |
305 | - } catch(\Exception $e) { |
|
306 | - Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]"); |
|
305 | + }catch (\Exception $e) { |
|
306 | + Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]"); |
|
307 | 307 | throw new ConfigException('Error al generar el módulo, prueba a cambiar los permisos', 403); |
308 | 308 | } |
309 | 309 | } |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | public function getConfigParams() { |
326 | 326 | $response = array_merge(Config::$required, Config::$optional); |
327 | 327 | $domains = Router::getInstance()->getDomains(); |
328 | - foreach($domains as $domain => $routes) { |
|
328 | + foreach ($domains as $domain => $routes) { |
|
329 | 329 | $pDomain = str_replace('@', '', $domain); |
330 | 330 | $pDomain = str_replace('/', '', $pDomain); |
331 | - $response[] = strtolower($pDomain) . '.api.secret'; |
|
331 | + $response[] = strtolower($pDomain).'.api.secret'; |
|
332 | 332 | } |
333 | 333 | return $this->json($response); |
334 | 334 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | |
371 | 371 | $selected = ''; |
372 | 372 | $monthOpen = null; |
373 | - if($this->getRequest()->getMethod() == 'POST') |
|
373 | + if ($this->getRequest()->getMethod() == 'POST') |
|
374 | 374 | { |
375 | 375 | $selected = $this->getRequest()->get("log"); |
376 | 376 | list($log, $monthOpen) = $this->srv->formatLogFile($selected); |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $router->simpatize(); |
399 | 399 | $this->security->setFlash("callback_message", _("Rutas generadas correctamente")); |
400 | 400 | $this->security->setFlash("callback_route", $this->getRoute("admin", true)); |
401 | - } catch(\Exception $e) { |
|
401 | + }catch (\Exception $e) { |
|
402 | 402 | Logger::getInstance()->errorLog($e->getMessage()); |
403 | 403 | $this->security->setFlash("callback_message", _("Algo no ha salido bien, revisa los logs")); |
404 | 404 | $this->security->setFlash("callback_route", $this->getRoute("admin", true)); |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | |
5 | 5 | use PSFS\base\types\SingletonTrait; |
6 | 6 | |
7 | -if(!function_exists("getallheaders")) |
|
7 | +if (!function_exists("getallheaders")) |
|
8 | 8 | { |
9 | 9 | function getallheaders() |
10 | 10 | { |
11 | 11 | $headers = array(); |
12 | - foreach($_SERVER as $h=>$v) |
|
13 | - if(preg_match('/HTTP_(.+)/',$h,$hp)) |
|
14 | - $headers[$hp[1]]=$v; |
|
12 | + foreach ($_SERVER as $h=>$v) |
|
13 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
14 | + $headers[$hp[1]] = $v; |
|
15 | 15 | return $headers; |
16 | 16 | } |
17 | 17 | } |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | * Método que devuelve la url solicitada |
110 | 110 | * @return string|null |
111 | 111 | */ |
112 | - public static function requestUri(){ return self::getInstance()->getRequestUri(); } |
|
112 | + public static function requestUri() { return self::getInstance()->getRequestUri(); } |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @return string |
116 | 116 | */ |
117 | - public function getRequestUri(){ return array_key_exists('REQUEST_URI', $this->server) ? $this->server['REQUEST_URI'] : ''; } |
|
117 | + public function getRequestUri() { return array_key_exists('REQUEST_URI', $this->server) ? $this->server['REQUEST_URI'] : ''; } |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Método que devuelve el idioma de la petición |
@@ -9,9 +9,10 @@ discard block |
||
9 | 9 | function getallheaders() |
10 | 10 | { |
11 | 11 | $headers = array(); |
12 | - foreach($_SERVER as $h=>$v) |
|
13 | - if(preg_match('/HTTP_(.+)/',$h,$hp)) |
|
12 | + foreach($_SERVER as $h=>$v) { |
|
13 | + if(preg_match('/HTTP_(.+)/',$h,$hp)) |
|
14 | 14 | $headers[$hp[1]]=$v; |
15 | + } |
|
15 | 16 | return $headers; |
16 | 17 | } |
17 | 18 | } |
@@ -180,7 +181,9 @@ discard block |
||
180 | 181 | */ |
181 | 182 | public function redirect($url = null) |
182 | 183 | { |
183 | - if (null === $url) $url = $this->server['HTTP_ORIGIN']; |
|
184 | + if (null === $url) { |
|
185 | + $url = $this->server['HTTP_ORIGIN']; |
|
186 | + } |
|
184 | 187 | ob_start(); |
185 | 188 | header('Location: '.$url); |
186 | 189 | ob_end_clean(); |
@@ -226,7 +229,9 @@ discard block |
||
226 | 229 | $host = $this->getServerName(); |
227 | 230 | $protocol = $protocol ? $this->getProtocol() : ''; |
228 | 231 | $url = ''; |
229 | - if (!empty($host) && !empty($protocol)) $url = $protocol.$host; |
|
232 | + if (!empty($host) && !empty($protocol)) { |
|
233 | + $url = $protocol.$host; |
|
234 | + } |
|
230 | 235 | return $url; |
231 | 236 | } |
232 | 237 |
@@ -95,6 +95,10 @@ |
||
95 | 95 | * @return string|null |
96 | 96 | */ |
97 | 97 | public static function header($name) { return self::getInstance()->getHeader($name); } |
98 | + |
|
99 | + /** |
|
100 | + * @return string |
|
101 | + */ |
|
98 | 102 | public function getHeader($name) |
99 | 103 | { |
100 | 104 | $header = null; |
@@ -125,11 +125,13 @@ |
||
125 | 125 | $cacheService->storeData($cacheFilename, $properties, Cache::JSON); |
126 | 126 | } |
127 | 127 | /** @var \ReflectionProperty $property */ |
128 | - if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { |
|
128 | + if (!empty($properties) && is_array($properties)) { |
|
129 | + foreach ($properties as $property => $class) { |
|
129 | 130 | $this->load($property, true, $class); |
130 | 131 | } |
132 | + } |
|
131 | 133 | $this->setLoaded(); |
132 | - }else { |
|
134 | + } else { |
|
133 | 135 | $logService->warningLog(get_class($this)." ya cargada"); |
134 | 136 | } |
135 | 137 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | public function __construct() |
20 | 20 | { |
21 | - Logger::log(get_class($this) . ' constructor invoked'); |
|
21 | + Logger::log(get_class($this).' constructor invoked'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param $value |
42 | 42 | */ |
43 | 43 | public function __set($variable, $value) { |
44 | - if(property_exists(get_class($this), $variable)) { |
|
44 | + if (property_exists(get_class($this), $variable)) { |
|
45 | 45 | $this->$variable = $value; |
46 | 46 | } |
47 | 47 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | $setter = "set".ucfirst($variable); |
99 | 99 | if (method_exists($calledClass, $setter)) { |
100 | 100 | $this->$setter($instance); |
101 | - } else { |
|
101 | + }else { |
|
102 | 102 | $this->$variable = $instance; |
103 | 103 | } |
104 | - } catch (\Exception $e) { |
|
105 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
104 | + }catch (\Exception $e) { |
|
105 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
106 | 106 | } |
107 | 107 | return $this; |
108 | 108 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | $this->setLoaded(); |
130 | 130 | }else { |
131 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
131 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | if (null === $class) { |
143 | 143 | $class = get_class($this); |
144 | 144 | } |
145 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
145 | + Logger::log('Extracting annotations properties from class '.$class); |
|
146 | 146 | $selfReflector = new \ReflectionClass($class); |
147 | 147 | if (false !== $selfReflector->getParentClass()) { |
148 | 148 | $properties = $this->getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | */ |
183 | 183 | private function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
184 | 184 | { |
185 | - Logger::log('Create inyectable instance for ' . $classNameSpace . ' into ' . get_class($this)); |
|
185 | + Logger::log('Create inyectable instance for '.$classNameSpace.' into '.get_class($this)); |
|
186 | 186 | $reflector = new \ReflectionClass($calledClass); |
187 | 187 | $property = $reflector->getProperty($variable); |
188 | 188 | $varInstanceType = (null === $classNameSpace) ? $this->extractVarType($property->getDocComment()) : $classNameSpace; |
189 | 189 | if (true === $singleton && method_exists($varInstanceType, "getInstance")) { |
190 | 190 | $instance = $varInstanceType::getInstance(); |
191 | - } else { |
|
191 | + }else { |
|
192 | 192 | $instance = new $varInstanceType(); |
193 | 193 | } |
194 | 194 | return $instance; |
@@ -307,7 +307,7 @@ |
||
307 | 307 | if ($file->isFile()) { |
308 | 308 | try { |
309 | 309 | $this->tpl->loadTemplate(str_replace($tplDir.'/', '', $file)); |
310 | - } catch (\Exception $e) { |
|
310 | + }catch (\Exception $e) { |
|
311 | 311 | Logger::getInstance()->errorLog($e->getMessage()); |
312 | 312 | } |
313 | 313 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $dump = ''; |
198 | 198 | try { |
199 | 199 | $dump = $this->tpl->render($tpl, $vars); |
200 | - }catch (\Exception $e) { |
|
200 | + } catch (\Exception $e) { |
|
201 | 201 | echo $e->getMessage()."<pre>".$e->getTraceAsString()."</pre>"; |
202 | 202 | } |
203 | 203 | return $dump; |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | unset($_SERVER["PHP_AUTH_USER"]); |
395 | 395 | unset($_SERVER["PHP_AUTH_PW"]); |
396 | 396 | header_remove("Authorization"); |
397 | - }else { |
|
397 | + } else { |
|
398 | 398 | header('Authorization:'); |
399 | 399 | } |
400 | 400 | } |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | |
6 | 6 | use PSFS\base\config\Config; |
7 | -use PSFS\base\exception\ConfigException; |
|
8 | 7 | use PSFS\base\extension\AssetsTokenParser; |
9 | 8 | use PSFS\base\extension\TemplateFunctions; |
10 | 9 | use PSFS\base\types\SingletonTrait; |