Passed
Push — master ( b24160...c4dde1 )
by Fran
04:32
created
src/bootstrap.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
 
5 5
 if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
6 6
 if (preg_match('/vendor/', SOURCE_DIR)) {
7
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
8
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
9
-} else {
10
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
11
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
7
+    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..');
8
+    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src');
9
+}else {
10
+    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..');
11
+    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules');
12 12
 }
13
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
14
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
15
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
16
-if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
13
+if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
14
+if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache');
15
+if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config');
16
+if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html');
17 17
 
18 18
 //Cargamos en memoria la función de desarrollo PRE
19 19
 if (!function_exists('pre')) {
Please login to merge, or discard this patch.
Braces   +32 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,19 +1,39 @@
 block discarded – undo
1 1
 <?php
2
-if (defined('PSFS_BOOTSTRAP_LOADED')) return;
2
+if (defined('PSFS_BOOTSTRAP_LOADED')) {
3
+    return;
4
+}
3 5
 use Symfony\Component\Finder\Finder;
4 6
 
5
-if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
7
+if (!defined('SOURCE_DIR')) {
8
+    define('SOURCE_DIR', __DIR__);
9
+}
6 10
 if (preg_match('/vendor/', SOURCE_DIR)) {
7
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
8
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
9
-} else {
10
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
11
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
12
-}
13
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
14
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
15
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
16
-if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
11
+    if (!defined('BASE_DIR')) {
12
+        define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
13
+    }
14
+    if (!defined('CORE_DIR')) {
15
+        define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
16
+    }
17
+    } else {
18
+    if (!defined('BASE_DIR')) {
19
+        define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
20
+    }
21
+    if (!defined('CORE_DIR')) {
22
+        define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
23
+    }
24
+    }
25
+if (!defined('LOG_DIR')) {
26
+    define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
27
+}
28
+if (!defined('CACHE_DIR')) {
29
+    define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
30
+}
31
+if (!defined('CONFIG_DIR')) {
32
+    define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
33
+}
34
+if (!defined('WEB_DIR')) {
35
+    define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
36
+}
17 37
 
18 38
 //Cargamos en memoria la función de desarrollo PRE
