Passed
Push — master ( cf70c6...6539c2 )
by Fran
07:46
created
src/base/types/Api.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      *
187 187
      * @param ModelCriteria $query
188 188
      */
189
-    private function addOrders(ModelCriteria &$query)
189
+    private function addOrders(ModelCriteria & $query)
190 190
     {
191 191
         $orderAdded = FALSE;
192 192
         $tableMap = $this->getTableMap();
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                 $orderAdded = TRUE;
196 196
                 if ($direction === Order::ASC) {
197 197
                     $query->addAscendingOrderByColumn($column->getPhpName());
198
-                } else {
198
+                }else {
199 199
                     $query->addDescendingOrderByColumn($column->getPhpName());
200 200
                 }
201 201
             }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         if (count($pks) == 1) {
216 216
             $pks = array_keys($pks);
217 217
             $this->extraColumns[$pks[0]] = self::API_MODEL_KEY_FIELD;
218
-        } else {
218
+        }else {
219 219
             throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta'));
220 220
         }
221 221
     }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             }
238 238
             if (null !== $column) {
239 239
                 $this->extraColumns[$column->getFullyQualifiedName()] = self::API_LIST_NAME_FIELD;
240
-            } else {
240
+            }else {
241 241
                 $this->addClassListName($tableMap);
242 242
             }
243 243
         }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      *
250 250
      * @param ModelCriteria $query
251 251
      */
252
-    private function addExtraColumns(ModelCriteria &$query)
252
+    private function addExtraColumns(ModelCriteria & $query)
253 253
     {
254 254
         if (self::API_ACTION_LIST === $this->action) {
255 255
             $this->addDefaultListField();
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      *
268 268
      * @param ModelCriteria $query
269 269
      */
270
-    protected function joinTables(ModelCriteria &$query)
270
+    protected function joinTables(ModelCriteria & $query)
271 271
     {
272 272
         //TODO for specific implementations
273 273
     }
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
      *
290 290
      * @param ModelCriteria $query
291 291
      */
292
-    private function addFilters(ModelCriteria &$query)
292
+    private function addFilters(ModelCriteria & $query)
293 293
     {
294 294
         if (count($this->query) > 0) {
295 295
             $tableMap = $this->getTableMap();
296 296
             foreach ($this->query as $field => $value) {
297 297
                 if (self::API_COMBO_FIELD === $field) {
298 298
                     ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
299
-                } else {
299
+                }else {
300 300
                     ApiHelper::addModelField($tableMap, $query, $field, $value);
301 301
                 }
302 302
             }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     /**
307 307
      * @param ModelCriteria $query
308 308
      */
309
-    private function checkReturnFields(ModelCriteria &$query)
309
+    private function checkReturnFields(ModelCriteria & $query)
310 310
     {
311 311
         $returnFields = $this->getRequest()->getQuery('__fields');
312 312
         if (null !== $returnFields) {
@@ -342,10 +342,10 @@  discard block
 block discarded – undo
342 342
             list($page, $limit) = $this->extractPagination();
343 343
             if ($limit == -1) {
344 344
                 $this->list = $query->find($this->con);
345
-            } else {
345
+            }else {
346 346
                 $this->list = $query->paginate($page, $limit, $this->con);
347 347
             }
348
-        } catch (\Exception $e) {
348
+        }catch (\Exception $e) {
349 349
             Logger::log($e->getMessage(), LOG_ERR);
350 350
         }
351 351
     }
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
             $this->joinTables($query);
363 363
             $this->addExtraColumns($query);
364 364
             $this->model = $query->findPk($pk);
365
-        } catch (\Exception $e) {
365
+        }catch (\Exception $e) {
366 366
             Logger::getInstance(get_class($this))->errorLog($e->getMessage());
367 367
         }
368 368
     }
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
                 $saved = TRUE;
454 454
                 $model = $this->model->toArray();
455 455
             }
456
-        } catch (\Exception $e) {
457
-            $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage();
456
+        }catch (\Exception $e) {
457
+            $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage();
458 458
             Logger::log($e->getMessage(), LOG_ERR);
459 459
         }
460 460
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
                     $this->model->delete($this->con);
485 485
                     $deleted = TRUE;
486 486
                 }
487
-            } catch (\Exception $e) {
487
+            }catch (\Exception $e) {
488 488
                 $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados');
489 489
                 Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
490 490
             }
