@@ -107,7 +107,7 @@ |
||
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Método que guarda en fichero los datos pasados |
110 | - * @param $path |
|
110 | + * @param string $path |
|
111 | 111 | * @param $data |
112 | 112 | * @param int $transform |
113 | 113 | * @param boolean $absolutePath |
@@ -131,7 +131,7 @@ |
||
131 | 131 | if (null !== $function && $this->hasExpiredCache($path, $expires)) { |
132 | 132 | $data = call_user_func($function); |
133 | 133 | $this->storeData($path, $data, $transform); |
134 | - } else { |
|
134 | + }else { |
|
135 | 135 | $data = $this->getDataFromFile($path, $transform); |
136 | 136 | } |
137 | 137 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * Método que copia los recursos recursivamente |
131 | 131 | * @param string $dest |
132 | 132 | * @param boolean $force |
133 | - * @param $filename_path |
|
133 | + * @param string $filename_path |
|
134 | 134 | * @param boolean $debug |
135 | 135 | */ |
136 | 136 | private static function copyResources($dest, $force, $filename_path, $debug) |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $path |
156 | 156 | * @param $domains |
157 | 157 | * |
158 | - * @return mixed |
|
158 | + * @return string |
|
159 | 159 | */ |
160 | 160 | private static function extractPathname($path, $domains) |
161 | 161 | { |
@@ -52,7 +52,7 @@ |
||
52 | 52 | $router = Router::getInstance(); |
53 | 53 | try { |
54 | 54 | return $router->getRoute($path, $absolute, $params); |
55 | - } catch (\Exception $e) |
|
55 | + }catch (\Exception $e) |
|
56 | 56 | { |
57 | 57 | return $router->getRoute('', $absolute, $params); |
58 | 58 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | if (is_dir($filename_path)) { |
142 | 142 | Config::createDir(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
143 | 143 | Template::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
144 | - }else { |
|
144 | + } else { |
|
145 | 145 | if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) { |
146 | 146 | throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
147 | 147 | } |
@@ -198,8 +198,11 @@ discard block |
||
198 | 198 | private static function putResourceContent($name, $filename_path, $base, $file_path) |
199 | 199 | { |
200 | 200 | $data = file_get_contents($filename_path); |
201 | - if (!empty($name)) file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
202 | - else file_put_contents($base.$file_path, $data); |
|
201 | + if (!empty($name)) { |
|
202 | + file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
203 | + } else { |
|
204 | + file_put_contents($base.$file_path, $data); |
|
205 | + } |
|
203 | 206 | } |
204 | 207 | |
205 | 208 | /** |
@@ -95,6 +95,10 @@ discard block |
||
95 | 95 | * @return string|null |
96 | 96 | */ |
97 | 97 | public static function header($name) { return self::getInstance()->getHeader($name); } |
98 | + |
|
99 | + /** |
|
100 | + * @return string |
|
101 | + */ |
|
98 | 102 | public function getHeader($name) |
99 | 103 | { |
100 | 104 | $header = null; |
@@ -107,7 +111,7 @@ discard block |
||
107 | 111 | |
108 | 112 | /** |
109 | 113 | * Método que devuelve la url solicitada |
110 | - * @return string|null |
|
114 | + * @return string |
|
111 | 115 | */ |
112 | 116 | public static function requestUri(){ return self::getInstance()->getRequestUri(); } |
113 | 117 |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | |
5 | 5 | use PSFS\base\types\SingletonTrait; |
6 | 6 | |
7 | -if(!function_exists("getallheaders")) |
|
7 | +if (!function_exists("getallheaders")) |
|
8 | 8 | { |
9 | 9 | function getallheaders() |
10 | 10 | { |
11 | 11 | $headers = array(); |
12 | - foreach($_SERVER as $h=>$v) |
|
13 | - if(preg_match('/HTTP_(.+)/',$h,$hp)) |
|
14 | - $headers[$hp[1]]=$v; |
|
12 | + foreach ($_SERVER as $h=>$v) |
|
13 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
14 | + $headers[$hp[1]] = $v; |
|
15 | 15 | return $headers; |
16 | 16 | } |
17 | 17 | } |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | * Método que devuelve la url solicitada |
110 | 110 | * @return string|null |
111 | 111 | */ |
112 | - public static function requestUri(){ return self::getInstance()->getRequestUri(); } |
|
112 | + public static function requestUri() { return self::getInstance()->getRequestUri(); } |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @return string |
116 | 116 | */ |
117 | - public function getRequestUri(){ return array_key_exists('REQUEST_URI', $this->server) ? $this->server['REQUEST_URI'] : ''; } |
|
117 | + public function getRequestUri() { return array_key_exists('REQUEST_URI', $this->server) ? $this->server['REQUEST_URI'] : ''; } |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Método que devuelve el idioma de la petición |
@@ -9,9 +9,10 @@ discard block |
||
9 | 9 | function getallheaders() |
10 | 10 | { |
11 | 11 | $headers = array(); |
12 | - foreach($_SERVER as $h=>$v) |
|
13 | - if(preg_match('/HTTP_(.+)/',$h,$hp)) |
|
12 | + foreach($_SERVER as $h=>$v) { |
|
13 | + if(preg_match('/HTTP_(.+)/',$h,$hp)) |
|
14 | 14 | $headers[$hp[1]]=$v; |
15 | + } |
|
15 | 16 | return $headers; |
16 | 17 | } |
17 | 18 | } |
@@ -180,7 +181,9 @@ discard block |
||
180 | 181 | */ |
181 | 182 | public function redirect($url = null) |
182 | 183 | { |
183 | - if (null === $url) $url = $this->server['HTTP_ORIGIN']; |
|
184 | + if (null === $url) { |
|
185 | + $url = $this->server['HTTP_ORIGIN']; |
|
186 | + } |
|
184 | 187 | ob_start(); |
185 | 188 | header('Location: '.$url); |
186 | 189 | ob_end_clean(); |
@@ -226,7 +229,9 @@ discard block |
||
226 | 229 | $host = $this->getServerName(); |
227 | 230 | $protocol = $protocol ? $this->getProtocol() : ''; |
228 | 231 | $url = ''; |
229 | - if (!empty($host) && !empty($protocol)) $url = $protocol.$host; |
|
232 | + if (!empty($host) && !empty($protocol)) { |
|
233 | + $url = $protocol.$host; |
|
234 | + } |
|
230 | 235 | return $url; |
231 | 236 | } |
232 | 237 |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | /** |
589 | 589 | * Método que extrae los parámetros de una función |
590 | 590 | * |
591 | - * @param array $sr |
|
591 | + * @param string[] $sr |
|
592 | 592 | * @param \ReflectionMethod $method |
593 | 593 | * |
594 | 594 | * @return array |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * |
643 | 643 | * @param string $docComments |
644 | 644 | * |
645 | - * @return bool |
|
645 | + * @return string |
|
646 | 646 | */ |
647 | 647 | private function extractReflectionCacheability($docComments) |
648 | 648 | { |
@@ -260,8 +260,10 @@ discard block |
||
260 | 260 | $_route = explode("/", $url['path']); |
261 | 261 | $_pattern = explode("/", $pattern); |
262 | 262 | $get = array(); |
263 | - if (!empty($_pattern)) foreach ($_pattern as $index => $component) { |
|
263 | + if (!empty($_pattern)) { |
|
264 | + foreach ($_pattern as $index => $component) { |
|
264 | 265 | $_get = array(); |
266 | + } |
|
265 | 267 | preg_match_all('/^\{(.*)\}$/i', $component, $_get); |
266 | 268 | if (!empty($_get[1]) && isset($_route[$index])) { |
267 | 269 | $get[array_pop($_get[1])] = $_route[$index]; |
@@ -476,8 +478,10 @@ discard block |
||
476 | 478 | throw new RouterException(_("No existe la ruta especificada")); |
477 | 479 | } |
478 | 480 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
479 | - if (!empty($params)) foreach ($params as $key => $value) { |
|
481 | + if (!empty($params)) { |
|
482 | + foreach ($params as $key => $value) { |
|
480 | 483 | $url = str_replace("{" . $key . "}", $value, $url); |
484 | + } |
|
481 | 485 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
482 | 486 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
483 | 487 | } |
@@ -599,12 +603,16 @@ discard block |
||
599 | 603 | $default = ''; |
600 | 604 | $params = array(); |
601 | 605 | $parameters = $method->getParameters(); |
602 | - if (count($parameters) > 0) foreach ($parameters as $param) { |
|
606 | + if (count($parameters) > 0) { |
|
607 | + foreach ($parameters as $param) { |
|
603 | 608 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
604 | 609 | $params[$param->getName()] = $param->getDefaultValue(); |
610 | + } |
|
605 | 611 | $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
606 | 612 | } |
607 | - } else $default = $regex; |
|
613 | + } else { |
|
614 | + $default = $regex; |
|
615 | + } |
|
608 | 616 | |
609 | 617 | return array($regex, $default, $params); |
610 | 618 | } |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function init() |
61 | 61 | { |
62 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) { |
|
62 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) { |
|
63 | 63 | $this->hydrateRouting(); |
64 | 64 | $this->simpatize(); |
65 | - } else { |
|
66 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE); |
|
67 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE); |
|
65 | + }else { |
|
66 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE); |
|
67 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | "success" => FALSE, |
85 | 85 | "error" => $e->getMessage(), |
86 | 86 | )), 'application/json'); |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | if (NULL === $e) { |
89 | 89 | $e = new \Exception(_('Página no encontrada'), 404); |
90 | 90 | } |
@@ -124,24 +124,24 @@ discard block |
||
124 | 124 | |
125 | 125 | //Search action and execute |
126 | 126 | return $this->searchAction($route); |
127 | - } catch (AccessDeniedException $e) { |
|
127 | + }catch (AccessDeniedException $e) { |
|
128 | 128 | Logger::getInstance()->debugLog(_('Solicitamos credenciales de acceso a zona restringida')); |
129 | 129 | if ('login' === Config::getInstance()->get('admin_login')) { |
130 | 130 | return $this->redirectLogin($route); |
131 | - } else { |
|
131 | + }else { |
|
132 | 132 | return $this->sentAuthHeader(); |
133 | 133 | } |
134 | - } catch (RouterException $r) { |
|
134 | + }catch (RouterException $r) { |
|
135 | 135 | if (FALSE !== preg_match('/\/$/', $route)) { |
136 | 136 | if (preg_match('/admin/', $route)) { |
137 | 137 | $default = Config::getInstance()->get('admin_action'); |
138 | - } else { |
|
138 | + }else { |
|
139 | 139 | $default = Config::getInstance()->get('home_action'); |
140 | 140 | } |
141 | 141 | |
142 | 142 | return $this->execute($this->getRoute($default)); |
143 | 143 | } |
144 | - } catch (\Exception $e) { |
|
144 | + }catch (\Exception $e) { |
|
145 | 145 | Logger::getInstance()->errorLog($e->getMessage()); |
146 | 146 | throw $e; |
147 | 147 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $corsEnabled = Config::getInstance()->get('cors.enabled'); |
158 | 158 | $request = Request::getInstance(); |
159 | 159 | if (NULL !== $corsEnabled && null !== $request->getServer('HTTP_REFERER')) { |
160 | - if($corsEnabled == '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) { |
|
160 | + if ($corsEnabled == '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) { |
|
161 | 161 | if (!$this->headersSent) { |
162 | 162 | header("Access-Control-Allow-Credentials: true"); |
163 | 163 | header("Access-Control-Allow-Origin: *"); |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | header("Access-Control-Allow-Headers: Access-Control-Allow-Methods, Access-Control-Allow-Headers, Access-Control-Allow-Origin, Origin, X-Requested-With, Content-Type, Accept, Authorization"); |
166 | 166 | $this->headersSent = true; |
167 | 167 | } |
168 | - if(Request::getInstance()->getMethod() == 'OPTIONS') { |
|
169 | - header( "HTTP/1.1 200 OK" ); |
|
168 | + if (Request::getInstance()->getMethod() == 'OPTIONS') { |
|
169 | + header("HTTP/1.1 200 OK"); |
|
170 | 170 | exit(); |
171 | 171 | } |
172 | 172 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $class = $this->getClassToCall($action); |
196 | 196 | try { |
197 | 197 | return $this->executeCachedRoute($route, $action, $class, $get); |
198 | - } catch (\Exception $e) { |
|
198 | + }catch (\Exception $e) { |
|
199 | 199 | Logger::getInstance()->debugLog($e->getMessage(), array($e->getFile(), $e->getLine())); |
200 | 200 | throw new RouterException($e->getMessage(), 404, $e); |
201 | 201 | } |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | if (file_exists($modules)) { |
284 | 284 | $this->routing = $this->inspectDir($modules, "", $this->routing); |
285 | 285 | } |
286 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
286 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
287 | 287 | $home = Config::getInstance()->get('home_action'); |
288 | 288 | if (NULL !== $home || $home !== '') { |
289 | 289 | $home_params = NULL; |
290 | 290 | foreach ($this->routing as $pattern => $params) { |
291 | 291 | list($method, $route) = $this->extractHttpRoute($pattern); |
292 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
292 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
293 | 293 | $home_params = $params; |
294 | 294 | } |
295 | 295 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php"); |
315 | 315 | foreach ($files as $file) { |
316 | 316 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
317 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing); |
|
317 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing); |
|
318 | 318 | } |
319 | 319 | $this->finder = new Finder(); |
320 | 320 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $httpMethod = $this->extractReflectionHttpMethod($docComments); |
356 | 356 | $visible = $this->extractReflectionVisibility($docComments); |
357 | 357 | $expiration = $this->extractReflectionCacheability($docComments); |
358 | - $routing[$httpMethod . "#|#" . $regex] = array( |
|
358 | + $routing[$httpMethod."#|#".$regex] = array( |
|
359 | 359 | "class" => $namespace, |
360 | 360 | "method" => $method->getName(), |
361 | 361 | "params" => $params, |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | { |
386 | 386 | //Calculamos los dominios para las plantillas |
387 | 387 | if ($class->hasConstant("DOMAIN")) { |
388 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
389 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
390 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
388 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
389 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
390 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
391 | 391 | $tpl_path = "templates"; |
392 | 392 | $public_path = "public"; |
393 | 393 | $model_path = "models"; |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | $model_path = ucfirst($model_path); |
398 | 398 | } |
399 | 399 | if ($class->hasConstant("TPL")) { |
400 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
400 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
401 | 401 | } |
402 | 402 | $this->domains[$domain] = array( |
403 | - "template" => $path . $tpl_path, |
|
404 | - "model" => $path . $model_path, |
|
405 | - "public" => $path . $public_path, |
|
403 | + "template" => $path.$tpl_path, |
|
404 | + "model" => $path.$model_path, |
|
405 | + "public" => $path.$public_path, |
|
406 | 406 | ); |
407 | 407 | } |
408 | 408 | |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | */ |
416 | 416 | private function simpatize() |
417 | 417 | { |
418 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
419 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
418 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
419 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
420 | 420 | $this->generateSlugs($absoluteTranslationFileName); |
421 | 421 | Config::createDir(CONFIG_DIR); |
422 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
422 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
423 | 423 | |
424 | 424 | return $this; |
425 | 425 | } |
@@ -470,16 +470,16 @@ discard block |
||
470 | 470 | public function getRoute($slug = '', $absolute = FALSE, $params = NULL) |
471 | 471 | { |
472 | 472 | if (strlen($slug) === 0) { |
473 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
473 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
474 | 474 | } |
475 | 475 | if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { |
476 | 476 | throw new RouterException(_("No existe la ruta especificada")); |
477 | 477 | } |
478 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
478 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
479 | 479 | if (!empty($params)) foreach ($params as $key => $value) { |
480 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
480 | + $url = str_replace("{".$key."}", $value, $url); |
|
481 | 481 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
482 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
482 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -497,12 +497,12 @@ discard block |
||
497 | 497 | if (preg_match('/^\/admin(\/|$)/', $routePattern)) { |
498 | 498 | if (preg_match('/^PSFS/', $params["class"])) { |
499 | 499 | $profile = "superadmin"; |
500 | - } else { |
|
500 | + }else { |
|
501 | 501 | $profile = "admin"; |
502 | 502 | } |
503 | 503 | if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) { |
504 | 504 | $_profile = ($params["visible"]) ? $profile : 'adminhidden'; |
505 | - if(!array_key_exists($_profile, $routes)) { |
|
505 | + if (!array_key_exists($_profile, $routes)) { |
|
506 | 506 | $routes[$_profile] = array(); |
507 | 507 | } |
508 | 508 | $routes[$_profile][] = $params["slug"]; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | $expr = preg_quote($expr, '/'); |
572 | 572 | $expr = str_replace('###', '(.*)', $expr); |
573 | 573 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
574 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
574 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
575 | 575 | |
576 | 576 | return $matched; |
577 | 577 | } |
@@ -609,9 +609,9 @@ discard block |
||
609 | 609 | if (count($parameters) > 0) foreach ($parameters as $param) { |
610 | 610 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
611 | 611 | $params[$param->getName()] = $param->getDefaultValue(); |
612 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
612 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
613 | 613 | } |
614 | - } else $default = $regex; |
|
614 | + }else $default = $regex; |
|
615 | 615 | |
616 | 616 | return array($regex, $default, $params); |
617 | 617 | } |
@@ -668,16 +668,16 @@ discard block |
||
668 | 668 | */ |
669 | 669 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
670 | 670 | { |
671 | - Logger::getInstance()->debugLog(_('Ruta resuelta para ') . $route); |
|
671 | + Logger::getInstance()->debugLog(_('Ruta resuelta para ').$route); |
|
672 | 672 | $this->session->setSessionKey("__CACHE__", $action); |
673 | 673 | $cache = Cache::needCache(); |
674 | 674 | $execute = TRUE; |
675 | 675 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
676 | 676 | $cacheDataName = $this->cache->getRequestCacheHash(); |
677 | - $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, $cache, function () { |
|
677 | + $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, $cache, function() { |
|
678 | 678 | }); |
679 | 679 | if (NULL !== $cachedData) { |
680 | - $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", $cache, function () { |
|
680 | + $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", $cache, function() { |
|
681 | 681 | }, Cache::JSON); |
682 | 682 | Template::getInstance()->renderCache($cachedData, $headers); |
683 | 683 | $execute = FALSE; |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | $translations = array(); |
727 | 727 | if (file_exists($absoluteTranslationFileName)) { |
728 | 728 | include($absoluteTranslationFileName); |
729 | - } else { |
|
729 | + }else { |
|
730 | 730 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
731 | 731 | } |
732 | 732 |
@@ -371,7 +371,7 @@ |
||
371 | 371 | * @param array $parts |
372 | 372 | * @param int $partLength |
373 | 373 | * |
374 | - * @return array |
|
374 | + * @return string[] |
|
375 | 375 | */ |
376 | 376 | private static function extractTsAndMod(array &$parts, $partLength) |
377 | 377 | { |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | public static function save($user) |
79 | 79 | { |
80 | 80 | $admins = array(); |
81 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
82 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
81 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
82 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
83 | 83 | } |
84 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
84 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
85 | 85 | $admins[$user['username']]['profile'] = $user['profile']; |
86 | 86 | |
87 | - return (FALSE !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
87 | + return (FALSE !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | public function getAdmins() |
105 | 105 | { |
106 | 106 | $admins = array(); |
107 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
108 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
107 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
108 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | return $admins; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | { |
125 | 125 | if (!$this->authorized) { |
126 | 126 | $request = Request::getInstance(); |
127 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
127 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
128 | 128 | //Si no hay fichero de usuarios redirigimos directamente al gestor |
129 | 129 | return Router::getInstance()->getAdmin()->adminers(); |
130 | 130 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | if (!empty($user) && !empty($admins[$user])) { |
139 | 139 | $auth = $admins[$user]['hash']; |
140 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
140 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
141 | 141 | $this->admin = array( |
142 | 142 | 'alias' => $user, |
143 | 143 | 'profile' => $admins[$user]['profile'], |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | $axis = 0; |
355 | 355 | $parts = array(); |
356 | 356 | try { |
357 | - $partLength = floor(strlen($token) / 10); |
|
358 | - for ($i = 0, $ct = ceil(strlen($token) / $partLength); $i < $ct; $i++) { |
|
357 | + $partLength = floor(strlen($token)/10); |
|
358 | + for ($i = 0, $ct = ceil(strlen($token)/$partLength); $i < $ct; $i++) { |
|
359 | 359 | $parts[] = substr($token, $axis, $partLength); |
360 | 360 | $axis += $partLength; |
361 | 361 | } |
362 | - } catch(\Exception $e) { |
|
362 | + }catch (\Exception $e) { |
|
363 | 363 | $partLength = 0; |
364 | 364 | } |
365 | 365 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $decoded = NULL; |
400 | 400 | list($partLength, $parts) = self::extractTokenParts($token); |
401 | 401 | list($ts, $mod) = self::extractTsAndMod($parts, $partLength); |
402 | - $hashMod = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
402 | + $hashMod = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
403 | 403 | if (time() - (integer)$ts < 300 && $hashMod === $mod) { |
404 | 404 | $decoded = implode('', $parts); |
405 | 405 | } |
@@ -416,16 +416,16 @@ discard block |
||
416 | 416 | public static function generateToken($secret, $module = 'PSFS') |
417 | 417 | { |
418 | 418 | $ts = time(); |
419 | - $hashModule = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
419 | + $hashModule = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
420 | 420 | $hash = hash('sha256', $secret); |
421 | - $insert = floor(strlen($hash) / strlen($ts)); |
|
421 | + $insert = floor(strlen($hash)/strlen($ts)); |
|
422 | 422 | $j = 0; |
423 | 423 | $token = ''; |
424 | 424 | for ($i = 0, $ct = strlen($ts); $i < $ct; $i++) { |
425 | - $token .= substr($ts, $i, 1) . substr($hash, $j, $insert) . substr($hashModule, $i, 2); |
|
425 | + $token .= substr($ts, $i, 1).substr($hash, $j, $insert).substr($hashModule, $i, 2); |
|
426 | 426 | $j += $insert; |
427 | 427 | } |
428 | - $token .= substr($hash, ($insert * strlen($ts)), strlen($hash) - ($insert * strlen($ts))); |
|
428 | + $token .= substr($hash, ($insert*strlen($ts)), strlen($hash) - ($insert*strlen($ts))); |
|
429 | 429 | return $token; |
430 | 430 | } |
431 | 431 |
@@ -125,8 +125,8 @@ |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | - * @param $header |
|
129 | - * @param null $content |
|
128 | + * @param string $header |
|
129 | + * @param string $content |
|
130 | 130 | * |
131 | 131 | * @return $this |
132 | 132 | */ |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->url = NULL; |
178 | 178 | $this->params = array(); |
179 | 179 | $this->headers = array(); |
180 | - $this->log->debugLog(_("Context service for " . get_called_class() . " cleared!")); |
|
180 | + $this->log->debugLog(_("Context service for ".get_called_class()." cleared!")); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | protected function setOpts() |
210 | 210 | { |
211 | - switch(strtoupper($this->type)) { |
|
211 | + switch (strtoupper($this->type)) { |
|
212 | 212 | case 'GET': |
213 | 213 | default: |
214 | 214 | curl_setopt($this->con, CURLOPT_CUSTOMREQUEST, "GET"); |
@@ -175,10 +175,10 @@ |
||
175 | 175 | |
176 | 176 | /** |
177 | 177 | * Create the depecency injected |
178 | - * @param $variable |
|
179 | - * @param $singleton |
|
178 | + * @param string $variable |
|
179 | + * @param boolean $singleton |
|
180 | 180 | * @param $classNameSpace |
181 | - * @param $calledClass |
|
181 | + * @param string $calledClass |
|
182 | 182 | * @return mixed |
183 | 183 | */ |
184 | 184 | private function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | $setter = "set".ucfirst($variable); |
99 | 99 | if (method_exists($calledClass, $setter)) { |
100 | 100 | $this->$setter($instance); |
101 | - } else { |
|
101 | + }else { |
|
102 | 102 | $this->$variable = $instance; |
103 | 103 | } |
104 | - } catch (\Exception $e) { |
|
104 | + }catch (\Exception $e) { |
|
105 | 105 | Logger::getInstance()->errorLog($e->getMessage()); |
106 | 106 | } |
107 | 107 | return $this; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | if (true === $singleton && method_exists($varInstanceType, "getInstance")) { |
190 | 190 | $instance = $varInstanceType::getInstance(); |
191 | 191 | return $instance; |
192 | - } else { |
|
192 | + }else { |
|
193 | 193 | $instance = new $varInstanceType(); |
194 | 194 | return $instance; |
195 | 195 | } |
@@ -125,11 +125,13 @@ |
||
125 | 125 | $cacheService->storeData($cacheFilename, $properties, Cache::JSON); |
126 | 126 | } |
127 | 127 | /** @var \ReflectionProperty $property */ |
128 | - if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { |
|
128 | + if (!empty($properties) && is_array($properties)) { |
|
129 | + foreach ($properties as $property => $class) { |
|
129 | 130 | $this->load($property, true, $class); |
130 | 131 | } |
132 | + } |
|
131 | 133 | $this->setLoaded(); |
132 | - }else { |
|
134 | + } else { |
|
133 | 135 | $logService->warningLog(get_class($this)." ya cargada"); |
134 | 136 | } |
135 | 137 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @param null|string $pk |
261 | 261 | * |
262 | - * @return JsonResponse JSON |
|
262 | + * @return string|null JSON |
|
263 | 263 | */ |
264 | 264 | public function get($pk = NULL) |
265 | 265 | { |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @POST |
304 | 304 | * @ROUTE /api/{__API__} |
305 | 305 | * |
306 | - * @return JsonResponse JSON |
|
306 | + * @return string|null JSON |
|
307 | 307 | */ |
308 | 308 | public function post() |
309 | 309 | { |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * |
334 | 334 | * @param string $pk |
335 | 335 | * |
336 | - * @return JsonResponse JSON |
|
336 | + * @return string|null JSON |
|
337 | 337 | */ |
338 | 338 | public function delete($pk = NULL) |
339 | 339 | { |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @param string $pk |
364 | 364 | * |
365 | - * @return JsonResponse |
|
365 | + * @return string|null |
|
366 | 366 | * |
367 | 367 | */ |
368 | 368 | public function put($pk) |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @param ModelCriteria $query |
176 | 176 | */ |
177 | - private function addOrders(ModelCriteria &$query) |
|
177 | + private function addOrders(ModelCriteria & $query) |
|
178 | 178 | { |
179 | 179 | $orderAdded = FALSE; |
180 | 180 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $orderAdded = TRUE; |
183 | 183 | if ($direction === Order::ASC) { |
184 | 184 | $query->addAscendingOrderByColumn($field); |
185 | - } else { |
|
185 | + }else { |
|
186 | 186 | $query->addDescendingOrderByColumn($field); |
187 | 187 | } |
188 | 188 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param ModelCriteria $query |
199 | 199 | */ |
200 | - private function addFilters(ModelCriteria &$query) |
|
200 | + private function addFilters(ModelCriteria & $query) |
|
201 | 201 | { |
202 | 202 | if (count($this->query) > 0) { |
203 | 203 | foreach ($this->query as $field => $value) { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
215 | 215 | $text = preg_replace('/(\'|\")/', '', $value); |
216 | 216 | $query->filterBy($tableField, $text, Criteria::LIKE); |
217 | - } else { |
|
217 | + }else { |
|
218 | 218 | $query->filterBy($tableField, $value, Criteria::EQUAL); |
219 | 219 | } |
220 | 220 | } |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | list($page, $limit) = $this->extractPagination(); |
236 | 236 | if ($limit == -1) { |
237 | 237 | $this->list = $query->find($this->con); |
238 | - } else { |
|
238 | + }else { |
|
239 | 239 | $this->list = $query->paginate($page, $limit, $this->con); |
240 | 240 | } |
241 | - } catch (\Exception $e) { |
|
241 | + }catch (\Exception $e) { |
|
242 | 242 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
243 | 243 | } |
244 | 244 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | try { |
254 | 254 | $query = $this->extractQuery(); |
255 | 255 | $this->model = $query->findPk($pk); |
256 | - } catch (\Exception $e) { |
|
256 | + }catch (\Exception $e) { |
|
257 | 257 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
258 | 258 | } |
259 | 259 | } |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | $return = $this->list->toArray(); |
282 | 282 | $total = $this->list->getNbResults(); |
283 | 283 | $pages = $this->list->getLastPage(); |
284 | - } catch (\Exception $e) { |
|
284 | + }catch (\Exception $e) { |
|
285 | 285 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
286 | 286 | } |
287 | - } else { |
|
287 | + }else { |
|
288 | 288 | $this->hydrateModel($pk); |
289 | 289 | $return = ($this->getModel() instanceof ActiveRecordInterface) ? $this->getModel()->toArray() : NULL; |
290 | 290 | if (NULL === $return) { |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $saved = TRUE; |
327 | 327 | $model = $this->model->toArray(); |
328 | 328 | } |
329 | - } catch (\Exception $e) { |
|
329 | + }catch (\Exception $e) { |
|
330 | 330 | Logger::getInstance()->errorLog($e->getMessage()); |
331 | 331 | } |
332 | 332 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $this->model->delete($this->con); |
355 | 355 | $deleted = TRUE; |
356 | 356 | } |
357 | - } catch (\Exception $e) { |
|
357 | + }catch (\Exception $e) { |
|
358 | 358 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
359 | 359 | } |
360 | 360 | } |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | */ |
398 | 398 | private function extractQuery() |
399 | 399 | { |
400 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
400 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
401 | 401 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
402 | 402 | $query = $queryReflector->getMethod('create')->invoke(NULL); |
403 | 403 | |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | if ($this->con->inTransaction()) { |
442 | 442 | if ($status === 200) { |
443 | 443 | $this->con->commit(); |
444 | - } else { |
|
444 | + }else { |
|
445 | 445 | $this->con->rollBack(); |
446 | 446 | } |
447 | 447 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | return $this->render('api.admin.html.twig', array( |
485 | 485 | "api" => $this->getApi(), |
486 | 486 | "domain" => $this->domain, |
487 | - "url" => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)), |
|
487 | + "url" => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)), |
|
488 | 488 | )); |
489 | 489 | } |
490 | 490 |
@@ -42,6 +42,10 @@ discard block |
||
42 | 42 | * @return Form |
43 | 43 | */ |
44 | 44 | public function setEncType($enctype) { $this->enctype = $enctype; return $this; } |
45 | + |
|
46 | + /** |
|
47 | + * @param string|null $action |
|
48 | + */ |
|
45 | 49 | public function setAction($action) { $this->action = $action; return $this; } |
46 | 50 | public function setMethod($method) { $this->method = $method; return $this; } |
47 | 51 | public function setAttrs(array $attrs) { $this->attrs = $attrs; return $this; } |
@@ -466,7 +470,7 @@ discard block |
||
466 | 470 | } |
467 | 471 | |
468 | 472 | /** |
469 | - * @param $token_field |
|
473 | + * @param string $token_field |
|
470 | 474 | * @return bool |
471 | 475 | */ |
472 | 476 | protected function existsFormToken($token_field) { |
@@ -494,7 +498,7 @@ discard block |
||
494 | 498 | /** |
495 | 499 | * Método que extrae el valor de un campo del formulario del modelo |
496 | 500 | * @param $field |
497 | - * @param $value |
|
501 | + * @param ObjectCollection $value |
|
498 | 502 | * @param $type |
499 | 503 | * @return mixed |
500 | 504 | */ |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use PSFS\base\Singleton; |
13 | 13 | use PSFS\base\types\interfaces\FormType; |
14 | 14 | |
15 | - abstract class Form extends Singleton implements FormType{ |
|
15 | + abstract class Form extends Singleton implements FormType { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Variables de formulario |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | public function __construct($model = null) |
33 | 33 | { |
34 | - if(null !== $model) { |
|
34 | + if (null !== $model) { |
|
35 | 35 | $this->model = $model; |
36 | 36 | } |
37 | 37 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getFieldValue($name) { |
124 | 124 | $value = null; |
125 | - if (null !== $this->getField($name)){ |
|
125 | + if (null !== $this->getField($name)) { |
|
126 | 126 | $field = $this->getField($name); |
127 | 127 | $value = (array_key_exists('value', $field) && null !== $field['value']) ? $field['value'] : null; |
128 | 128 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $model->save(); |
324 | 324 | $save = true; |
325 | 325 | Logger::getInstance()->infoLog(get_class($this->model)." guardado con id ".$this->model->getPrimaryKey()); |
326 | - } catch (\Exception $e) { |
|
326 | + }catch (\Exception $e) { |
|
327 | 327 | Logger::getInstance()->errorLog($e->getMessage()); |
328 | 328 | throw new FormException($e->getMessage(), $e->getCode(), $e); |
329 | 329 | } |
@@ -369,10 +369,10 @@ discard block |
||
369 | 369 | if (array_key_exists($key, $data[$form_name])) { |
370 | 370 | if (preg_match("/id/i", $key) && ($data[$form_name][$key] === 0 || $data[$form_name][$key] === "%" || $data[$form_name][$key] === "")) { |
371 | 371 | $field["value"] = null; |
372 | - } else { |
|
372 | + }else { |
|
373 | 373 | $field["value"] = $data[$form_name][$key]; |
374 | 374 | } |
375 | - } else { |
|
375 | + }else { |
|
376 | 376 | unset($field["value"]); |
377 | 377 | } |
378 | 378 | return array($data, $field); |
@@ -416,10 +416,10 @@ discard block |
||
416 | 416 | if (array_key_exists('class_id', $field) && method_exists($class, "get".$field["class_id"])) { |
417 | 417 | $method = "get".$field["class_id"]; |
418 | 418 | $data[] = $class->$method(); |
419 | - } else { |
|
419 | + }else { |
|
420 | 420 | $data[] = $class->getPrimaryKey(); |
421 | 421 | } |
422 | - } else { |
|
422 | + }else { |
|
423 | 423 | $data[] = $val; |
424 | 424 | } |
425 | 425 | |
@@ -449,11 +449,11 @@ discard block |
||
449 | 449 | $field["value"] = $value; |
450 | 450 | } elseif ($value instanceof \DateTime) { |
451 | 451 | $field["value"] = $value->format("Y-m-d H:i:s"); |
452 | - } else { |
|
452 | + }else { |
|
453 | 453 | $field["value"] = $value->getPrimaryKey(); |
454 | 454 | } |
455 | 455 | } |
456 | - } else { |
|
456 | + }else { |
|
457 | 457 | $field["value"] = $value; |
458 | 458 | } |
459 | 459 | } |
@@ -157,7 +157,9 @@ discard block |
||
157 | 157 | if ($valid) { |
158 | 158 | if (count($this->fields) > 0) { |
159 | 159 | foreach ($this->fields as $key => &$field) { |
160 | - if ($key === self::SEPARATOR) continue; |
|
160 | + if ($key === self::SEPARATOR) { |
|
161 | + continue; |
|
162 | + } |
|
161 | 163 | list($field, $valid) = $this->checkFieldValidation($field, $key); |
162 | 164 | } |
163 | 165 | } |
@@ -444,7 +446,7 @@ discard block |
||
444 | 446 | //Si es una relación múltiple |
445 | 447 | if ($value instanceof ObjectCollection) { |
446 | 448 | $field = $this->computeModelFieldValue($field, $value, $type); |
447 | - }else { //O una relación unitaria |
|
449 | + } else { //O una relación unitaria |
|
448 | 450 | if (method_exists($value, "__toString")) { |
449 | 451 | $field["value"] = $value; |
450 | 452 | } elseif ($value instanceof \DateTime) { |