@@ -135,9 +135,11 @@ |
||
135 | 135 | $cacheService->storeData($cacheFilename, $properties, Cache::JSON); |
136 | 136 | } |
137 | 137 | /** @var \ReflectionProperty $property */ |
138 | - if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { |
|
138 | + if (!empty($properties) && is_array($properties)) { |
|
139 | + foreach ($properties as $property => $class) { |
|
139 | 140 | $this->load($property, true, $class); |
140 | 141 | } |
142 | + } |
|
141 | 143 | $this->setLoaded(); |
142 | 144 | } else { |
143 | 145 | Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - Logger::log(get_class($this) . ' constructor invoked'); |
|
23 | + Logger::log(get_class($this).' constructor invoked'); |
|
24 | 24 | $this->init(); |
25 | 25 | } |
26 | 26 | |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | $calledClass = get_called_class(); |
91 | 91 | try { |
92 | 92 | $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
93 | - $setter = "set" . ucfirst($variable); |
|
93 | + $setter = "set".ucfirst($variable); |
|
94 | 94 | if (method_exists($calledClass, $setter)) { |
95 | 95 | $this->$setter($instance); |
96 | - } else { |
|
96 | + }else { |
|
97 | 97 | $this->$variable = $instance; |
98 | 98 | } |
99 | - } catch (\Exception $e) { |
|
100 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
99 | + }catch (\Exception $e) { |
|
100 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
101 | 101 | } |
102 | 102 | return $this; |
103 | 103 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | if (!$this->isLoaded()) { |
111 | 111 | $filename = sha1(get_class($this)); |
112 | - $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . ".json"; |
|
112 | + $cacheFilename = "reflections".DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.".json"; |
|
113 | 113 | /** @var \PSFS\base\Cache $cacheService */ |
114 | 114 | $cacheService = Cache::getInstance(); |
115 | 115 | /** @var \PSFS\base\config\Config $configService */ |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | $this->load($property, true, $class); |
125 | 125 | } |
126 | 126 | $this->setLoaded(); |
127 | - } else { |
|
128 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
127 | + }else { |
|
128 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
@@ -177,7 +177,7 @@ |
||
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 | /** |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * Add request param |
118 | 118 | * |
119 | - * @param $key |
|
119 | + * @param integer $key |
|
120 | 120 | * @param null $value |
121 | 121 | * |
122 | 122 | * @return \PSFS\base\Service |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | - * @param $header |
|
157 | - * @param null $content |
|
156 | + * @param string $header |
|
157 | + * @param string $content |
|
158 | 158 | * |
159 | 159 | * @return $this |
160 | 160 | */ |
@@ -21,11 +21,11 @@ |
||
21 | 21 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
22 | 22 | |
23 | 23 | // filepath |
24 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
24 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
25 | 25 | if (!file_exists($abs_path)) { |
26 | - pre('→ ' . $class); |
|
27 | - pre('→ ' . $path); |
|
28 | - pre('→ ' . $abs_path); |
|
26 | + pre('→ '.$class); |
|
27 | + pre('→ '.$path); |
|
28 | + pre('→ '.$abs_path); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // require the file |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Método que guarda en fichero los datos pasados |
124 | - * @param $path |
|
124 | + * @param string $path |
|
125 | 125 | * @param $data |
126 | 126 | * @param int $transform |
127 | 127 | * @param boolean $absolutePath |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Método estático que revisa si se necesita cachear la respuesta de un servicio o no |
159 | - * @return integer|boolean |
|
159 | + * @return integer |
|
160 | 160 | */ |
161 | 161 | public static function needCache() |
162 | 162 | { |
@@ -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 | GeneratorHelper::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 | } |
@@ -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 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $hash = ""; |
195 | 195 | $action = Security::getInstance()->getSessionKey("__CACHE__"); |
196 | 196 | if (null !== $action && $action["cache"] > 0) { |
197 | - $hash = $action["http"] . " " . $action["slug"]; |
|
197 | + $hash = $action["http"]." ".$action["slug"]; |
|
198 | 198 | } |
199 | 199 | return sha1($hash); |
200 | 200 | } |
@@ -38,8 +38,8 @@ |
||
38 | 38 | //Generating the templates translations |
39 | 39 | $translations = $this->tpl->regenerateTemplates(); |
40 | 40 | |
41 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
42 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
41 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
42 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
43 | 43 | |
44 | 44 | //xgettext localizations |
45 | 45 | $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale)); |
@@ -33,7 +33,9 @@ |
||
33 | 33 | public function getTranslations($locale) |
34 | 34 | { |
35 | 35 | //Default locale |
36 | - if (null === $locale) $locale = $this->config->get("default_language"); |
|
36 | + if (null === $locale) { |
|
37 | + $locale = $this->config->get("default_language"); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | //Generating the templates translations |
39 | 41 | $translations = $this->tpl->regenerateTemplates(); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param string $msg |
89 | 89 | * @param array $context |
90 | 90 | * |
91 | - * @return bool |
|
91 | + * @return boolean|null |
|
92 | 92 | */ |
93 | 93 | public function debugLog($msg = '', $context = []) |
94 | 94 | { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Método que escribe un log de Error |
100 | - * @param $msg |
|
100 | + * @param string $msg |
|
101 | 101 | * @param array $context |
102 | 102 | * |
103 | 103 | * @return bool |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Método que escribe un log de Warning |
112 | - * @param $msg |
|
112 | + * @param string $msg |
|
113 | 113 | * @param array $context |
114 | 114 | * @return bool |
115 | 115 | */ |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | |
15 | 15 | |
16 | 16 | if (!defined("LOG_DIR")) { |
17 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
18 | - define("LOG_DIR", BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
17 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
18 | + define("LOG_DIR", BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $config = Config::getInstance(); |
49 | 49 | $args = func_get_args(); |
50 | 50 | list($logger, $debug, $path) = $this->setup($config, $args); |
51 | - $this->stream = fopen($path . DIRECTORY_SEPARATOR . date("Ymd") . ".log", "a+"); |
|
51 | + $this->stream = fopen($path.DIRECTORY_SEPARATOR.date("Ymd").".log", "a+"); |
|
52 | 52 | $this->addPushLogger($logger, $debug, $config); |
53 | 53 | $this->log_level = Config::getInstance()->get('log.level') ?: 'info'; |
54 | 54 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | private function createLoggerPath(Config $config) |
203 | 203 | { |
204 | 204 | $logger = $this->setLoggerName($config); |
205 | - $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m'); |
|
205 | + $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m'); |
|
206 | 206 | GeneratorHelper::createDir($path); |
207 | 207 | |
208 | 208 | return $path; |
@@ -393,8 +393,10 @@ |
||
393 | 393 | throw new RouterException(_("No existe la ruta especificada")); |
394 | 394 | } |
395 | 395 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
396 | - if (!empty($params)) foreach ($params as $key => $value) { |
|
396 | + if (!empty($params)) { |
|
397 | + foreach ($params as $key => $value) { |
|
397 | 398 | $url = str_replace("{" . $key . "}", $value, $url); |
399 | + } |
|
398 | 400 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
399 | 401 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
400 | 402 | } |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function init() |
62 | 62 | { |
63 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) { |
|
63 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) { |
|
64 | 64 | $this->hydrateRouting(); |
65 | 65 | $this->simpatize(); |
66 | - } else { |
|
67 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE); |
|
68 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE); |
|
66 | + }else { |
|
67 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE); |
|
68 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE); |
|
69 | 69 | $this->checkExternalModules(false); |
70 | 70 | } |
71 | 71 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | "success" => FALSE, |
91 | 91 | "error" => $e->getMessage(), |
92 | 92 | )), 'application/json'); |
93 | - } else { |
|
93 | + }else { |
|
94 | 94 | return $template->render('error.html.twig', array( |
95 | 95 | 'exception' => $e, |
96 | 96 | 'trace' => $e->getTraceAsString(), |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | SecurityHelper::checkRestrictedAccess($route); |
149 | 149 | //Search action and execute |
150 | 150 | $this->searchAction($route); |
151 | - } catch (AccessDeniedException $e) { |
|
151 | + }catch (AccessDeniedException $e) { |
|
152 | 152 | Logger::log(_('Solicitamos credenciales de acceso a zona restringida')); |
153 | 153 | return Admin::staticAdminLogon($route); |
154 | - } catch (RouterException $r) { |
|
154 | + }catch (RouterException $r) { |
|
155 | 155 | Logger::log($r->getMessage(), LOG_WARNING); |
156 | - } catch (\Exception $e) { |
|
156 | + }catch (\Exception $e) { |
|
157 | 157 | Logger::log($e->getMessage(), LOG_ERR); |
158 | 158 | throw $e; |
159 | 159 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | protected function searchAction($route) |
172 | 172 | { |
173 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
173 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
174 | 174 | //Revisamos si tenemos la ruta registrada |
175 | 175 | $parts = parse_url($route); |
176 | 176 | $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $class = RouterHelper::getClassToCall($action); |
185 | 185 | try { |
186 | 186 | $this->executeCachedRoute($route, $action, $class, $get); |
187 | - } catch (\Exception $e) { |
|
187 | + }catch (\Exception $e) { |
|
188 | 188 | Logger::log($e->getMessage(), LOG_ERR); |
189 | 189 | throw new RouterException($e->getMessage(), 404, $e); |
190 | 190 | } |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | $externalModules = explode(',', $externalModules); |
214 | 214 | foreach ($externalModules as &$module) { |
215 | 215 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
216 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
216 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
217 | 217 | if (file_exists($externalModulePath)) { |
218 | 218 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
219 | 219 | if (!empty($externalModule)) { |
220 | 220 | foreach ($externalModule as $modulePath) { |
221 | 221 | $extModule = $modulePath->getBasename(); |
222 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
222 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
223 | 223 | if (file_exists($moduleAutoloader)) { |
224 | 224 | @include $moduleAutoloader; |
225 | 225 | if ($hydrateRoute) { |
226 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
226 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
246 | 246 | foreach ($modules as $modulePath) { |
247 | 247 | $module = $modulePath->getBasename(); |
248 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
248 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | $this->checkExternalModules(); |
252 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
252 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $home_params = NULL; |
265 | 265 | foreach ($this->routing as $pattern => $params) { |
266 | 266 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
267 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
267 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
268 | 268 | $home_params = $params; |
269 | 269 | } |
270 | 270 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php"); |
290 | 290 | foreach ($files as $file) { |
291 | 291 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
292 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
292 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
293 | 293 | } |
294 | 294 | $this->finder = new Finder(); |
295 | 295 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | if (!$this->domains) { |
360 | 360 | $this->domains = []; |
361 | 361 | } |
362 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
362 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
363 | 363 | if (!array_key_exists($domain, $this->domains)) { |
364 | 364 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
365 | 365 | } |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function simpatize() |
376 | 376 | { |
377 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
378 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
377 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
378 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
379 | 379 | $this->generateSlugs($absoluteTranslationFileName); |
380 | 380 | GeneratorHelper::createDir(CONFIG_DIR); |
381 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
381 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
382 | 382 | |
383 | 383 | return $this; |
384 | 384 | } |
@@ -396,16 +396,16 @@ discard block |
||
396 | 396 | public function getRoute($slug = '', $absolute = FALSE, $params = []) |
397 | 397 | { |
398 | 398 | if (strlen($slug) === 0) { |
399 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
399 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
400 | 400 | } |
401 | 401 | if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { |
402 | 402 | throw new RouterException(_("No existe la ruta especificada")); |
403 | 403 | } |
404 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
404 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
405 | 405 | if (!empty($params)) foreach ($params as $key => $value) { |
406 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
406 | + $url = str_replace("{".$key."}", $value, $url); |
|
407 | 407 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
408 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
408 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -450,19 +450,19 @@ discard block |
||
450 | 450 | */ |
451 | 451 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
452 | 452 | { |
453 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
453 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
454 | 454 | Security::getInstance()->setSessionKey("__CACHE__", $action); |
455 | 455 | $cache = Cache::needCache(); |
456 | 456 | $execute = TRUE; |
457 | 457 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
458 | 458 | $cacheDataName = $this->cache->getRequestCacheHash(); |
459 | - $tmpDir = substr($cacheDataName, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheDataName, 2, 2) . DIRECTORY_SEPARATOR; |
|
460 | - $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName, |
|
461 | - $cache, function () { |
|
459 | + $tmpDir = substr($cacheDataName, 0, 2).DIRECTORY_SEPARATOR.substr($cacheDataName, 2, 2).DIRECTORY_SEPARATOR; |
|
460 | + $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName, |
|
461 | + $cache, function() { |
|
462 | 462 | }); |
463 | 463 | if (NULL !== $cachedData) { |
464 | - $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName . ".headers", |
|
465 | - $cache, function () { |
|
464 | + $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName.".headers", |
|
465 | + $cache, function() { |
|
466 | 466 | }, Cache::JSON); |
467 | 467 | Template::getInstance()->renderCache($cachedData, $headers); |
468 | 468 | $execute = FALSE; |
@@ -56,8 +56,10 @@ discard block |
||
56 | 56 | $_route = explode("/", $url['path']); |
57 | 57 | $_pattern = explode("/", $pattern); |
58 | 58 | $get = array(); |
59 | - if (!empty($_pattern)) foreach ($_pattern as $index => $component) { |
|
59 | + if (!empty($_pattern)) { |
|
60 | + foreach ($_pattern as $index => $component) { |
|
60 | 61 | $_get = array(); |
62 | + } |
|
61 | 63 | preg_match_all('/^\{(.*)\}$/i', $component, $_get); |
62 | 64 | if (!empty($_get[1]) && isset($_route[$index])) { |
63 | 65 | $get[array_pop($_get[1])] = $_route[$index]; |
@@ -151,12 +153,16 @@ discard block |
||
151 | 153 | $params = []; |
152 | 154 | $parameters = $method->getParameters(); |
153 | 155 | /** @var \ReflectionParameter $param */ |
154 | - if (count($parameters) > 0) foreach ($parameters as $param) { |
|
156 | + if (count($parameters) > 0) { |
|
157 | + foreach ($parameters as $param) { |
|
155 | 158 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
156 | 159 | $params[$param->getName()] = $param->getDefaultValue(); |
160 | + } |
|
157 | 161 | $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
158 | 162 | } |
159 | - } else $default = $regex; |
|
163 | + } else { |
|
164 | + $default = $regex; |
|
165 | + } |
|
160 | 166 | |
161 | 167 | return array($regex, $default, $params); |
162 | 168 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * Método que extrae los parámetros de una función |
142 | 142 | * |
143 | - * @param array $sr |
|
143 | + * @param string[] $sr |
|
144 | 144 | * @param \ReflectionMethod $method |
145 | 145 | * |
146 | 146 | * @return array |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param string $docComments |
209 | 209 | * |
210 | - * @return bool |
|
210 | + * @return string |
|
211 | 211 | */ |
212 | 212 | public static function extractReflectionCacheability($docComments) |
213 | 213 | { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public static function getClassToCall($action) |
23 | 23 | { |
24 | 24 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
25 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
25 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
26 | 26 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
27 | 27 | return $class; |
28 | 28 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $expr = preg_quote($expr, '/'); |
109 | 109 | $expr = str_replace('###', '(.*)', $expr); |
110 | 110 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
111 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
111 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
112 | 112 | return $matched; |
113 | 113 | } |
114 | 114 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
121 | 121 | { |
122 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
123 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
122 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
123 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
124 | 124 | $tpl_path = "templates"; |
125 | 125 | $public_path = "public"; |
126 | 126 | $model_path = "models"; |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | $model_path = ucfirst($model_path); |
131 | 131 | } |
132 | 132 | if ($class->hasConstant("TPL")) { |
133 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
133 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
134 | 134 | } |
135 | 135 | return [ |
136 | 136 | "base" => $path, |
137 | - "template" => $path . $tpl_path, |
|
138 | - "model" => $path . $model_path, |
|
139 | - "public" => $path . $public_path, |
|
137 | + "template" => $path.$tpl_path, |
|
138 | + "model" => $path.$model_path, |
|
139 | + "public" => $path.$public_path, |
|
140 | 140 | ]; |
141 | 141 | } |
142 | 142 | |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | if (count($parameters) > 0) foreach ($parameters as $param) { |
159 | 159 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
160 | 160 | $params[$param->getName()] = $param->getDefaultValue(); |
161 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
161 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
162 | 162 | } |
163 | - } else $default = $regex; |
|
163 | + }else $default = $regex; |
|
164 | 164 | |
165 | 165 | return array($regex, $default, $params); |
166 | 166 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $default = str_replace('{__DOMAIN__}', $module, $default); |
241 | 241 | $httpMethod = RouterHelper::extractReflectionHttpMethod($docComments); |
242 | 242 | $label = RouterHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
243 | - $route = $httpMethod . "#|#" . $regex; |
|
243 | + $route = $httpMethod."#|#".$regex; |
|
244 | 244 | $info = [ |
245 | 245 | "method" => $method->getName(), |
246 | 246 | "params" => $params, |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public static function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
56 | 56 | { |
57 | - Logger::log('Create inyectable instance for ' . $classNameSpace); |
|
57 | + Logger::log('Create inyectable instance for '.$classNameSpace); |
|
58 | 58 | $reflector = new \ReflectionClass($calledClass); |
59 | 59 | $property = $reflector->getProperty($variable); |
60 | 60 | $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace; |
61 | 61 | if (true === $singleton && method_exists($varInstanceType, "getInstance")) { |
62 | 62 | $instance = $varInstanceType::getInstance(); |
63 | - } else { |
|
63 | + }else { |
|
64 | 64 | $instance = new $varInstanceType(); |
65 | 65 | } |
66 | 66 | return $instance; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public static function getClassProperties($class) |
75 | 75 | { |
76 | 76 | $properties = []; |
77 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
77 | + Logger::log('Extracting annotations properties from class '.$class); |
|
78 | 78 | $selfReflector = new \ReflectionClass($class); |
79 | 79 | if (false !== $selfReflector->getParentClass()) { |
80 | 80 | $properties = self::getClassProperties($selfReflector->getParentClass()->getName()); |