19 39
 if (!function_exists('pre')) {
Please login to merge, or discard this patch.
src/base/types/Api.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
     namespace PSFS\base\types;
3 3
 
4
-    use Propel\Runtime\ActiveQuery\Criteria;
5 4
     use Propel\Runtime\ActiveQuery\ModelCriteria;
6 5
     use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
7 6
     use Propel\Runtime\Connection\ConnectionInterface;
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
          *
169 169
          * @param ModelCriteria $query
170 170
          */
171
-        private function addOrders(ModelCriteria &$query)
171
+        private function addOrders(ModelCriteria & $query)
172 172
         {
173 173
             $orderAdded = FALSE;
174 174
             $tableMap = $this->getTableMap();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                     $orderAdded = TRUE;
178 178
                     if ($direction === Order::ASC) {
179 179
                         $query->addAscendingOrderByColumn($column->getPhpName());
180
-                    } else {
180
+                    }else {
181 181
                         $query->addDescendingOrderByColumn($column->getPhpName());
182 182
                     }
183 183
                 }
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
          * Method that add a new field with the Label of the row
192 192
          */
193 193
         private function addDefaultListField() {
194
-            if(!in_array(self::API_LIST_NAME_FIELD, $this->extraColumns)) {
194
+            if (!in_array(self::API_LIST_NAME_FIELD, $this->extraColumns)) {
195 195
                 $tableMap = $this->getTableMap();
196 196
                 $column = null;
197
-                if($tableMap->hasColumn('NAME')) {
197
+                if ($tableMap->hasColumn('NAME')) {
198 198
                     $column = $tableMap->getColumn('NAME');
199
-                } elseif($tableMap->hasColumn('TITLE')) {
199
+                } elseif ($tableMap->hasColumn('TITLE')) {
200 200
                     $column = $tableMap->getColumn('TITLE');
201
-                } elseif($tableMap->hasColumn('LABEL')) {
201
+                } elseif ($tableMap->hasColumn('LABEL')) {
202 202
                     $column = $tableMap->getColumn('LABEL');
203 203
                 }
204
-                if(null !== $column) {
204
+                if (null !== $column) {
205 205
                     $this->extraColumns[$column->getFullyQualifiedName()] = self::API_LIST_NAME_FIELD;
206
-                } else {
206
+                }else {
207 207
                     $this->addClassListName($tableMap);
208 208
                 }
209 209
             }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
          *
215 215
          * @param ModelCriteria $query
216 216
          */
217
-        private function addExtraColumns(ModelCriteria &$query)
217
+        private function addExtraColumns(ModelCriteria & $query)
218 218
         {
219 219
             $this->addDefaultListField();
220 220
             if (!empty($this->extraColumns)) {
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
          *
230 230
          * @param ModelCriteria $query
231 231
          */
232
-        protected function joinTables(ModelCriteria &$query)
232
+        protected function joinTables(ModelCriteria & $query)
233 233
         {
234 234
             //TODO for specific implementations
235 235
         }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
          */
240 240
         protected function parseExtraColumns() {
241 241
             $columns = [];
242
-            foreach($this->extraColumns as $key => $columnName) {
242
+            foreach ($this->extraColumns as $key => $columnName) {
243 243
                 $columns[$columnName] = strtolower($columnName);
244 244
             }
245 245
             return $columns;
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
          *
251 251
          * @param ModelCriteria $query
252 252
          */
253
-        private function addFilters(ModelCriteria &$query)
253
+        private function addFilters(ModelCriteria & $query)
254 254
         {
255 255
             if (count($this->query) > 0) {
256 256
                 $tableMap = $this->getTableMap();
257 257
                 foreach ($this->query as $field => $value) {
258
-                    if(self::API_COMBO_FIELD === $field) {
258
+                    if (self::API_COMBO_FIELD === $field) {
259 259
                         ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
260
-                    } else {
260
+                    }else {
261 261
                         ApiHelper::addModelField($tableMap, $query, $field, $value);
262 262
                     }
263 263
                 }
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
                 list($page, $limit) = $this->extractPagination();
280 280
                 if ($limit == -1) {
281 281
                     $this->list = $query->find($this->con);
282
-                } else {
282
+                }else {
283 283
                     $this->list = $query->paginate($page, $limit, $this->con);
284 284
                 }
285
-            } catch (\Exception $e) {
285
+            }catch (\Exception $e) {
286 286
                 Logger::log($e->getMessage(), LOG_ERR);
287 287
             }
288 288
         }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                 $this->joinTables($query);
300 300
                 $this->addExtraColumns($query);
301 301
                 $this->model = $query->findPk($pk);
302
-            } catch (\Exception $e) {
302
+            }catch (\Exception $e) {
303 303
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
304 304
             }
305 305
         }
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
                     $saved = TRUE;
388 388
                     $model = $this->model->toArray();
389 389
                 }
390
-            } catch (\Exception $e) {
391
-                $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage();
390
+            }catch (\Exception $e) {
391
+                $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage();
392 392
                 Logger::log($e->getMessage(), LOG_ERR);
393 393
             }
394 394
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
                         $this->model->delete($this->con);
418 418
                         $deleted = TRUE;
419 419
                     }
420
-                } catch (\Exception $e) {
420
+                }catch (\Exception $e) {
421 421
                     $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados');
422 422
                     Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
423 423
                 }
@@ -451,14 +451,14 @@  discard block
 block discarded – undo
451 451
                         $updated = TRUE;
452 452
                         $status = 200;
453 453
                         $model = $this->model->toArray();
454
-                    } else {
454
+                    }else {
455 455
                         $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
456 456
                     }
457
-                } catch(\Exception $e) {
457
+                }catch (\Exception $e) {
458 458
                     $model = $e->getMessage();
459 459
                     Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
460 460
                 }
461
-            } else {
461
+            }else {
462 462
                 $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
463 463
             }
464 464
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
          */
471 471
         private function extractQuery()
472 472
         {
473
-            $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query");
473
+            $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query");
474 474
             /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */
475 475
             $query = $queryReflector->getMethod('create')->invoke($this->con);
476 476
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
             if (null !== $this->con && $this->con->inTransaction()) {
515 515
                 if ($status === 200) {
516 516
                     $this->con->commit();
517
-                } else {
517
+                }else {
518 518
                     $this->con->rollBack();
519 519
                 }
520 520
             }
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
             return $this->render('api.admin.html.twig', array(
559 559
                 "api"    => $this->getApi(),
560 560
                 "domain" => $this->domain,
561
-                "url"    => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)),
561
+                "url"    => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)),
562 562
             ), [], '');
