@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | if (str_contains($header, ':')) { |
25 | 25 | list($key, $value) = explode(':', $header); |
26 | - } else { |
|
26 | + }else { |
|
27 | 27 | $key = 'Http Status'; |
28 | 28 | $value = $header; |
29 | 29 | } |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | Logger::log('Adding debug headers to render response'); |
102 | 102 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
103 | 103 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
104 | - self::setHeader('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
105 | - self::setHeader('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
106 | - self::setHeader('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
104 | + self::setHeader('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
105 | + self::setHeader('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
106 | + self::setHeader('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | return $vars; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return int|string |
116 | 116 | * @throws GeneratorException |
117 | 117 | */ |
118 | - public static function httpNotFound(\Throwable $exception = null, bool $isJson = false): int|string |
|
118 | + public static function httpNotFound(\Throwable $exception = null, bool $isJson = false): int | string |
|
119 | 119 | { |
120 | 120 | if (self::isTest()) { |
121 | 121 | return 404; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $notFoundRoute = Config::getParam('route.404'); |
135 | 135 | if (null !== $notFoundRoute) { |
136 | 136 | Request::getInstance()->redirect(Router::getInstance()->getRoute($notFoundRoute, true)); |
137 | - } else { |
|
137 | + }else { |
|
138 | 138 | return $template->render('error.html.twig', array( |
139 | 139 | 'exception' => $exception, |
140 | 140 | 'trace' => $exception->getTraceAsString(), |
@@ -32,13 +32,13 @@ |
||
32 | 32 | { |
33 | 33 | $namespace = explode('\\', $this->getModelTableMap()); |
34 | 34 | $module = strtolower($namespace[0]); |
35 | - $secret = Config::getInstance()->get($module . '.api.secret'); |
|
35 | + $secret = Config::getInstance()->get($module.'.api.secret'); |
|
36 | 36 | if (null === $secret) { |
37 | 37 | $secret = Config::getInstance()->get("api.secret"); |
38 | 38 | } |
39 | 39 | if (null === $secret) { |
40 | 40 | $auth = true; |
41 | - } else { |
|
41 | + }else { |
|
42 | 42 | $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN'); |
43 | 43 | if (array_key_exists('API_TOKEN', $this->query)) { |
44 | 44 | $token = $this->query['API_TOKEN']; |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function init() |
66 | 66 | { |
67 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, true); |
|
68 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, true); |
|
67 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, true); |
|
68 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, true); |
|
69 | 69 | if (empty($this->routing) || Config::getParam('debug', true)) { |
70 | 70 | $this->debugLoad(); |
71 | 71 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $this->hydrateRouting(); |
87 | 87 | $this->simpatize(); |
88 | 88 | Logger::log('End routes load'); |
89 | - } else { |
|
89 | + }else { |
|
90 | 90 | Logger::log('Routes generation skipped'); |
91 | 91 | } |
92 | 92 | } |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | try { |
104 | 104 | //Search action and execute |
105 | 105 | return $this->searchAction($route); |
106 | - } catch (AccessDeniedException $e) { |
|
107 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
106 | + }catch (AccessDeniedException $e) { |
|
107 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
108 | 108 | return Admin::staticAdminLogon(); |
109 | - } catch (RouterException $r) { |
|
109 | + }catch (RouterException $r) { |
|
110 | 110 | Logger::log($r->getMessage(), LOG_WARNING); |
111 | 111 | $code = $r->getCode(); |
112 | - } catch (Exception $e) { |
|
112 | + }catch (Exception $e) { |
|
113 | 113 | Logger::log($e->getMessage(), LOG_ERR); |
114 | 114 | throw $e; |
115 | 115 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function searchAction($route) |
129 | 129 | { |
130 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
130 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
131 | 131 | //Revisamos si tenemos la ruta registrada |
132 | 132 | $parts = parse_url($route); |
133 | 133 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | throw new RouterException(t('Preconditions failed'), 412); |
151 | - } catch (Exception $e) { |
|
151 | + }catch (Exception $e) { |
|
152 | 152 | Logger::log($e->getMessage(), LOG_ERR); |
153 | 153 | throw $e; |
154 | 154 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | } |
175 | 175 | $valid = count($action['requirements']) === $checked; |
176 | - } else { |
|
176 | + }else { |
|
177 | 177 | $valid = true; |
178 | 178 | } |
179 | 179 | return $valid; |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | if ($modules->hasResults()) { |
197 | 197 | foreach ($modules->getIterator() as $modulePath) { |
198 | 198 | $module = $modulePath->getBasename(); |
199 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
199 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
203 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, true); |
|
203 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, true); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $homeParams = null; |
218 | 218 | foreach ($this->routing as $pattern => $params) { |
219 | 219 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
220 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
220 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
221 | 221 | $homeParams = $params; |
222 | 222 | } |
223 | 223 | unset($method); |
@@ -249,18 +249,18 @@ discard block |
||
249 | 249 | { |
250 | 250 | $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : ''; |
251 | 251 | if ('' === $slug) { |
252 | - return $baseUrl . '/'; |
|
252 | + return $baseUrl.'/'; |
|
253 | 253 | } |
254 | 254 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
255 | 255 | throw new RouterException(t('No existe la ruta especificada')); |
256 | 256 | } |
257 | - $url = $baseUrl . $this->slugs[$slug]; |
|
257 | + $url = $baseUrl.$this->slugs[$slug]; |
|
258 | 258 | if (!empty($params)) { |
259 | 259 | foreach ($params as $key => $value) { |
260 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
260 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
261 | 261 | } |
262 | 262 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
263 | - $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default']; |
|
263 | + $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default']; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | if ($this->hasToRunPreChecks($class)) { |
276 | 276 | self::run($class, '__check', true); |
277 | 277 | } |
278 | - $preAction = 'pre' . ucfirst($method); |
|
278 | + $preAction = 'pre'.ucfirst($method); |
|
279 | 279 | if (method_exists($class, $preAction)) { |
280 | 280 | self::run($class, $preAction); |
281 | 281 | } |
@@ -290,13 +290,13 @@ discard block |
||
290 | 290 | */ |
291 | 291 | public static function run($class, $method, $throwExceptions = false): void |
292 | 292 | { |
293 | - Inspector::stats("[Router] Pre action invoked " . get_class($class) . "::{$method}", Inspector::SCOPE_DEBUG); |
|
293 | + Inspector::stats("[Router] Pre action invoked ".get_class($class)."::{$method}", Inspector::SCOPE_DEBUG); |
|
294 | 294 | try { |
295 | 295 | if (false === call_user_func_array([$class, $method], [])) { |
296 | - Logger::log(t("[Router] action " . get_class($class) . "::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
296 | + Logger::log(t("[Router] action ".get_class($class)."::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
297 | 297 | error_clear_last(); |
298 | 298 | } |
299 | - } catch (Exception $e) { |
|
299 | + }catch (Exception $e) { |
|
300 | 300 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
301 | 301 | if ($throwExceptions) { |
302 | 302 | throw $e; |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | */ |
326 | 326 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
327 | 327 | { |
328 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
328 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
329 | 329 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
330 | 330 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
331 | 331 | $cache = Cache::needCache(); |
@@ -333,15 +333,15 @@ discard block |
||
333 | 333 | $return = null; |
334 | 334 | if (false !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === false) { |
335 | 335 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
336 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
336 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
337 | 337 | if (NULL !== $cachedData) { |
338 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
338 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
339 | 339 | Template::getInstance()->renderCache($cachedData, $headers); |
340 | 340 | $execute = false; |
341 | 341 | } |
342 | 342 | } |
343 | 343 | if ($execute) { |
344 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
344 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
345 | 345 | $this->checkPreActions($class, $action['method']); |
346 | 346 | $return = call_user_func_array([$class, $action['method']], $params); |
347 | 347 | if (false === $return) { |
@@ -85,18 +85,18 @@ |
||
85 | 85 | if (!Request::getInstance()->isFile()) { |
86 | 86 | return $this->router->execute($uri ?? $this->actualUri); |
87 | 87 | } |
88 | - } else { |
|
88 | + }else { |
|
89 | 89 | return ConfigController::getInstance()->config(); |
90 | 90 | } |
91 | - } catch (AdminCredentialsException $a) { |
|
91 | + }catch (AdminCredentialsException $a) { |
|
92 | 92 | return UserController::showAdminManager(); |
93 | - } catch (SecurityException $s) { |
|
93 | + }catch (SecurityException $s) { |
|
94 | 94 | return $this->security->notAuthorized($this->actualUri); |
95 | - } catch (RouterException $r) { |
|
95 | + }catch (RouterException $r) { |
|
96 | 96 | return $this->router->httpNotFound($r); |
97 | - } catch (ApiException $a) { |
|
97 | + }catch (ApiException $a) { |
|
98 | 98 | return $this->router->httpNotFound($a, true); |
99 | - } catch (\Exception $e) { |
|
99 | + }catch (\Exception $e) { |
|
100 | 100 | return $this->handleException($e); |
101 | 101 | } |
102 | 102 |