@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | protected function init() |
48 | 48 | { |
49 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json")) { |
|
49 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json")) { |
|
50 | 50 | $this->loadConfigData(); |
51 | 51 | } |
52 | 52 | return $this; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function getTemplatePath() |
118 | 118 | { |
119 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
119 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
120 | 120 | return realpath($path); |
121 | 121 | } |
122 | 122 | |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | $final_data = self::saveExtraParams($data); |
164 | 164 | $saved = false; |
165 | 165 | try { |
166 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", $final_data, Cache::JSON, true); |
|
166 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", $final_data, Cache::JSON, true); |
|
167 | 167 | Config::getInstance()->loadConfigData(); |
168 | 168 | $saved = true; |
169 | - } catch (ConfigException $e) { |
|
169 | + }catch (ConfigException $e) { |
|
170 | 170 | Logger::log($e->getMessage(), LOG_ERR); |
171 | 171 | } |
172 | 172 | return $saved; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function getPropelParams() |
200 | 200 | { |
201 | - return Cache::getInstance()->getDataFromFile(__DIR__ . DIRECTORY_SEPARATOR . 'properties.json', Cache::JSON, true); |
|
201 | + return Cache::getInstance()->getDataFromFile(__DIR__.DIRECTORY_SEPARATOR.'properties.json', Cache::JSON, true); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | { |
211 | 211 | try { |
212 | 212 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
213 | - throw new \Exception(_('Can\'t create directory ') . $dir); |
|
213 | + throw new \Exception(_('Can\'t create directory ').$dir); |
|
214 | 214 | } |
215 | - } catch (\Exception $e) { |
|
215 | + }catch (\Exception $e) { |
|
216 | 216 | Logger::log($e->getMessage(), LOG_WARNING); |
217 | 217 | if (!file_exists(dirname($dir))) { |
218 | - throw new ConfigException($e->getMessage() . $dir); |
|
218 | + throw new ConfigException($e->getMessage().$dir); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | } |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | { |
228 | 228 | $rootDirs = array("css", "js", "media", "font"); |
229 | 229 | foreach ($rootDirs as $dir) { |
230 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
230 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
231 | 231 | try { |
232 | - @shell_exec("rm -rf " . WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
233 | - } catch (\Exception $e) { |
|
232 | + @shell_exec("rm -rf ".WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
233 | + }catch (\Exception $e) { |
|
234 | 234 | Logger::log($e->getMessage()); |
235 | 235 | } |
236 | 236 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function loadConfigData() |
244 | 244 | { |
245 | - $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", |
|
245 | + $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", |
|
246 | 246 | Cache::JSON, |
247 | 247 | TRUE) ?: []; |
248 | 248 | $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | try { |
155 | 155 | $minifiedJs = Minifier::minify($data); |
156 | - } catch(\Exception $e) { |
|
156 | + }catch (\Exception $e) { |
|
157 | 157 | Logger::log($e->getMessage(), LOG_ERR); |
158 | 158 | $minifiedJs = false; |
159 | 159 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | foreach ($this->compiled_files as $file) { |
197 | 197 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
198 | 198 | } |
199 | - } else { |
|
199 | + }else { |
|
200 | 200 | echo "\t\t<script type='text/javascript' src='/js/".$this->hash.".js'></script>\n"; |
201 | 201 | } |
202 | 202 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | foreach ($this->compiled_files as $file) { |
211 | 211 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
212 | 212 | } |
213 | - } else { |
|
213 | + }else { |
|
214 | 214 | echo "\t\t<link href='/css/".$this->hash.".css' rel='stylesheet' media='screen, print'>"; |
215 | 215 | } |
216 | 216 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | Logger::log("$orig copiado a $dest", LOG_INFO); |
236 | 236 | } |
237 | 237 | } |
238 | - } catch (\Exception $e) { |
|
238 | + }catch (\Exception $e) { |
|
239 | 239 | Logger::log($e->getMessage(), LOG_ERR); |
240 | 240 | } |
241 | 241 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | if ($this->debug) { |
264 | 264 | $data = file_get_contents($file); |
265 | 265 | $this->storeContents($base.$file_path, $data); |
266 | - } else { |
|
266 | + }else { |
|
267 | 267 | $data .= file_get_contents($file); |
268 | 268 | } |
269 | 269 | $this->compiled_files[] = "/css/".$file_path; |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function init() |
56 | 56 | { |
57 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) { |
|
57 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) { |
|
58 | 58 | $this->hydrateRouting(); |
59 | 59 | $this->simpatize(); |
60 | - } else { |
|
61 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE); |
|
62 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE); |
|
60 | + }else { |
|
61 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE); |
|
62 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | "success" => FALSE, |
80 | 80 | "error" => $e->getMessage(), |
81 | 81 | )), 'application/json'); |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | if (NULL === $e) { |
84 | 84 | Logger::log('Not found page throwed without previus exception'); |
85 | 85 | $e = new \Exception(_('Page not found'), 404); |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function getAllRoutes() { |
110 | 110 | $routes = []; |
111 | - foreach($this->routing as $path => $route) { |
|
112 | - if(array_key_exists('slug', $route)) { |
|
111 | + foreach ($this->routing as $path => $route) { |
|
112 | + if (array_key_exists('slug', $route)) { |
|
113 | 113 | $routes[$route['slug']] = $path; |
114 | 114 | } |
115 | 115 | } |
@@ -134,24 +134,24 @@ discard block |
||
134 | 134 | $this->checkRestrictedAccess($route); |
135 | 135 | //Search action and execute |
136 | 136 | $this->searchAction($route); |
137 | - } catch (AccessDeniedException $e) { |
|
137 | + }catch (AccessDeniedException $e) { |
|
138 | 138 | Logger::log(_('Solicitamos credenciales de acceso a zona restringida')); |
139 | 139 | if ('login' === Config::getInstance()->get('admin_login')) { |
140 | 140 | return $this->redirectLogin($route); |
141 | - } else { |
|
141 | + }else { |
|
142 | 142 | return $this->sentAuthHeader(); |
143 | 143 | } |
144 | - } catch (RouterException $r) { |
|
144 | + }catch (RouterException $r) { |
|
145 | 145 | if (FALSE !== preg_match('/\/$/', $route)) { |
146 | 146 | if (preg_match('/admin/', $route)) { |
147 | 147 | $default = Config::getInstance()->get('admin_action'); |
148 | - } else { |
|
148 | + }else { |
|
149 | 149 | $default = Config::getInstance()->get('home_action'); |
150 | 150 | } |
151 | 151 | |
152 | 152 | return $this->execute($this->getRoute($default)); |
153 | 153 | } |
154 | - } catch (\Exception $e) { |
|
154 | + }catch (\Exception $e) { |
|
155 | 155 | Logger::log($e->getMessage(), LOG_ERR); |
156 | 156 | throw $e; |
157 | 157 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $class = $this->getClassToCall($action); |
229 | 229 | try { |
230 | 230 | $this->executeCachedRoute($route, $action, $class, $get); |
231 | - } catch (\Exception $e) { |
|
231 | + }catch (\Exception $e) { |
|
232 | 232 | Logger::log($e->getMessage(), LOG_ERR); |
233 | 233 | throw new RouterException($e->getMessage(), 404, $e); |
234 | 234 | } |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | $this->routing = $this->inspectDir($base, "PSFS", array()); |
317 | 317 | if (file_exists($modules)) { |
318 | 318 | $module = ""; |
319 | - if(file_exists($modules . DIRECTORY_SEPARATOR . 'module.json')) { |
|
320 | - $mod_cfg = json_decode(file_get_contents($modules . DIRECTORY_SEPARATOR . 'module.json'), true); |
|
319 | + if (file_exists($modules.DIRECTORY_SEPARATOR.'module.json')) { |
|
320 | + $mod_cfg = json_decode(file_get_contents($modules.DIRECTORY_SEPARATOR.'module.json'), true); |
|
321 | 321 | $module = $mod_cfg['module']; |
322 | 322 | } |
323 | 323 | $this->routing = $this->inspectDir($modules, $module, $this->routing); |
324 | 324 | } |
325 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
325 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $home_params = NULL; |
338 | 338 | foreach ($this->routing as $pattern => $params) { |
339 | 339 | list($method, $route) = $this->extractHttpRoute($pattern); |
340 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
340 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
341 | 341 | $home_params = $params; |
342 | 342 | } |
343 | 343 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php"); |
363 | 363 | foreach ($files as $file) { |
364 | 364 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
365 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing); |
|
365 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing); |
|
366 | 366 | } |
367 | 367 | $this->finder = new Finder(); |
368 | 368 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $httpMethod = $this->extractReflectionHttpMethod($docComments); |
413 | 413 | $visible = $this->extractReflectionVisibility($docComments); |
414 | 414 | $expiration = $this->extractReflectionCacheability($docComments); |
415 | - $routing[$httpMethod . "#|#" . $regex] = array( |
|
415 | + $routing[$httpMethod."#|#".$regex] = array( |
|
416 | 416 | "class" => $namespace, |
417 | 417 | "method" => $method->getName(), |
418 | 418 | "params" => $params, |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | { |
443 | 443 | //Calculamos los dominios para las plantillas |
444 | 444 | if ($class->hasConstant("DOMAIN")) { |
445 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
446 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
447 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
445 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
446 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
447 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
448 | 448 | $tpl_path = "templates"; |
449 | 449 | $public_path = "public"; |
450 | 450 | $model_path = "models"; |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | $model_path = ucfirst($model_path); |
455 | 455 | } |
456 | 456 | if ($class->hasConstant("TPL")) { |
457 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
457 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
458 | 458 | } |
459 | 459 | $this->domains[$domain] = array( |
460 | - "template" => $path . $tpl_path, |
|
461 | - "model" => $path . $model_path, |
|
462 | - "public" => $path . $public_path, |
|
460 | + "template" => $path.$tpl_path, |
|
461 | + "model" => $path.$model_path, |
|
462 | + "public" => $path.$public_path, |
|
463 | 463 | ); |
464 | 464 | } |
465 | 465 | |
@@ -472,11 +472,11 @@ discard block |
||
472 | 472 | */ |
473 | 473 | public function simpatize() |
474 | 474 | { |
475 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
476 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
475 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
476 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
477 | 477 | $this->generateSlugs($absoluteTranslationFileName); |
478 | 478 | Config::createDir(CONFIG_DIR); |
479 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
479 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
480 | 480 | |
481 | 481 | return $this; |
482 | 482 | } |
@@ -527,16 +527,16 @@ discard block |
||
527 | 527 | public function getRoute($slug = '', $absolute = FALSE, $params = []) |
528 | 528 | { |
529 | 529 | if (strlen($slug) === 0) { |
530 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
530 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
531 | 531 | } |
532 | 532 | if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { |
533 | 533 | throw new RouterException(_("No existe la ruta especificada")); |
534 | 534 | } |
535 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
535 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
536 | 536 | if (!empty($params)) foreach ($params as $key => $value) { |
537 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
537 | + $url = str_replace("{".$key."}", $value, $url); |
|
538 | 538 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
539 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
539 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | if (preg_match('/^\/admin(\/|$)/', $routePattern)) { |
555 | 555 | if (preg_match('/^\\\?PSFS/', $params["class"])) { |
556 | 556 | $profile = "superadmin"; |
557 | - } else { |
|
557 | + }else { |
|
558 | 558 | $profile = "admin"; |
559 | 559 | } |
560 | 560 | if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) { |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | protected function getClassToCall($action) |
607 | 607 | { |
608 | 608 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
609 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
609 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
610 | 610 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
611 | 611 | return $class; |
612 | 612 | } |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | $expr = preg_quote($expr, '/'); |
626 | 626 | $expr = str_replace('###', '(.*)', $expr); |
627 | 627 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
628 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
628 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
629 | 629 | return $matched; |
630 | 630 | } |
631 | 631 | |
@@ -662,9 +662,9 @@ discard block |
||
662 | 662 | if (count($parameters) > 0) foreach ($parameters as $param) { |
663 | 663 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
664 | 664 | $params[$param->getName()] = $param->getDefaultValue(); |
665 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
665 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
666 | 666 | } |
667 | - } else $default = $regex; |
|
667 | + }else $default = $regex; |
|
668 | 668 | |
669 | 669 | return array($regex, $default, $params); |
670 | 670 | } |
@@ -720,17 +720,17 @@ discard block |
||
720 | 720 | */ |
721 | 721 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
722 | 722 | { |
723 | - Logger::log('Executing route ' . $route); |
|
723 | + Logger::log('Executing route '.$route); |
|
724 | 724 | Security::getInstance()->setSessionKey("__CACHE__", $action); |
725 | 725 | $cache = Cache::needCache(); |
726 | 726 | $execute = TRUE; |
727 | 727 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
728 | 728 | $cacheDataName = $this->cache->getRequestCacheHash(); |
729 | - $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, |
|
730 | - $cache, function () {}); |
|
729 | + $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, |
|
730 | + $cache, function() {}); |
|
731 | 731 | if (NULL !== $cachedData) { |
732 | - $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", |
|
733 | - $cache, function () {}, Cache::JSON); |
|
732 | + $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", |
|
733 | + $cache, function() {}, Cache::JSON); |
|
734 | 734 | Template::getInstance()->renderCache($cachedData, $headers); |
735 | 735 | $execute = FALSE; |
736 | 736 | } |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | $translations = array(); |
777 | 777 | if (file_exists($absoluteTranslationFileName)) { |
778 | 778 | include($absoluteTranslationFileName); |
779 | - } else { |
|
779 | + }else { |
|
780 | 780 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
781 | 781 | } |
782 | 782 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | private function saveTextToFile($data, $path, $absolute = false) |
31 | 31 | { |
32 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
32 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
33 | 33 | $filename = basename($absolutePath); |
34 | 34 | Config::createDir(str_replace($filename, "", $absolutePath)); |
35 | 35 | if (false === file_put_contents($absolutePath, $data)) { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false) |
49 | 49 | { |
50 | 50 | $data = null; |
51 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
51 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
52 | 52 | if (file_exists($absolutePath)) { |
53 | 53 | $data = file_get_contents($absolutePath); |
54 | 54 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
66 | 66 | { |
67 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
67 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
68 | 68 | $lasModificationDate = filemtime($absolutePath); |
69 | 69 | return ($lasModificationDate + $expires <= time()); |
70 | 70 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | break; |
88 | 88 | case Cache::GZIP: |
89 | 89 | // TODO implementar |
90 | - if(function_exists('gzuncompress')) { |
|
90 | + if (function_exists('gzuncompress')) { |
|
91 | 91 | $data = gzuncompress($data); |
92 | 92 | } |
93 | 93 | break; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $data = Cache::transformData($data, Cache::GZIP); |
113 | 113 | break; |
114 | 114 | case Cache::GZIP: |
115 | - if(function_exists('gzcompress')) { |
|
115 | + if (function_exists('gzcompress')) { |
|
116 | 116 | $data = gzcompress($data); |
117 | 117 | } |
118 | 118 | break; |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT) |
145 | 145 | { |
146 | 146 | $data = null; |
147 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
147 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
148 | 148 | if (null !== $function && $this->hasExpiredCache($path, $expires)) { |
149 | 149 | $data = call_user_func($function); |
150 | 150 | $this->storeData($path, $data, $transform); |
151 | - } else { |
|
151 | + }else { |
|
152 | 152 | $data = $this->getDataFromFile($path, $transform); |
153 | 153 | } |
154 | 154 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $hash = ""; |
179 | 179 | $action = Security::getInstance()->getSessionKey("__CACHE__"); |
180 | 180 | if (null !== $action && $action["cache"] > 0) { |
181 | - $hash = $action["http"] . " " . $action["slug"]; |
|
181 | + $hash = $action["http"]." ".$action["slug"]; |
|
182 | 182 | } |
183 | 183 | return sha1($hash); |
184 | 184 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | if (!preg_match('/^\@ROOT/i', $domain)) { |
35 | 35 | $modules[] = str_replace('/', '', str_replace('@', '', $domain)); |
36 | 36 | } |
37 | - } catch (\Exception $e) { |
|
37 | + }catch (\Exception $e) { |
|
38 | 38 | $modules[] = $e->getMessage(); |
39 | 39 | } |
40 | 40 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function extractApiEndpoints($module) |
54 | 54 | { |
55 | - $module_path = CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Api"; |
|
55 | + $module_path = CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Api"; |
|
56 | 56 | $endpoints = []; |
57 | 57 | if (file_exists($module_path)) { |
58 | 58 | $finder = new Finder(); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if (count($finder)) { |
61 | 61 | /** @var \SplFileInfo $file */ |
62 | 62 | foreach ($finder as $file) { |
63 | - $namespace = "\\{$module}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
63 | + $namespace = "\\{$module}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
64 | 64 | $endpoints[$namespace] = $this->extractApiInfo($namespace); |
65 | 65 | } |
66 | 66 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | if (NULL !== $mInfo) { |
90 | 90 | $info[] = $mInfo; |
91 | 91 | } |
92 | - } catch (\Exception $e) { |
|
92 | + }catch (\Exception $e) { |
|
93 | 93 | Logger::getInstance()->errorLog($e->getMessage()); |
94 | 94 | } |
95 | 95 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | protected function extractReturn($model, $comments = '') |
238 | 238 | { |
239 | - $modelDto = []; |
|
239 | + $modelDto = []; |
|
240 | 240 | preg_match('/\@return\ (.*)\((.*)\)\n/i', $comments, $returnTypes); |
241 | 241 | if (count($returnTypes)) { |
242 | 242 | // Extract principal DTO information |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
290 | 290 | $payload = $this->extractDtoProperties($namespace); |
291 | 291 | } |
292 | - } catch (\Exception $e) { |
|
292 | + }catch (\Exception $e) { |
|
293 | 293 | Logger::getInstance()->errorLog($e->getMessage()); |
294 | 294 | } |
295 | 295 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | if (in_array($methodInfo['method'], ['POST', 'PUT'])) { |
326 | 326 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); |
327 | 327 | } |
328 | - } catch (\Exception $e) { |
|
328 | + }catch (\Exception $e) { |
|
329 | 329 | jpre($e->getMessage()); |
330 | 330 | Logger::getInstance()->errorLog($e->getMessage()); |
331 | 331 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public static function translateSwaggerFormats($format) |
345 | 345 | { |
346 | - switch(strtolower($format)) { |
|
346 | + switch (strtolower($format)) { |
|
347 | 347 | case 'bool': |
348 | 348 | case 'boolean': |
349 | 349 | $swaggerType = 'boolean'; |
@@ -404,13 +404,13 @@ discard block |
||
404 | 404 | ]]); |
405 | 405 | if (array_key_exists($subDtoName, $subDto)) { |
406 | 406 | $definitions = $subDto; |
407 | - } else { |
|
407 | + }else { |
|
408 | 408 | $definitions[$subDtoName] = $subDto; |
409 | 409 | } |
410 | 410 | $dto['properties'][$field] = [ |
411 | - '$ref' => "#/definitions/" . $subDtoName, |
|
411 | + '$ref' => "#/definitions/".$subDtoName, |
|
412 | 412 | ]; |
413 | - } else { |
|
413 | + }else { |
|
414 | 414 | list($type, $format) = self::translateSwaggerFormats($format); |
415 | 415 | $dto['properties'][$field] = [ |
416 | 416 | "type" => $type, |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | "url" => Router::getInstance()->getRoute(''), |
448 | 448 | ] |
449 | 449 | ]; |
450 | - foreach($endpoints as $model) { |
|
450 | + foreach ($endpoints as $model) { |
|
451 | 451 | foreach ($model as $endpoint) { |
452 | 452 | $dtos += self::extractSwaggerDefinition($endpoint); |
453 | 453 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | protected function extractDtoName($dto, $isArray = false) |
467 | 467 | { |
468 | 468 | $dto = explode('\\', $dto); |
469 | - $modelDto = array_pop($dto) . "Dto"; |
|
469 | + $modelDto = array_pop($dto)."Dto"; |
|
470 | 470 | if ($isArray) { |
471 | 471 | $modelDto .= "List"; |
472 | 472 | } |