Passed
Push — master ( c4dde1...728bda )
by Fran
03:38
created
src/base/types/helpers/SecurityHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         if (!Config::getInstance()->checkTryToSaveConfig()
23 23
             && (preg_match('/^\/(admin|setup\-admin)/i', $route) || NULL !== Config::getInstance()->get('restricted'))
24 24
         ) {
25
-            if(!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
25
+            if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
26 26
                 //Si no hay fichero de usuarios redirigimos directamente al gestor
27 27
                 return UserController::showAdminManager();
28 28
             }
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.