563 563
         }
564 564
 
@@ -592,12 +592,12 @@  discard block
 block discarded – undo
592 592
             $pages = 0;
593 593
             try {
594 594
                 $this->paginate();
595
-                if(null !== $this->list) {
595
+                if (null !== $this->list) {
596 596
                     $return = $this->list->toArray();
597 597
                     $total = $this->list->getNbResults();
598 598
                     $pages = $this->list->getLastPage();
599 599
                 }
600
-            } catch (\Exception $e) {
600
+            }catch (\Exception $e) {
601 601
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
602 602
             }
603 603
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
             $return = array();
617 617
             if (NULL === $model && method_exists($model, 'toArray')) {
618 618
                 $code = 404;
619
-            } else {
619
+            }else {
620 620
                 $return = $model->toArray();
621 621
             }
622 622
 
@@ -631,10 +631,10 @@  discard block
 block discarded – undo
631 631
             $pks = '';
632 632
             $sep = '';
633 633
             foreach ($tableMap->getPrimaryKeys() as $pk) {
634
-                $pks .= $sep . $pk->getFullyQualifiedName();
634
+                $pks .= $sep.$pk->getFullyQualifiedName();
635 635
                 $sep = ', "|", ';
636 636
             }
637
-            $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = self::API_LIST_NAME_FIELD;
637
+            $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = self::API_LIST_NAME_FIELD;
638 638
         }
639 639
 
640 640
         /**
Please login to merge, or discard this patch.
src/base/types/helpers/ApiHelper.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@
 block discarded – undo
192 192
 
193 193
     /**
194 194
      * @param ColumnMap $column
195
-     * @param ModelCriteria $quwuery
195
+     * @param ModelCriteria $query
196 196
      * @param mixed $value
197 197
      */
198 198
     private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
                 $fDto = self::generatePasswordField($field, $required);
46 46
             } elseif (in_array($mappedColumn->getType(), [PropelTypes::TIMESTAMP])) {
47 47
                 $fDto = self::createField($field, Field::TEXT_TYPE, $required);
48
-            } elseif(in_array($mappedColumn->getType(), [PropelTypes::ENUM, PropelTypes::SET])) {
48
+            } elseif (in_array($mappedColumn->getType(), [PropelTypes::ENUM, PropelTypes::SET])) {
49 49
                 $fDto = self::generateEnumField($field, $required);
50
-                foreach($mappedColumn->getValueSet() as $value) {
50
+                foreach ($mappedColumn->getValueSet() as $value) {
51 51
                     $fDto->data[] = [
52 52
                         $field => $value,
53 53
                         "Label" => _($value),
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                 }
56 56
             }
57 57
 
58
-            if(null !== $fDto) {
58
+            if (null !== $fDto) {
59 59
                 $form->addField($fDto);
60 60
             }
61 61
         }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         $fDto->entity = $relatedModel;
79 79
         $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName());
80 80
         $fDto->relatedField = $relatedField->getPhpName();
81
-        $fDto->url = Router::getInstance()->getRoute('api-' . $relatedModel);
81
+        $fDto->url = Router::getInstance()->getRoute('api-'.$relatedModel);
82 82
         return $fDto;
83 83
     }
84 84
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     public static function checkFieldExists(TableMap $tableMap, $field) {
184 184
         try {
185 185
             $column = $tableMap->getColumnByPhpName($field);
186
-        } catch(\Exception $e) {
186
+        }catch (\Exception $e) {
187 187
             Logger::log($e->getMessage(), LOG_ERR);
188 188
             $column = null;
189 189
         }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      * @param ModelCriteria $quwuery
196 196
      * @param mixed $value
197 197
      */
198
-    private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) {
198
+    private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null) {
199 199
         $tableField = $column->getPhpName();
200 200
         if (preg_match('/^<=/', $value)) {
201 201
             $query->filterBy($tableField, substr($value, 2, strlen($value)), Criteria::LESS_EQUAL);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             $text = preg_replace('/(\'|\")/', '', $value);
210 210
             $text = preg_replace('/\ /', '%', $text);
211 211
             $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE);
212
-        } else {
212
+        }else {
213 213
             $query->filterBy($tableField, $value, Criteria::EQUAL);
214 214
         }
