@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $platform = trim(Config::getInstance()->get('platform.name', 'PSFS')); |
38 | 38 | ResponseHelper::setHeader('HTTP/1.1 401 Unauthorized'); |
39 | - ResponseHelper::setHeader('WWW-Authenticate: Basic Realm="' . $platform . '"'); |
|
39 | + ResponseHelper::setHeader('WWW-Authenticate: Basic Realm="'.$platform.'"'); |
|
40 | 40 | echo t('Zona restringida'); |
41 | 41 | exit(); |
42 | 42 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $admin['class'] = 'primary'; |
79 | 79 | break; |
80 | 80 | } |
81 | - } else { |
|
81 | + }else { |
|
82 | 82 | $admin['class'] = 'primary'; |
83 | 83 | } |
84 | 84 | } |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | |
14 | 14 | public static function handleEvents(string $eventName, mixed $context = null): void |
15 | 15 | { |
16 | - if(array_key_exists($eventName, self::$events)) { |
|
17 | - foreach(self::$events[$eventName] as $eventClass) { |
|
16 | + if (array_key_exists($eventName, self::$events)) { |
|
17 | + foreach (self::$events[$eventName] as $eventClass) { |
|
18 | 18 | try { |
19 | 19 | $return = (new $eventClass)($context); |
20 | 20 | Logger::log("$eventClass event handled with return $return"); |
21 | - } catch (\Exception $exception) { |
|
22 | - Logger::log("$eventClass event handled with exception:" . $exception->getMessage(), LOG_CRIT); |
|
21 | + }catch (\Exception $exception) { |
|
22 | + Logger::log("$eventClass event handled with exception:".$exception->getMessage(), LOG_CRIT); |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public static function addEvent(string $eventName, string $eventClass): void |
29 | 29 | { |
30 | - if(!array_key_exists($eventName, self::$events)) { |
|
30 | + if (!array_key_exists($eventName, self::$events)) { |
|
31 | 31 | self::$events[$eventName] = []; |
32 | 32 | } |
33 | 33 | self::$events[$eventName][] = $eventClass; |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | if (!headers_sent()) { |
51 | 51 | // TODO include this headers in Template class output method |
52 | 52 | ResponseHelper::setHeader('Access-Control-Allow-Credentials: true'); |
53 | - ResponseHelper::setHeader('Access-Control-Allow-Origin: ' . Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
53 | + ResponseHelper::setHeader('Access-Control-Allow-Origin: '.Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
54 | 54 | ResponseHelper::setHeader('Vary: Origin'); |
55 | 55 | ResponseHelper::setHeader('Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS, HEAD'); |
56 | - ResponseHelper::setHeader('Access-Control-Allow-Headers: ' . implode(', ', self::getCorsHeaders())); |
|
56 | + ResponseHelper::setHeader('Access-Control-Allow-Headers: '.implode(', ', self::getCorsHeaders())); |
|
57 | 57 | } |
58 | 58 | if (Request::getInstance()->getMethod() === Request::VERB_OPTIONS) { |
59 | 59 | Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | return $ip; |
87 | 87 | } |
88 | 88 | } |
89 | - } else { |
|
89 | + }else { |
|
90 | 90 | if (self::validateIpAddress($xForwardedFor)) { |
91 | 91 | return $xForwardedFor; |
92 | 92 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | // Verifica si la IP está en el rango válido |
127 | 127 | if ($ipNum >= $rangoInicioNum && $ipNum <= $rangoFinNum) { |
128 | 128 | return true; // La IP está en el rango válido |
129 | - } else { |
|
129 | + }else { |
|
130 | 130 | return false; // La IP está fuera del rango válido |
131 | 131 | } |
132 | 132 | } |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | foreach ($data as $key => $value) { |
30 | 30 | try { |
31 | 31 | $realValue = $model->getByName($key); |
32 | - } catch (\Exception $e) { |
|
32 | + }catch (\Exception $e) { |
|
33 | 33 | $realValue = $value; |
34 | 34 | } |
35 | 35 | if (Api::API_MODEL_KEY_FIELD === $key) { |
36 | 36 | $result[$key] = (integer)$realValue; |
37 | - } else { |
|
37 | + }else { |
|
38 | 38 | $result[$key] = $realValue; |
39 | 39 | } |
40 | 40 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return array |
50 | 50 | * @throws \Propel\Runtime\Exception\PropelException |
51 | 51 | */ |
52 | - public static function mapArrayObject($namespace, ColumnMap $modelPk, array $query, array|ActiveRecordInterface $data = []) |
|
52 | + public static function mapArrayObject($namespace, ColumnMap $modelPk, array $query, array | ActiveRecordInterface $data = []) |
|
53 | 53 | { |
54 | 54 | $formatter = new ObjectFormatter(); |
55 | 55 | $formatter->setClass($namespace); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | /** @var ActiveRecordInterface $obj */ |
68 | 68 | $obj = @$formatter->getAllObjectsFromRow($objData); |
69 | 69 | $result = self::mapResult($obj, $data); |
70 | - if (!preg_match('/' . $modelPk->getPhpName() . '/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
70 | + if (!preg_match('/'.$modelPk->getPhpName().'/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
71 | 71 | unset($result[$modelPk->getPhpName()]); |
72 | 72 | } |
73 | 73 | return $result; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | protected function hydrateOrders() |
40 | 40 | { |
41 | 41 | if (count($this->query)) { |
42 | - Logger::log(static::class . ' gathering query string', LOG_DEBUG); |
|
42 | + Logger::log(static::class.' gathering query string', LOG_DEBUG); |
|
43 | 43 | foreach ($this->query as $key => $value) { |
44 | 44 | if ($key === self::API_ORDER_FIELD) { |
45 | 45 | $orders = json_decode($value, true); |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | */ |
58 | 58 | protected function extractPagination() |
59 | 59 | { |
60 | - Logger::log(static::class . ' extract pagination start', LOG_DEBUG); |
|
60 | + Logger::log(static::class.' extract pagination start', LOG_DEBUG); |
|
61 | 61 | $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1; |
62 | 62 | $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100; |
63 | - Logger::log(static::class . ' extract pagination end', LOG_DEBUG); |
|
63 | + Logger::log(static::class.' extract pagination end', LOG_DEBUG); |
|
64 | 64 | return array($page, (int)$limit); |
65 | 65 | } |
66 | 66 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @param ModelCriteria $query |
70 | 70 | * @throws \PSFS\base\exception\ApiException |
71 | 71 | */ |
72 | - protected function addOrders(ModelCriteria &$query) |
|
72 | + protected function addOrders(ModelCriteria & $query) |
|
73 | 73 | { |
74 | - Logger::log(static::class . ' extract orders start ', LOG_DEBUG); |
|
74 | + Logger::log(static::class.' extract orders start ', LOG_DEBUG); |
|
75 | 75 | $orderAdded = FALSE; |
76 | 76 | $tableMap = $this->getTableMap(); |
77 | 77 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $orderAdded = TRUE; |
80 | 80 | if ($direction === Order::ASC) { |
81 | 81 | $query->addAscendingOrderByColumn($column->getPhpName()); |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | $query->addDescendingOrderByColumn($column->getPhpName()); |
84 | 84 | } |
85 | 85 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $query->addAscendingOrderByColumn($key); |
91 | 91 | } |
92 | 92 | } |
93 | - Logger::log(static::class . ' extract orders end', LOG_DEBUG); |
|
93 | + Logger::log(static::class.' extract orders end', LOG_DEBUG); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @param ModelCriteria $query |
100 | 100 | */ |
101 | - protected function addFilters(ModelCriteria &$query) |
|
101 | + protected function addFilters(ModelCriteria & $query) |
|
102 | 102 | { |
103 | 103 | if (count($this->query) > 0) { |
104 | 104 | $tableMap = $this->getTableMap(); |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | $this->checkReturnFields($query); |
127 | 127 | if ($limit === -1) { |
128 | 128 | $this->list = $query->find($this->con); |
129 | - } else { |
|
129 | + }else { |
|
130 | 130 | $this->list = $query->paginate($page, $limit, $this->con); |
131 | 131 | } |
132 | - } catch (\Exception $e) { |
|
132 | + }catch (\Exception $e) { |
|
133 | 133 | Logger::log($e->getMessage(), LOG_ERR); |
134 | 134 | } |
135 | 135 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | $header = null; |
138 | 138 | if ($this->hasHeader($name)) { |
139 | 139 | $header = $this->header[$name]; |
140 | - } else if (array_key_exists('h_' . strtolower($name), $this->query)) { |
|
141 | - $header = $this->query['h_' . strtolower($name)]; |
|
142 | - } else if (array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
143 | - $header = $this->getServer('HTTP_' . strtoupper(str_replace('-', '_', $name))); |
|
140 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
141 | + $header = $this->query['h_'.strtolower($name)]; |
|
142 | + }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
143 | + $header = $this->getServer('HTTP_'.strtoupper(str_replace('-', '_', $name))); |
|
144 | 144 | } |
145 | 145 | return $header ?: $default; |
146 | 146 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $url = $this->getServer('HTTP_ORIGIN'); |
255 | 255 | } |
256 | 256 | ob_start(); |
257 | - header('Location: ' . $url); |
|
257 | + header('Location: '.$url); |
|
258 | 258 | ob_end_clean(); |
259 | 259 | Security::getInstance()->updateSession(); |
260 | 260 | exit(t('Redirect...')); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $url = $this->getServerName(); |
271 | 271 | $protocol = $hasProtocol ? $this->getProtocol() : '//'; |
272 | 272 | if (!empty($protocol)) { |
273 | - $url = $protocol . $url; |
|
273 | + $url = $protocol.$url; |
|
274 | 274 | } |
275 | 275 | return $this->checkServerPort($url); |
276 | 276 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | } |
293 | 293 | if (!in_array($port, [80, 443], true)) { |
294 | - $url .= ':' . $port; |
|
294 | + $url .= ':'.$port; |
|
295 | 295 | } |
296 | 296 | return $url; |
297 | 297 | } |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | |
47 | 47 | $filePath = $returnPath = ''; |
48 | 48 | if (!file_exists($filePath)) { |
49 | - $filePath = BASE_DIR . $string; |
|
49 | + $filePath = BASE_DIR.$string; |
|
50 | 50 | } |
51 | 51 | $filenamePath = AssetsHelper::findDomainPath($string, $filePath); |
52 | - if(!empty($filenamePath)){ |
|
52 | + if (!empty($filenamePath)) { |
|
53 | 53 | $filePath = self::processAsset($string, $name, $return, $filenamePath); |
54 | 54 | $basePath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl(false)); |
55 | - $returnPath = empty($name) ? $basePath . '/' . $filePath : $name; |
|
55 | + $returnPath = empty($name) ? $basePath.'/'.$filePath : $name; |
|
56 | 56 | } |
57 | 57 | return $return ? $returnPath : ''; |
58 | 58 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $router = Router::getInstance(); |
71 | 71 | try { |
72 | 72 | return $router->getRoute($path, $absolute, $params); |
73 | - } catch (\Exception $e) { |
|
73 | + }catch (\Exception $e) { |
|
74 | 74 | Logger::log($e->getMessage()); |
75 | 75 | return $router->getRoute('', $absolute, $params); |
76 | 76 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $filenamePath = self::extractPathname($path, $domains); |
167 | 167 | // Check if resources has been copied to public folders |
168 | 168 | if (!$debug) { |
169 | - $cacheFilename = Config::getParam('cache.var', '__initial__') . '.file.cache'; |
|
169 | + $cacheFilename = Config::getParam('cache.var', '__initial__').'.file.cache'; |
|
170 | 170 | $cachedFiles = Cache::getInstance()->readFromCache($cacheFilename, |
171 | 171 | 1, fn() => [], Cache::JSON, true) ?: []; |
172 | 172 | // Force the resource copy |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string|array |
189 | 189 | */ |
190 | - private static function extractPathname(string $path, $domains): string|array |
|
190 | + private static function extractPathname(string $path, $domains): string | array |
|
191 | 191 | { |
192 | 192 | $filenamePath = $path; |
193 | 193 | if (!empty($domains) && !file_exists($path)) { |
@@ -226,13 +226,13 @@ discard block |
||
226 | 226 | * @param string $base |
227 | 227 | * @param string $filePath |
228 | 228 | */ |
229 | - private static function putResourceContent(string|null $name, string $filenamePath, string $base, string $filePath): void |
|
229 | + private static function putResourceContent(string | null $name, string $filenamePath, string $base, string $filePath): void |
|
230 | 230 | { |
231 | 231 | $data = file_get_contents($filenamePath); |
232 | 232 | if (!empty($name)) { |
233 | - file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
234 | - } else { |
|
235 | - file_put_contents($base . $filePath, $data); |
|
233 | + file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
234 | + }else { |
|
235 | + file_put_contents($base.$filePath, $data); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
@@ -245,15 +245,15 @@ discard block |
||
245 | 245 | * @return string |
246 | 246 | * @throws GeneratorException |
247 | 247 | */ |
248 | - private static function processAsset(string $string, string|null $name = null, bool $return = true, string $filenamePath = ''): string |
|
248 | + private static function processAsset(string $string, string | null $name = null, bool $return = true, string $filenamePath = ''): string |
|
249 | 249 | { |
250 | 250 | $filePath = $filenamePath; |
251 | 251 | if (file_exists($filenamePath)) { |
252 | 252 | list($base, $htmlBase, $filePath) = AssetsHelper::calculateAssetPath($string, $name, $return, $filenamePath); |
253 | 253 | //Creamos el directorio si no existe |
254 | - GeneratorHelper::createDir($base . $htmlBase); |
|
254 | + GeneratorHelper::createDir($base.$htmlBase); |
|
255 | 255 | //Si se ha modificado |
256 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($filenamePath)) { |
|
256 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($filenamePath)) { |
|
257 | 257 | if ($htmlBase === 'css') { |
258 | 258 | self::processCssLines($filenamePath); |
259 | 259 | } |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | public static array $headers_sent = []; |
21 | 21 | |
22 | 22 | public static function setHeader(string $header): void { |
23 | - if(str_contains($header, ':')) { |
|
23 | + if (str_contains($header, ':')) { |
|
24 | 24 | list($key, $value) = explode(':', $header); |
25 | - } else { |
|
25 | + }else { |
|
26 | 26 | $key = 'Http Status'; |
27 | 27 | $value = $header; |
28 | 28 | } |
29 | 29 | if (!in_array($key, self::$headers_sent)) { |
30 | - if(!self::isTest()) { |
|
30 | + if (!self::isTest()) { |
|
31 | 31 | header($header); |
32 | 32 | } |
33 | 33 | self::$headers_sent[$key] = $value; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | Logger::log('Adding debug headers to render response'); |
100 | 100 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
101 | 101 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
102 | - self::setHeader('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
103 | - self::setHeader('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
104 | - self::setHeader('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
102 | + self::setHeader('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
103 | + self::setHeader('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
104 | + self::setHeader('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $vars; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @return int|string |
114 | 114 | * @throws GeneratorException |
115 | 115 | */ |
116 | - public static function httpNotFound(Exception $exception = NULL, bool $isJson = false): int|string |
|
116 | + public static function httpNotFound(Exception $exception = NULL, bool $isJson = false): int | string |
|
117 | 117 | { |
118 | 118 | if (self::isTest()) { |
119 | 119 | return 404; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $notFoundRoute = Config::getParam('route.404'); |
133 | 133 | if (null !== $notFoundRoute) { |
134 | 134 | Request::getInstance()->redirect(Router::getInstance()->getRoute($notFoundRoute, true)); |
135 | - } else { |
|
135 | + }else { |
|
136 | 136 | return $template->render('error.html.twig', array( |
137 | 137 | 'exception' => $exception, |
138 | 138 | 'trace' => $exception->getTraceAsString(), |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function init() |
64 | 64 | { |
65 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
66 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
65 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
66 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
67 | 67 | if (empty($this->routing) || Config::getParam('debug', true)) { |
68 | 68 | $this->debugLoad(); |
69 | 69 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $this->hydrateRouting(); |
85 | 85 | $this->simpatize(); |
86 | 86 | Logger::log('End routes load'); |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | Logger::log('Routes generation skipped'); |
89 | 89 | } |
90 | 90 | } |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | try { |
102 | 102 | //Search action and execute |
103 | 103 | return $this->searchAction($route); |
104 | - } catch (AccessDeniedException $e) { |
|
105 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
104 | + }catch (AccessDeniedException $e) { |
|
105 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
106 | 106 | return Admin::staticAdminLogon(); |
107 | - } catch (RouterException $r) { |
|
107 | + }catch (RouterException $r) { |
|
108 | 108 | Logger::log($r->getMessage(), LOG_WARNING); |
109 | 109 | $code = $r->getCode(); |
110 | - } catch (Exception $e) { |
|
110 | + }catch (Exception $e) { |
|
111 | 111 | Logger::log($e->getMessage(), LOG_ERR); |
112 | 112 | throw $e; |
113 | 113 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function searchAction($route) |
127 | 127 | { |
128 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
128 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
129 | 129 | //Revisamos si tenemos la ruta registrada |
130 | 130 | $parts = parse_url($route); |
131 | 131 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | throw new RouterException(t('Preconditions failed'), 412); |
148 | - } catch (Exception $e) { |
|
148 | + }catch (Exception $e) { |
|
149 | 149 | Logger::log($e->getMessage(), LOG_ERR); |
150 | 150 | throw $e; |
151 | 151 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | } |
172 | 172 | $valid = count($action['requirements']) === $checked; |
173 | - } else { |
|
173 | + }else { |
|
174 | 174 | $valid = true; |
175 | 175 | } |
176 | 176 | return $valid; |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | if ($modules->hasResults()) { |
194 | 194 | foreach ($modules->getIterator() as $modulePath) { |
195 | 195 | $module = $modulePath->getBasename(); |
196 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
196 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |
200 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
200 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $homeParams = NULL; |
215 | 215 | foreach ($this->routing as $pattern => $params) { |
216 | 216 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
217 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
217 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
218 | 218 | $homeParams = $params; |
219 | 219 | } |
220 | 220 | unset($method); |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | { |
247 | 247 | $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : ''; |
248 | 248 | if ('' === $slug) { |
249 | - return $baseUrl . '/'; |
|
249 | + return $baseUrl.'/'; |
|
250 | 250 | } |
251 | 251 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
252 | 252 | throw new RouterException(t('No existe la ruta especificada')); |
253 | 253 | } |
254 | - $url = $baseUrl . $this->slugs[$slug]; |
|
254 | + $url = $baseUrl.$this->slugs[$slug]; |
|
255 | 255 | if (!empty($params)) { |
256 | 256 | foreach ($params as $key => $value) { |
257 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
257 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
258 | 258 | } |
259 | 259 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
260 | - $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default']; |
|
260 | + $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default']; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | if ($this->hasToRunPreChecks($class)) { |
273 | 273 | self::run($class, '__check', true); |
274 | 274 | } |
275 | - $preAction = 'pre' . ucfirst($method); |
|
275 | + $preAction = 'pre'.ucfirst($method); |
|
276 | 276 | if (method_exists($class, $preAction)) { |
277 | 277 | self::run($class, $preAction); |
278 | 278 | } |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public static function run($class, $method, $throwExceptions = false): void |
289 | 289 | { |
290 | - Inspector::stats("[Router] Pre action invoked " . get_class($class) . "::{$method}", Inspector::SCOPE_DEBUG); |
|
290 | + Inspector::stats("[Router] Pre action invoked ".get_class($class)."::{$method}", Inspector::SCOPE_DEBUG); |
|
291 | 291 | try { |
292 | 292 | if (false === call_user_func_array([$class, $method], [])) { |
293 | - Logger::log(t("[Router] action " . get_class($class) . "::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
293 | + Logger::log(t("[Router] action ".get_class($class)."::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
294 | 294 | error_clear_last(); |
295 | 295 | } |
296 | - } catch (Exception $e) { |
|
296 | + }catch (Exception $e) { |
|
297 | 297 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
298 | 298 | if ($throwExceptions) { |
299 | 299 | throw $e; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
324 | 324 | { |
325 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
325 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
326 | 326 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
327 | 327 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
328 | 328 | $cache = Cache::needCache(); |
@@ -330,15 +330,15 @@ discard block |
||
330 | 330 | $return = null; |
331 | 331 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
332 | 332 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
333 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
333 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
334 | 334 | if (NULL !== $cachedData) { |
335 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
335 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
336 | 336 | Template::getInstance()->renderCache($cachedData, $headers); |
337 | 337 | $execute = FALSE; |
338 | 338 | } |
339 | 339 | } |
340 | 340 | if ($execute) { |
341 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
341 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
342 | 342 | $this->checkPreActions($class, $action['method']); |
343 | 343 | $return = call_user_func_array([$class, $action['method']], $params); |
344 | 344 | if (false === $return) { |