@@ -519,14 +519,14 @@  discard block
 block discarded – undo
519 519
                     $updated = TRUE;
520 520
                     $status = 200;
521 521
                     $model = $this->model->toArray();
522
-                } else {
522
+                }else {
523 523
                     $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
524 524
                 }
525
-            } catch (\Exception $e) {
525
+            }catch (\Exception $e) {
526 526
                 $model = $e->getMessage();
527 527
                 Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
528 528
             }
529
-        } else {
529
+        }else {
530 530
             $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
531 531
         }
532 532
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
      */
539 539
     private function extractQuery()
540 540
     {
541
-        $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query");
541
+        $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query");
542 542
         /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */
543 543
         $query = $queryReflector->getMethod('create')->invoke($this->con);
544 544
 
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
         if (null !== $this->con && $this->con->inTransaction()) {
583 583
             if ($status === 200) {
584 584
                 $this->con->commit();
585
-            } else {
585
+            }else {
586 586
                 $this->con->rollBack();
587 587
             }
588 588
         }
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
             "domain" => $this->getDomain(),
635 635
             "listLabel" => self::API_LIST_NAME_FIELD,
636 636
             'modelId' => self::API_MODEL_KEY_FIELD,
637
-            'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)),
638
-            "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)),
637
+            'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)),
638
+            "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)),
639 639
         ), [], '');
640 640
     }
641 641
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
                 $total = $this->list->getNbResults();
676 676
                 $pages = $this->list->getLastPage();
677 677
             }
678
-        } catch (\Exception $e) {
678
+        }catch (\Exception $e) {
679 679
             Logger::getInstance(get_class($this))->errorLog($e->getMessage());
680 680
         }
681 681
 
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
         $return = array();
695 695
         if (NULL === $model && method_exists($model, 'toArray')) {
696 696
             $code = 404;
697
-        } else {
697
+        }else {
698 698
             $return = $model->toArray();
699 699
         }
700 700
 
@@ -709,9 +709,9 @@  discard block
 block discarded – undo
709 709
         $pks = '';
710 710
         $sep = '';
711 711
         foreach ($tableMap->getPrimaryKeys() as $pk) {
712
-            $pks .= $sep . $pk->getFullyQualifiedName();
712
+            $pks .= $sep.$pk->getFullyQualifiedName();
713 713
             $sep = ', "|", ';
714 714
         }
715
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = self::API_LIST_NAME_FIELD;
715
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = self::API_LIST_NAME_FIELD;
716 716
     }
717 717
 }
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
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::getInstance()->getDebugMode()) {
68 68
             $this->debugLoad();
69 69
         }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
                 "success" => FALSE,
102 102
                 "error" => $e->getMessage(),
103 103
             )), 'application/json');