215 215
     }
@@ -220,23 +220,23 @@  discard block
 block discarded – undo
220 220
      * @param array $extraColumns
221 221
      * @param mixed $value
222 222
      */
223
-    public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null) {
223
+    public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null) {
224 224
         $exp = 'CONCAT(';
225 225
         $sep = '';
226
-        foreach($tableMap->getColumns() as $column) {
227
-            if($column->isText()) {
228
-                $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")';
226
+        foreach ($tableMap->getColumns() as $column) {
227
+            if ($column->isText()) {
228
+                $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")';
229 229
                 $sep = ', " ", ';
230 230
             }
231 231
         }
232
-        foreach($extraColumns as $extra => $name) {
233
-            $exp .= $sep . $extra;
232
+        foreach ($extraColumns as $extra => $name) {
233
+            $exp .= $sep.$extra;
234 234
             $sep = ', " ", ';
235 235
         }
236 236
         $exp .= ")";
237 237
         $text = preg_replace('/(\'|\")/', '', $value);
238 238
         $text = preg_replace('/\ /', '%', $text);
239
-        $query->where($exp . Criteria::LIKE . '"%' . $text . '%"');
239
+        $query->where($exp.Criteria::LIKE.'"%'.$text.'%"');
240 240
     }
241 241
 
242 242
     /**
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      * @param string $field
247 247
      * @param mixed $value
248 248
      */
249
-    public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null) {
249
+    public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null) {
250 250
         if ($column = self::checkFieldExists($tableMap, $field)) {
251 251
             self::addQueryFilter($column, $query, $value);
252 252
         }
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
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
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 "success" => FALSE,
89 89
                 "error" => $e->getMessage(),
90 90
             )), 'application/json');
