@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | if ($files->hasResults()) { |
55 | 55 | foreach ($files->getIterator() as $file) { |
56 | 56 | if ($namespace !== Router::PSFS_BASE_NAMESPACE && method_exists($file, 'getRelativePathname')) { |
57 | - $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
58 | - } else { |
|
57 | + $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
58 | + }else { |
|
59 | 59 | $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname())); |
60 | 60 | } |
61 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
61 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | $this->initializeFinder(); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | if (!is_array($this->domains)) { |
112 | 112 | $this->domains = []; |
113 | 113 | } |
114 | - $domain = '@' . $class->getConstant('DOMAIN') . '/'; |
|
114 | + $domain = '@'.$class->getConstant('DOMAIN').'/'; |
|
115 | 115 | if (!array_key_exists($domain, $this->domains)) { |
116 | 116 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
117 | 117 | } |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath, &$routing = []) |
139 | 139 | { |
140 | 140 | $extModule = $modulePath->getBasename(); |
141 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
141 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
142 | 142 | if (file_exists($moduleAutoloader)) { |
143 | 143 | include_once $moduleAutoloader; |
144 | 144 | if ($hydrateRoute) { |
145 | - $routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $routing); |
|
145 | + $routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $routing); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } |
@@ -158,18 +158,18 @@ discard block |
||
158 | 158 | $modulesToIgnore = explode(',', Config::getParam('hide.modules', '')); |
159 | 159 | try { |
160 | 160 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
161 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
161 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
162 | 162 | if (file_exists($externalModulePath)) { |
163 | 163 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
164 | 164 | if ($externalModule->hasResults()) { |
165 | 165 | foreach ($externalModule->getIterator() as $modulePath) { |
166 | - if(!in_array(strtoupper($modulePath->getRelativePathname()), $modulesToIgnore)) { |
|
166 | + if (!in_array(strtoupper($modulePath->getRelativePathname()), $modulesToIgnore)) { |
|
167 | 167 | $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath, $routing); |
168 | 168 | } |
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
172 | - } catch (Exception $e) { |
|
172 | + }catch (Exception $e) { |
|
173 | 173 | Logger::log($e->getMessage(), LOG_WARNING); |
174 | 174 | } |
175 | 175 | } |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | public function domainExists($domainToCheck) { |
182 | 182 | $exists = false; |
183 | 183 | $domains = array_keys($this->getDomains()); |
184 | - foreach($domains as $domain) { |
|
184 | + foreach ($domains as $domain) { |
|
185 | 185 | $cleanDomain = strtolower(str_replace(['@', '/', '\\'], '', $domain)); |
186 | - if($cleanDomain === strtolower($domainToCheck)) { |
|
186 | + if ($cleanDomain === strtolower($domainToCheck)) { |
|
187 | 187 | $exists = true; |
188 | 188 | break; |
189 | 189 | } |
@@ -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 | } |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function debugLoad() |
81 | 81 | { |
82 | - if(!Config::getParam('skip.route_generation', false)) { |
|
82 | + if (!Config::getParam('skip.route_generation', false)) { |
|
83 | 83 | Logger::log('Begin routes load'); |
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); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | private function checkPreActions($class, $method) |
271 | 271 | { |
272 | - $preAction = 'pre' . ucfirst($method); |
|
272 | + $preAction = 'pre'.ucfirst($method); |
|
273 | 273 | if (method_exists($class, $preAction)) { |
274 | 274 | Inspector::stats('[Router] Pre action invoked', Inspector::SCOPE_DEBUG); |
275 | 275 | try { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]); |
278 | 278 | error_clear_last(); |
279 | 279 | } |
280 | - } catch (Exception $e) { |
|
280 | + }catch (Exception $e) { |
|
281 | 281 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
282 | 282 | } |
283 | 283 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
296 | 296 | { |
297 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
297 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
298 | 298 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
299 | 299 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
300 | 300 | $cache = Cache::needCache(); |
@@ -302,15 +302,15 @@ discard block |
||
302 | 302 | $return = null; |
303 | 303 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
304 | 304 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
305 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
305 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
306 | 306 | if (NULL !== $cachedData) { |
307 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
307 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
308 | 308 | Template::getInstance()->renderCache($cachedData, $headers); |
309 | 309 | $execute = FALSE; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | if ($execute) { |
313 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
313 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
314 | 314 | $this->checkPreActions($class, $action['method']); |
315 | 315 | $return = call_user_func_array([$class, $action['method']], $params); |
316 | 316 | if (false === $return) { |