104
-        } else {
104
+        }else {
105 105
             return $template->render('error.html.twig', array(
106 106
                 'exception' => $e,
107 107
                 'trace' => $e->getTraceAsString(),
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
             SecurityHelper::checkRestrictedAccess($route);
160 160
             //Search action and execute
161 161
             $this->searchAction($route);
162
-        } catch (AccessDeniedException $e) {
162
+        }catch (AccessDeniedException $e) {
163 163
             Logger::log(_('Solicitamos credenciales de acceso a zona restringida'));
164 164
             return Admin::staticAdminLogon($route);
165
-        } catch (RouterException $r) {
165
+        }catch (RouterException $r) {
166 166
             Logger::log($r->getMessage(), LOG_WARNING);
167
-        } catch (\Exception $e) {
167
+        }catch (\Exception $e) {
168 168
             Logger::log($e->getMessage(), LOG_ERR);
169 169
             throw $e;
170 170
         }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      */
182 182
     protected function searchAction($route)
183 183
     {
184
-        Logger::log('Searching action to execute: ' . $route, LOG_INFO);
184
+        Logger::log('Searching action to execute: '.$route, LOG_INFO);
185 185
         //Revisamos si tenemos la ruta registrada
186 186
         $parts = parse_url($route);
187 187
         $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                 $class = RouterHelper::getClassToCall($action);
196 196
                 try {
197 197
                     $this->executeCachedRoute($route, $action, $class, $get);
198
-                } catch (\Exception $e) {
198
+                }catch (\Exception $e) {
199 199
                     Logger::log($e->getMessage(), LOG_ERR);
200 200
                     throw new \RuntimeException($e->getMessage(), 404, $e);
201 201
                 }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      */
219 219
     private function getExternalModules() {
220 220
         $externalModules = Config::getParam('modules.extend', '');
221
-        if(Config::getParam('psfs.auth', false)) {
221
+        if (Config::getParam('psfs.auth', false)) {
222 222
             $externalModules .= ',psfs/auth';
223 223
         }
224 224
         return $externalModules;
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
             $externalModules = explode(',', $externalModules);
236 236
             foreach ($externalModules as &$module) {
237 237
                 $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
238
-                $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
238
+                $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
239 239
                 if (file_exists($externalModulePath)) {
240 240
                     $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
241 241
                     if (!empty($externalModule)) {
242 242
                         foreach ($externalModule as $modulePath) {
243 243
                             $extModule = $modulePath->getBasename();
244
-                            $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
244
+                            $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
245 245
                             if (file_exists($moduleAutoloader)) {
246 246
                                 @include $moduleAutoloader;
247 247
                                 if ($hydrateRoute) {
248
-                                    $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing);
248
+                                    $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing);
249 249
                                 }
250 250
                             }
251 251
                         }
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
269 269
             foreach ($modules as $modulePath) {
270 270
                 $module = $modulePath->getBasename();
271
-                $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
271
+                $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
272 272
             }
273 273
         }
274
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);
274
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);
275 275
     }
276 276
 
277 277
     /**
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
             $home_params = NULL;
287 287
             foreach ($this->routing as $pattern => $params) {
288 288
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
289
-                if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) {
289
+                if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) {
290 290
                     $home_params = $params;
291 291
                 }
292 292
             }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php");
312 312
         foreach ($files as $file) {
313 313
             $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname()));
314
-            $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
314
+            $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
315 315
         }
316 316
         $this->finder = new Finder();
317 317
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             if (!$this->domains) {
382 382
                 $this->domains = [];
383 383
             }
384
-            $domain = "@" . $class->getConstant("DOMAIN") . "/";
384
+            $domain = "@".$class->getConstant("DOMAIN")."/";
385 385
             if (!array_key_exists($domain, $this->domains)) {
386 386
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
387 387
             }
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
      */
397 397
     public function simpatize()
398 398
     {
399
-        $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";
400
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
399
+        $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";
400
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
401 401
         $this->generateSlugs($absoluteTranslationFileName);
402 402
         GeneratorHelper::createDir(CONFIG_DIR);
403
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
403
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
404 404
 
405 405
         return $this;
406 406
     }
@@ -418,16 +418,16 @@  discard block
 block discarded – undo
418 418
     public function getRoute($slug = '', $absolute = FALSE, $params = [])
419 419
     {
420 420
         if (strlen($slug) === 0) {
421
-            return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';
421
+            return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';
422 422
         }
423 423
         if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
424 424
             throw new RouterException(_("No existe la ruta especificada"));
425 425
         }
426
-        $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
426
+        $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
427 427
         if (!empty($params)) foreach ($params as $key => $value) {
428
-            $url = str_replace("{" . $key . "}", $value, $url);
428
+            $url = str_replace("{".$key."}", $value, $url);
429 429
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
430
-            $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
430
+            $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
431 431
         }
432 432
 
433 433
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -472,18 +472,18 @@  discard block
 block discarded – undo
472 472
      */
473 473
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
474 474
     {
475
-        Logger::log('Executing route ' . $route, LOG_INFO);
475
+        Logger::log('Executing route '.$route, LOG_INFO);
476 476
         Security::getInstance()->setSessionKey("__CACHE__", $action);
477 477
         $cache = Cache::needCache();
478 478
         $execute = TRUE;
479 479
         if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) {
480 480
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
481
-            $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName,
482
-                $cache, function () {
481
+            $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$path.$cacheDataName,
482
+                $cache, function() {
483 483
                 });
484 484
             if (NULL !== $cachedData) {
485
-                $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers",
486
-                    $cache, function () {
485
+                $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers",
486
+                    $cache, function() {
487 487
                     }, Cache::JSON);
488 488
                 Template::getInstance()->renderCache($cachedData, $headers);
489 489
                 $execute = FALSE;
Please login to merge, or discard this patch.