91
-        } else {
91
+        }else {
92 92
             return $template->render('error.html.twig', array(
93 93
                 'exception' => $e,
94 94
                 'trace' => $e->getTraceAsString(),
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public function getAllRoutes() {
114 114
         $routes = [];
115
-        foreach($this->routing as $path => $route) {
116
-            if(array_key_exists('slug', $route)) {
115
+        foreach ($this->routing as $path => $route) {
116
+            if (array_key_exists('slug', $route)) {
117 117
                 $routes[$route['slug']] = $path;
118 118
             }
119 119
         }
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
             SecurityHelper::checkRestrictedAccess($route);
139 139
             //Search action and execute
140 140
             $this->searchAction($route);
141
-        } catch (AccessDeniedException $e) {
141
+        }catch (AccessDeniedException $e) {
142 142
             Logger::log(_('Solicitamos credenciales de acceso a zona restringida'));
143 143
             return Admin::staticAdminLogon($route);
144
-        } catch (RouterException $r) {
144
+        }catch (RouterException $r) {
145 145
             Logger::log($r->getMessage(), LOG_WARNING);
146
-        } catch (\Exception $e) {
146
+        }catch (\Exception $e) {
147 147
             Logger::log($e->getMessage(), LOG_ERR);
148 148
             throw $e;
149 149
         }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     protected function searchAction($route)
162 162
     {
163
-        Logger::log('Searching action to execute: ' . $route, LOG_INFO);
163
+        Logger::log('Searching action to execute: '.$route, LOG_INFO);
164 164
         //Revisamos si tenemos la ruta registrada
165 165
         $parts = parse_url($route);
166 166
         $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route;
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
                 $class = RouterHelper::getClassToCall($action);
175 175
                 try {
176 176
                     $this->executeCachedRoute($route, $action, $class, $get);
177
-                } catch (\Exception $e) {
177
+                }catch (\Exception $e) {
178 178
                     Logger::log($e->getMessage(), LOG_ERR);
179 179
                     throw new RouterException($e->getMessage(), 404, $e);
180 180
                 }
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
         $this->routing = $this->inspectDir($base, "PSFS", array());
203 203
         if (file_exists($modulesPath)) {
204 204
             $module = "";
205
-            if(file_exists($modulesPath . DIRECTORY_SEPARATOR . 'module.json')) {
206
-                $mod_cfg = json_decode(file_get_contents($modulesPath . DIRECTORY_SEPARATOR . 'module.json'), true);
205
+            if (file_exists($modulesPath.DIRECTORY_SEPARATOR.'module.json')) {
206
+                $mod_cfg = json_decode(file_get_contents($modulesPath.DIRECTORY_SEPARATOR.'module.json'), true);
207 207
                 $module = $mod_cfg['module'];
208 208
             }
209 209
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
210
-            foreach($modules as $modulePath) {
210
+            foreach ($modules as $modulePath) {
211 211
                 $module = $modulePath->getBasename();
212
-                $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
212
+                $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
213 213
             }
214 214
         }
215
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);
215
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);
216 216
     }
217 217
 
218 218
     /**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
             $home_params = NULL;
228 228
             foreach ($this->routing as $pattern => $params) {
229 229
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
230
-                if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) {
230
+                if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) {
231 231
                     $home_params = $params;
232 232
                 }
233 233
             }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php");
253 253
         foreach ($files as $file) {
254 254
             $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname()));
255
-            $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
255
+            $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
256 256
         }
257 257
         $this->finder = new Finder();
258 258
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
                 }
293 293
                 foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
294 294
                     list($route, $info) = RouterHelper::extractRouteInfo($method, $api, $module);
295
-                    if(null !== $route && null !== $info) {
295
+                    if (null !== $route && null !== $info) {
296 296
                         $info['class'] = $namespace;
297 297
                         $routing[$route] = $info;
298 298
                     }
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
     {
316 316
         //Calculamos los dominios para las plantillas
317 317
         if ($class->hasConstant("DOMAIN") && !$class->isAbstract()) {
318
-            if(!$this->domains) {
318
+            if (!$this->domains) {
319 319
                 $this->domains = [];
320 320
             }
321
-            $domain = "@" . $class->getConstant("DOMAIN") . "/";
322
-            if(!array_key_exists($domain, $this->domains)) {
321
+            $domain = "@".$class->getConstant("DOMAIN")."/";
322
+            if (!array_key_exists($domain, $this->domains)) {
323 323
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
324 324
             }
325 325
         }
@@ -333,11 +333,11 @@  discard block
 block discarded – undo
333 333
      */
334 334
     public function simpatize()
335 335
     {
336
-        $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";
337
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
336
+        $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";
337
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
338 338
         $this->generateSlugs($absoluteTranslationFileName);
339 339
         Config::createDir(CONFIG_DIR);
340
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
340
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
341 341
 
342 342
         return $this;
343 343
     }
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
     public function getRoute($slug = '', $absolute = FALSE, $params = [])
356 356
     {
357 357
         if (strlen($slug) === 0) {
358
-            return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';
358
+            return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';
359 359
         }
360 360
         if (NULL === $slug || !array_key_exists($slug, $this->slugs)) {
361 361
             throw new RouterException(_("No existe la ruta especificada"));
362 362
         }
363
-        $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
363
+        $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
364 364
         if (!empty($params)) foreach ($params as $key => $value) {
365
-            $url = str_replace("{" . $key . "}", $value, $url);
365
+            $url = str_replace("{".$key."}", $value, $url);
366 366
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
367
-            $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
367
+            $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
368 368
         }
369 369
 
370 370
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -407,25 +407,25 @@  discard block
 block discarded – undo
407 407
      */
408 408
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
409 409
     {
410
-        Logger::log('Executing route ' . $route, LOG_INFO);
410
+        Logger::log('Executing route '.$route, LOG_INFO);
411 411
         Security::getInstance()->setSessionKey("__CACHE__", $action);
412 412
         $cache = Cache::needCache();
413 413
         $execute = TRUE;
414 414
         if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) {
415 415
             $cacheDataName = $this->cache->getRequestCacheHash();
416
-            $tmpDir = substr($cacheDataName, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheDataName, 2, 2) . DIRECTORY_SEPARATOR;
417
-            $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName,
418
-                $cache, function () {});
416
+            $tmpDir = substr($cacheDataName, 0, 2).DIRECTORY_SEPARATOR.substr($cacheDataName, 2, 2).DIRECTORY_SEPARATOR;
417
+            $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName,
418
+                $cache, function() {});
419 419
             if (NULL !== $cachedData) {
420
-                $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName . ".headers",
421
-                    $cache, function () {}, Cache::JSON);
420
+                $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName.".headers",
421
+                    $cache, function() {}, Cache::JSON);
422 422
                 Template::getInstance()->renderCache($cachedData, $headers);
423 423
                 $execute = FALSE;
424 424
             }
425 425
         }
426 426
         if ($execute) {
427 427
             Logger::log(_('Start executing action'), LOG_DEBUG);
428
-            if(false === call_user_func_array(array($class, $action['method']), $params)) {
428
+            if (false === call_user_func_array(array($class, $action['method']), $params)) {
429 429
                 Logger::log(_('An error ocurred trying to execute the action'), LOG_ERR, [error_get_last()]);
430 430
             }
431 431
         }
Please login to merge, or discard this patch.
src/base/types/helpers/RouterHelper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public static function getClassToCall($action)
21 21
     {
22 22
         Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action);
23
-        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"];
23
+        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"];
24 24
         $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass;
25 25
         return $class;
26 26
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         $expr = preg_quote($expr, '/');
107 107
         $expr = str_replace('###', '(.*)', $expr);
108 108
         $expr2 = preg_replace('/\(\.\*\)$/', '', $expr);
109
-        $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path);
109
+        $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path);
110 110
         return $matched;
111 111
     }
112 112
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public static function extractDomainInfo(\ReflectionClass $class, $domain)
119 119
     {
120
-        $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
121
-        $path = realpath($path) . DIRECTORY_SEPARATOR;
120
+        $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
121
+        $path = realpath($path).DIRECTORY_SEPARATOR;
122 122
         $tpl_path = "templates";
123 123
         $public_path = "public";
124 124
         $model_path = "models";
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
             $model_path = ucfirst($model_path);
129 129
         }
130 130
         if ($class->hasConstant("TPL")) {
131
-            $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL");
131
+            $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL");
132 132
         }
133 133
         return [
134
-            "template" => $path . $tpl_path,
135
-            "model" => $path . $model_path,
136
-            "public" => $path . $public_path,
134
+            "template" => $path.$tpl_path,
135
+            "model" => $path.$model_path,
136
+            "public" => $path.$public_path,
137 137
         ];
138 138
     }
139 139
 
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
         if (count($parameters) > 0) foreach ($parameters as $param) {
156 156
             if ($param->isOptional() && !is_array($param->getDefaultValue())) {
157 157
                 $params[$param->getName()] = $param->getDefaultValue();
158
-                $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
158
+                $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex);
159 159
             }
160
-        } else $default = $regex;
160
+        }else $default = $regex;
161 161
 
162 162
         return array($regex, $default, $params);
163 163
     }
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
     {
226 226
         $is_enabled = true;
227 227
         // For non api routes
228
-        if(strlen($api) > 0 && preg_match('/admin/i', $route)) {
228
+        if (strlen($api) > 0 && preg_match('/admin/i', $route)) {
229 229
             // If route is for api, check if admin is enabled in config
230 230
             $admin_enabled = Config::getInstance()->get('api.admin');
231
-            if(empty($admin_enabled)) {
231
+            if (empty($admin_enabled)) {
232 232
                 $is_enabled = false;
233 233
             }
234 234
         }
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
             $default = str_replace('{__DOMAIN__}', $module, $default);
257 257
             $httpMethod = RouterHelper::extractReflectionHttpMethod($docComments);
258 258
             $label = RouterHelper::extractReflectionLabel($docComments);
259
-            if(self::checkCanAddRoute($regex, $api)) {
260
-                $route = $httpMethod . "#|#" . $regex;
259
+            if (self::checkCanAddRoute($regex, $api)) {
260
+                $route = $httpMethod."#|#".$regex;
261 261
                 $info = [
262 262
                     "method" => $method->getName(),
263 263
                     "params" => $params,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             $default = Config::getInstance()->get('admin_action') ?: 'admin-login';
286 286
 
287 287
         }
288
-        if(null !== $default) {
288
+        if (null !== $default) {
289 289
             return Router::getInstance()->execute(Router::getInstance()->getRoute($default));
290 290
         }
291 291
         return null;
Please login to merge, or discard this patch.