Passed
Push — master ( 5f2aa2...8a1343 )
by Fran
02:37
created
src/base/types/traits/Api/MutationTrait.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         if (count($pks) === 1) {
81 81
             $pks = array_keys($pks);
82 82
             return [
83
-                $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD
83
+                $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD
84 84
             ];
85 85
         }
86 86
         if (count($pks) > 1) {
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
             $principal = '';
89 89
             $sep = 'CONCAT(';
90 90
             foreach ($pks as $pk) {
91
-                $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName();
92
-                $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName();
93
-                $sep = ', "' . Api::API_PK_SEPARATOR . '", ';
91
+                $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName();
92
+                $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName();
93
+                $sep = ', "'.Api::API_PK_SEPARATOR.'", ';
94 94
             }
95 95
             $principal .= ')';
96 96
             $apiPks[$principal] = Api::API_MODEL_KEY_FIELD;
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
         $pks = '';
118 118
         $sep = '';
119 119
         foreach ($tableMap->getPrimaryKeys() as $pk) {
120
-            $pks .= $sep . $pk->getFullyQualifiedName();
120
+            $pks .= $sep.$pk->getFullyQualifiedName();
121 121
             $sep = ', "|", ';
122 122
         }
123
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD;
123
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD;
124 124
     }
125 125
 
126 126
     /**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             }
143 143
             if (null !== $column) {
144 144
                 $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD;
145
-            } else {
145
+            }else {
146 146
                 $this->addClassListName($tableMap);
147 147
             }
148 148
         }
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
             $this->addPkToList();
162 162
         }
163 163
         if (!empty($this->extraColumns)) {
164
-            if(Config::getParam('api.extrafields.compat', true)) {
164
+            if (Config::getParam('api.extrafields.compat', true)) {
165 165
                 $fields = array_values($this->extraColumns);
166
-            } else {
166
+            }else {
167 167
                 $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD);
168 168
                 $fields = explode(',', $returnFields ?: '');
169 169
                 $fields[] = self::API_MODEL_KEY_FIELD;
170 170
             }
171 171
             foreach ($this->extraColumns as $expression => $columnName) {
172
-                if(empty($fields) || in_array($columnName, $fields)) {
172
+                if (empty($fields) || in_array($columnName, $fields)) {
173 173
                     $query->withColumn($expression, $columnName);
174 174
                 }
175 175
             }
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
     {
202 202
         $this->extractApiLang();
203 203
         $model = $this->getModelNamespace();
204
-        $modelI18n = $model . 'I18n';
204
+        $modelI18n = $model.'I18n';
205 205
         if (method_exists($query, 'useI18nQuery')) {
206 206
             $query->useI18nQuery($this->lang);
207
-            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n) . 'TableMap';
207
+            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n).'TableMap';
208 208
             /** @var TableMap $modelI18nTableMap */
209 209
             $modelI18nTableMap = $modelI18nTableMapClass::getTableMap();
210
-            foreach($modelI18nTableMap->getColumns() as $columnMap) {
211
-                if(!$columnMap->isPrimaryKey()) {
210
+            foreach ($modelI18nTableMap->getColumns() as $columnMap) {
211
+                if (!$columnMap->isPrimaryKey()) {
212 212
                     $query->withColumn($columnMap->getFullyQualifiedName(), ApiHelper::getColumnMapName($columnMap));
213
-                } elseif(!$columnMap->isForeignKey()) {
214
-                    $query->withColumn('IFNULL(' . $columnMap->getFullyQualifiedName() . ', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap));
213
+                } elseif (!$columnMap->isForeignKey()) {
214
+                    $query->withColumn('IFNULL('.$columnMap->getFullyQualifiedName().', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap));
215 215
                 }
216 216
             }
217 217
         }
@@ -225,22 +225,22 @@  discard block
 block discarded – undo
225 225
         $model->fromArray($data, ApiHelper::getFieldTypes());
226 226
         $tableMap = $this->getTableMap();
227 227
         try {
228
-            if($tableMap->hasRelation($tableMap->getPhpName() . 'I18n'))
228
+            if ($tableMap->hasRelation($tableMap->getPhpName().'I18n'))
229 229
             {
230
-                $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n');
230
+                $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n');
231 231
                 $i18NTableMap = $relateI18n->getLocalTable();
232 232
                 $model->setLocale($this->lang);
233
-                foreach($i18NTableMap->getColumns() as $columnMap) {
234
-                    $method = 'set' . $columnMap->getPhpName();
233
+                foreach ($i18NTableMap->getColumns() as $columnMap) {
234
+                    $method = 'set'.$columnMap->getPhpName();
235 235
                     $dtoColumnName = ApiHelper::getColumnMapName($columnMap);
236
-                    if(array_key_exists($dtoColumnName, $data)
236
+                    if (array_key_exists($dtoColumnName, $data)
237 237
                         && method_exists($model, $method)
238 238
                         && !($columnMap->isPrimaryKey() && $columnMap->isForeignKey())) {
239 239
                         $model->$method($data[$dtoColumnName]);
240 240
                     }
241 241
                 }
242 242
             }
243
-        } catch(\Exception $e) {
243
+        }catch (\Exception $e) {
244 244
             Logger::log($e->getMessage(), LOG_DEBUG);
245 245
         }
246 246
     }
Please login to merge, or discard this patch.
src/base/types/Api.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
     public function init()
82 82
     {
83 83
         parent::init();
84
-        Logger::log(static::class . ' init', LOG_DEBUG);
84
+        Logger::log(static::class.' init', LOG_DEBUG);
85 85
         $this->domain = $this->getDomain();
86 86
         $this->hydrateRequestData();
87 87
         $this->hydrateOrders();
88
-        if($this instanceof CustomApi === false) {
88
+        if ($this instanceof CustomApi === false) {
89 89
             $this->createConnection($this->getTableMap());
90 90
         }
91 91
         $this->checkFieldType();
92 92
         $this->setLoaded(true);
93
-        Logger::log(static::class . ' loaded', LOG_DEBUG);
93
+        Logger::log(static::class.' loaded', LOG_DEBUG);
94 94
     }
95 95
 
96 96
     private function checkActions($method) {
97
-        switch($method) {
97
+        switch ($method) {
98 98
             default:
99 99
             case 'modelList': $this->action = self::API_ACTION_LIST; break;
100 100
             case 'get': $this->action = self::API_ACTION_GET; break;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     protected function hydrateOrders()
112 112
     {
113 113
         if (count($this->query)) {
114
-            Logger::log(static::class . ' gathering query string', LOG_DEBUG);
114
+            Logger::log(static::class.' gathering query string', LOG_DEBUG);
115 115
             foreach ($this->query as $key => $value) {
116 116
                 if ($key === self::API_ORDER_FIELD && is_array($value)) {
117 117
                     foreach ($value as $field => $direction) {
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
      */
129 129
     protected function extractPagination()
130 130
     {
131
-        Logger::log(static::class . ' extract pagination start', LOG_DEBUG);
131
+        Logger::log(static::class.' extract pagination start', LOG_DEBUG);
132 132
         $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1;
133 133
         $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100;
134
-        Logger::log(static::class . ' extract pagination end', LOG_DEBUG);
134
+        Logger::log(static::class.' extract pagination end', LOG_DEBUG);
135 135
         return array($page, (int)$limit);
136 136
     }
137 137
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     private function addOrders(ModelCriteria &$query)
144 144
     {
145
-        Logger::log(static::class . ' extract orders start ', LOG_DEBUG);
145
+        Logger::log(static::class.' extract orders start ', LOG_DEBUG);
146 146
         $orderAdded = FALSE;
147 147
         $tableMap = $this->getTableMap();
148 148
         foreach ($this->order->getOrders() as $field => $direction) {
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
                 $orderAdded = TRUE;
151 151
                 if ($direction === Order::ASC) {
152 152
                     $query->addAscendingOrderByColumn($column->getPhpName());
153
-                } else {
153
+                }else {
154 154
                     $query->addDescendingOrderByColumn($column->getPhpName());
155 155
                 }
156 156
             }
157 157
         }
158 158
         if (!$orderAdded) {
159 159
             $pks = $this->getPkDbName();
160
-            foreach(array_keys($pks) as $key) {
160
+            foreach (array_keys($pks) as $key) {
161 161
                 $query->addAscendingOrderByColumn($key);
162 162
             }
163 163
         }
164
-        Logger::log(static::class . ' extract orders end', LOG_DEBUG);
164
+        Logger::log(static::class.' extract orders end', LOG_DEBUG);
165 165
     }
166 166
 
167 167
     /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             foreach ($this->query as $field => $value) {
177 177
                 if (self::API_COMBO_FIELD === $field) {
178 178
                     ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
179
-                } elseif(!preg_match('/^__/', $field)) {
179
+                } elseif (!preg_match('/^__/', $field)) {
180 180
                     ApiHelper::addModelField($tableMap, $query, $field, $value);
181 181
                 }
182 182
             }
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
             list($page, $limit) = $this->extractPagination();
198 198
             if ($limit === -1) {
199 199
                 $this->list = $query->find($this->con);
200
-            } else {
200
+            }else {
201 201
                 $this->list = $query->paginate($page, $limit, $this->con);
202 202
             }
203
-        } catch (\Exception $e) {
203
+        }catch (\Exception $e) {
204 204
             Logger::log($e->getMessage(), LOG_ERR);
205 205
         }
206 206
     }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $code = 200;
220 220
         list($return, $total, $pages) = $this->getList();
221 221
         $message = null;
222
-        if(!$total) {
222
+        if (!$total) {
223 223
             $message = t('No se han encontrado elementos para la búsqueda');
224 224
         }
225 225
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         $pages = 1;
246 246
         $message = null;
247 247
         list($code, $return) = $this->getSingleResult($pk);
248
-        if($code !== 200) {
248
+        if ($code !== 200) {
249 249
             $message = t('No se ha encontrado el elemento solicitado');
250 250
         }
251 251
 
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
                 $status = 200;
275 275
                 $saved = TRUE;
276 276
                 $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
277
-            } else {
277
+            }else {
278 278
                 $message = t('No se ha podido guardar el modelo seleccionado');
279 279
             }
280
-        } catch (\Exception $e) {
281
-            $message = t('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage();
280
+        }catch (\Exception $e) {
281
+            $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage();
282 282
             $context = [];
283
-            if(null !== $e->getPrevious()) {
283
+            if (null !== $e->getPrevious()) {
284 284
                 $context[] = $e->getPrevious()->getMessage();
285 285
             }
286 286
             Logger::log($e->getMessage(), LOG_CRIT, $context);
@@ -316,18 +316,18 @@  discard block
 block discarded – undo
316 316
                     $updated = TRUE;
317 317
                     $status = 200;
318 318
                     $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
319
-                } else {
319
+                }else {
320 320
                     $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
321 321
                 }
322
-            } catch (\Exception $e) {
322
+            }catch (\Exception $e) {
323 323
                 $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
324 324
                 $context = [];
325
-                if(null !== $e->getPrevious()) {
325
+                if (null !== $e->getPrevious()) {
326 326
                     $context[] = $e->getPrevious()->getMessage();
327 327
                 }
328 328
                 Logger::log($e->getMessage(), LOG_CRIT, $context);
329 329
             }
330
-        } else {
330
+        }else {
331 331
             $message = t('No se ha encontrado el modelo al que se hace referencia para actualizar');
332 332
         }
333 333
 
@@ -355,15 +355,15 @@  discard block
 block discarded – undo
355 355
                 $this->con->beginTransaction();
356 356
                 $this->hydrateModel($pk);
357 357
                 if (NULL !== $this->model) {
358
-                    if(method_exists('clearAllReferences', $this->model)) {
358
+                    if (method_exists('clearAllReferences', $this->model)) {
359 359
                         $this->model->clearAllReferences(true);
360 360
                     }
361 361
                     $this->model->delete($this->con);
362 362
                     $deleted = TRUE;
363 363
                 }
364
-            } catch (\Exception $e) {
364
+            }catch (\Exception $e) {
365 365
                 $context = [];
366
-                if(null !== $e->getPrevious()) {
366
+                if (null !== $e->getPrevious()) {
367 367
                     $context[] = $e->getPrevious()->getMessage();
368 368
                 }
369 369
                 Logger::log($e->getMessage(), LOG_CRIT, $context);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
             $this->saveBulk();
393 393
             $saved = true;
394 394
             $status = 200;
395
-        } catch(\Exception $e) {
395
+        }catch (\Exception $e) {
396 396
             Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData());
397 397
             $message = t('Bulk insert rolled back');
398 398
         }
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
         /** @var CustomerTableMap $tableMap */
416 416
         $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap());
417
-        foreach($this->list->getData() as $data) {
417
+        foreach ($this->list->getData() as $data) {
418 418
             $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data);
419 419
         }
420 420
         return $return;
@@ -431,23 +431,23 @@  discard block
 block discarded – undo
431 431
         try {
432 432
             $this->paginate();
433 433
             if (null !== $this->list) {
434
-                if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) {
434
+                if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) {
435 435
                     $return = $this->extractDataWithFormat();
436
-                } else {
436
+                }else {
437 437
                     $return = $this->list->toArray(null, false, $this->fieldType ?: TableMap::TYPE_PHPNAME, false);
438 438
                 }
439 439
                 $total = 0;
440 440
                 $pages = 0;
441
-                if($this->list instanceof PropelModelPager) {
441
+                if ($this->list instanceof PropelModelPager) {
442 442
                     $total = $this->list->getNbResults();
443 443
                     $pages = $this->list->getLastPage();
444
-                } elseif($this->list instanceof ArrayCollection) {
444
+                } elseif ($this->list instanceof ArrayCollection) {
445 445
                     $total = count($return);
446 446
                     $pages = 1;
447 447
                 }
448 448
             }
449
-        } catch (\Exception $e) {
450
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
449
+        }catch (\Exception $e) {
450
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
451 451
         }
452 452
 
453 453
         return array($return, $total, $pages);
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         $return = array();
466 466
         if (NULL === $model || !method_exists($model, 'toArray')) {
467 467
             $code = 404;
468
-        } else {
468
+        }else {
469 469
             $return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
470 470
         }
471 471
 
Please login to merge, or discard this patch.
src/base/config/LoginForm.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
             ))
38 38
             ->addButton('submit', t("Acceder como {{username}}"))
39 39
             ->addButton("cancel", t("Cancelar"), "button", array(
40
-                "onclick" => "javacript:location.href = \"" . Router::getInstance()->getRoute('') . "\";",
40
+                "onclick" => "javacript:location.href = \"".Router::getInstance()->getRoute('')."\";",
41 41
                 "class" => "btn-link",
42 42
             ));
43 43
     }
Please login to merge, or discard this patch.
src/base/config/ConfigForm.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,9 +83,9 @@
 block discarded – undo
83 83
             'class' => 'btn-warning md-default',
84 84
             'icon' => 'fa-plus',
85 85
         ];
86
-        if(Config::getParam('admin.version', 'v1') === 'v1') {
87
-            $add['onclick'] = 'javascript:addNewField(document.getElementById("' . $this->getName() . '"));';
88
-        } else {
86
+        if (Config::getParam('admin.version', 'v1') === 'v1') {
87
+            $add['onclick'] = 'javascript:addNewField(document.getElementById("'.$this->getName().'"));';
88
+        }else {
89 89
             $add['ng-click'] = 'addNewField()';
90 90
         }
91 91
         $this->addButton('submit', t('Guardar configuración'), 'submit', array(
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function init()
76 76
     {
77
-        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE);
77
+        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE);
78 78
         if (empty($this->routing) || Config::getParam('debug', true)) {
79 79
             $this->debugLoad();
80
-        } else {
81
-            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE);
80
+        }else {
81
+            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE);
82 82
         }
83 83
         $this->checkExternalModules(false);
84 84
         $this->setLoaded();
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
         }
117 117
 
118 118
         $notFoundRoute = Config::getParam('route.404');
119
-        if(null !== $notFoundRoute) {
119
+        if (null !== $notFoundRoute) {
120 120
             Request::getInstance()->redirect($this->getRoute($notFoundRoute, true));
121
-        } else {
121
+        }else {
122 122
             return $template->render('error.html.twig', array(
123 123
                 'exception' => $exception,
124 124
                 'trace' => $exception->getTraceAsString(),
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
         try {
170 170
             //Search action and execute
171 171
             return $this->searchAction($route);
172
-        } catch (AccessDeniedException $e) {
173
-            Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']);
172
+        }catch (AccessDeniedException $e) {
173
+            Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']);
174 174
             return Admin::staticAdminLogon($route);
175
-        } catch (RouterException $r) {
175
+        }catch (RouterException $r) {
176 176
             Logger::log($r->getMessage(), LOG_WARNING);
177
-        } catch (\Exception $e) {
177
+        }catch (\Exception $e) {
178 178
             Logger::log($e->getMessage(), LOG_ERR);
179 179
             throw $e;
180 180
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     protected function searchAction($route)
194 194
     {
195
-        Logger::log('Searching action to execute: ' . $route, LOG_INFO);
195
+        Logger::log('Searching action to execute: '.$route, LOG_INFO);
196 196
         //Revisamos si tenemos la ruta registrada
197 197
         $parts = parse_url($route);
198 198
         $path = array_key_exists('path', $parts) ? $parts['path'] : $route;
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
                 /** @var $class \PSFS\base\types\Controller */
208 208
                 $class = RouterHelper::getClassToCall($action);
209 209
                 try {
210
-                    if($this->checkRequirements($action, $get)) {
210
+                    if ($this->checkRequirements($action, $get)) {
211 211
                         return $this->executeCachedRoute($route, $action, $class, $get);
212
-                    } else {
212
+                    }else {
213 213
                         throw new RouterException(t('La ruta no es válida'), 400);
214 214
                     }
215
-                } catch (\Exception $e) {
215
+                }catch (\Exception $e) {
216 216
                     Logger::log($e->getMessage(), LOG_ERR);
217 217
                     throw $e;
218 218
                 }
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
      * @return bool
228 228
      */
229 229
     private function checkRequirements(array $action, $params = []) {
230
-        if(!empty($params) && !empty($action['requirements'])) {
230
+        if (!empty($params) && !empty($action['requirements'])) {
231 231
             $checked = 0;
232
-            foreach(array_keys($params) as $key) {
233
-                if(in_array($key, $action['requirements'], true)) {
232
+            foreach (array_keys($params) as $key) {
233
+                if (in_array($key, $action['requirements'], true)) {
234 234
                     $checked++;
235 235
                 }
236 236
             }
237 237
             $valid = count($action['requirements']) === $checked;
238
-        } else {
238
+        }else {
239 239
             $valid = true;
240 240
         }
241 241
         return $valid;
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         $this->checkExternalModules();
286 286
         if (file_exists($modulesPath)) {
287 287
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
288
-            if($modules->hasResults()) {
288
+            if ($modules->hasResults()) {
289 289
                 foreach ($modules->getIterator() as $modulePath) {
290 290
                     $module = $modulePath->getBasename();
291
-                    $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
291
+                    $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
292 292
                 }
293 293
             }
294 294
         }
295
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE);
295
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE);
296 296
     }
297 297
 
298 298
     /**
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             $home_params = NULL;
309 309
             foreach ($this->routing as $pattern => $params) {
310 310
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
311
-                if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) {
311
+                if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) {
312 312
                     $home_params = $params;
313 313
                 }
314 314
                 unset($method);
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
     private function inspectDir($origen, $namespace = 'PSFS', $routing = [])
331 331
     {
332 332
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name('*.php');
333
-        if($files->hasResults()) {
333
+        if ($files->hasResults()) {
334 334
             foreach ($files->getIterator() as $file) {
335
-                if($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) {
336
-                    $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
337
-                } else {
335
+                if ($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) {
336
+                    $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
337
+                }else {
338 338
                     $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname()));
339 339
                 }
340
-                $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
340
+                $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
341 341
             }
342 342
         }
343 343
         $this->finder = new Finder();
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     private function addRouting($namespace, &$routing, $module = 'PSFS')
367 367
     {
368 368
         if (self::exists($namespace)) {
369
-            if(I18nHelper::checkI18Class($namespace)) {
369
+            if (I18nHelper::checkI18Class($namespace)) {
370 370
                 return $routing;
371 371
             }
372 372
             $reflection = new \ReflectionClass($namespace);
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             if (!$this->domains) {
409 409
                 $this->domains = [];
410 410
             }
411
-            $domain = '@' . $class->getConstant('DOMAIN') . '/';
411
+            $domain = '@'.$class->getConstant('DOMAIN').'/';
412 412
             if (!array_key_exists($domain, $this->domains)) {
413 413
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
414 414
             }
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
      */
425 425
     public function simpatize()
426 426
     {
427
-        $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php';
428
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
427
+        $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php';
428
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
429 429
         $this->generateSlugs($absoluteTranslationFileName);
430 430
         GeneratorHelper::createDir(CONFIG_DIR);
431
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
431
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE);
432 432
 
433 433
         return $this;
434 434
     }
@@ -444,18 +444,18 @@  discard block
 block discarded – undo
444 444
     public function getRoute($slug = '', $absolute = FALSE, array $params = [])
445 445
     {
446 446
         if ('' === $slug) {
447
-            return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/';
447
+            return $absolute ? Request::getInstance()->getRootUrl().'/' : '/';
448 448
         }
449 449
         if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
450 450
             throw new RouterException(t('No existe la ruta especificada'));
451 451
         }
452
-        $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
452
+        $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
453 453
         if (!empty($params)) {
454 454
             foreach ($params as $key => $value) {
455
-                $url = str_replace('{' . $key . '}', $value, $url);
455
+                $url = str_replace('{'.$key.'}', $value, $url);
456 456
             }
457 457
         } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) {
458
-            $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
458
+            $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default'];
459 459
         }
460 460
 
461 461
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -474,15 +474,15 @@  discard block
 block discarded – undo
474 474
      * @param string $method
475 475
      */
476 476
     private function checkPreActions($class, $method) {
477
-        $preAction = 'pre' . ucfirst($method);
478
-        if(method_exists($class, $preAction)) {
477
+        $preAction = 'pre'.ucfirst($method);
478
+        if (method_exists($class, $preAction)) {
479 479
             Logger::log(t('Pre action invoked'));
480 480
             try {
481
-                if(false === call_user_func_array([$class, $preAction])) {
481
+                if (false === call_user_func_array([$class, $preAction])) {
482 482
                     Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]);
483 483
                     error_clear_last();
484 484
                 }
485
-            } catch (\Exception $e) {
485
+            }catch (\Exception $e) {
486 486
                 Logger::log($e->getMessage(), LOG_ERR, [$class, $method]);
487 487
             }
488 488
         }
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
      */
500 500
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
501 501
     {
502
-        Logger::log('Executing route ' . $route, LOG_INFO);
502
+        Logger::log('Executing route '.$route, LOG_INFO);
503 503
         $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams());
504 504
         Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action);
505 505
         $cache = Cache::needCache();
@@ -507,9 +507,9 @@  discard block
 block discarded – undo
507 507
         $return = null;
508 508
         if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) {
509 509
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
510
-            $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache);
510
+            $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache);
511 511
             if (NULL !== $cachedData) {
512
-                $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON);
512
+                $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON);
513 513
                 Template::getInstance()->renderCache($cachedData, $headers);
514 514
                 $execute = FALSE;
515 515
             }
@@ -554,11 +554,11 @@  discard block
 block discarded – undo
554 554
     private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath)
555 555
     {
556 556
         $extModule = $modulePath->getBasename();
557
-        $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
558
-        if(file_exists($moduleAutoloader)) {
557
+        $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
558
+        if (file_exists($moduleAutoloader)) {
559 559
             include_once $moduleAutoloader;
560 560
             if ($hydrateRoute) {
561
-                $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing);
561
+                $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing);
562 562
             }
563 563
         }
564 564
     }
@@ -572,16 +572,16 @@  discard block
 block discarded – undo
572 572
     {
573 573
         try {
574 574
             $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
575
-            $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
576
-            if(file_exists($externalModulePath)) {
575
+            $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
576
+            if (file_exists($externalModulePath)) {
577 577
                 $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
578
-                if($externalModule->hasResults()) {
578
+                if ($externalModule->hasResults()) {
579 579
                     foreach ($externalModule->getIterator() as $modulePath) {
580 580
                         $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath);
581 581
                     }
582 582
                 }
583 583
             }
584
-        } catch (\Exception $e) {
584
+        }catch (\Exception $e) {
585 585
             Logger::log($e->getMessage(), LOG_WARNING);
586 586
             $module = null;
587 587
         }
Please login to merge, or discard this patch.
src/base/Request.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public static function header($name, $default = null)
147 147
     {
148
-        return self::getInstance()->getHeader($name,  $default);
148
+        return self::getInstance()->getHeader($name, $default);
149 149
     }
150 150
 
151 151
     /**
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
         $header = null;
159 159
         if ($this->hasHeader($name)) {
160 160
             $header = $this->header[$name];
161
-        } else if(array_key_exists('h_' . strtolower($name), $this->query)) {
162
-            $header = $this->query['h_' . strtolower($name)];
163
-        } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) {
164
-            $header = $this->server['HTTP_' . strtoupper(str_replace('-', '_', $name))];
161
+        }else if (array_key_exists('h_'.strtolower($name), $this->query)) {
162
+            $header = $this->query['h_'.strtolower($name)];
163
+        }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) {
164
+            $header = $this->server['HTTP_'.strtoupper(str_replace('-', '_', $name))];
165 165
         }
166 166
         return $header ?: $default;
167 167
     }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             $url = $this->getServer('HTTP_ORIGIN');
261 261
         }
262 262
         ob_start();
263
-        header('Location: ' . $url);
263
+        header('Location: '.$url);
264 264
         ob_end_clean();
265 265
         Security::getInstance()->updateSession();
266 266
         exit(t('Redireccionando...'));
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
         $url = $this->getServerName();
307 307
         $protocol = $hasProtocol ? $this->getProtocol() : '';
308 308
         if (!empty($protocol)) {
309
-            $url = $protocol . $url;
309
+            $url = $protocol.$url;
310 310
         }
311 311
         if (!in_array((integer)$this->getServer('SERVER_PORT'), [80, 443], true)) {
312
-            $url .= ':' . $this->getServer('SERVER_PORT');
312
+            $url .= ':'.$this->getServer('SERVER_PORT');
313 313
         }
314 314
         return $url;
315 315
     }
Please login to merge, or discard this patch.
src/base/Cache.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         GeneratorHelper::createDir(dirname($path));
56 56
         if (false === FileHelper::writeFile($path, $data)) {
57
-            throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
57
+            throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ').$path);
58 58
         }
59 59
     }
60 60
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         Logger::log('Gathering data from cache', LOG_DEBUG, ['path' => $path]);
70 70
         $data = null;
71
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
71
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
72 72
         if (file_exists($absolutePath)) {
73 73
             $data = FileHelper::readFile($absolutePath);
74 74
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
85 85
     {
86 86
         Logger::log('Checking expiration', LOG_DEBUG, ['path' => $path]);
87
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
87
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
88 88
         $lasModificationDate = filemtime($absolutePath);
89 89
         return ($lasModificationDate + $expires <= time());
90 90
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         Logger::log('Store data in cache', LOG_DEBUG, ['path' => $path]);
153 153
         $data = self::transformData($data, $transform);
154
-        $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
154
+        $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
155 155
         $this->saveTextToFile($data, $absolutePath);
156 156
     }
157 157
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $data = null;
170 170
         Logger::log('Reading data from cache', LOG_DEBUG, ['path' => $path]);
171
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
171
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
172 172
             if (is_callable($function) && $this->hasExpiredCache($path, $expires)) {
173 173
                 $data = $function();
174 174
                 $this->storeData($path, $data, $transform, false, $expires);
175
-            } else {
175
+            }else {
176 176
                 $data = $this->getDataFromFile($path, $transform);
177 177
             }
178 178
         }
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     public function flushCache() {
227
-        if(Config::getParam('cache.data.enable', false)) {
227
+        if (Config::getParam('cache.data.enable', false)) {
228 228
             Logger::log('Flushing cache', LOG_DEBUG);
229 229
             $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR);
230
-            if(is_array($action)) {
231
-                $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
232
-                if(!file_exists($hashPath)) {
233
-                    $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath;
230
+            if (is_array($action)) {
231
+                $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
232
+                if (!file_exists($hashPath)) {
233
+                    $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath;
234 234
                 }
235 235
                 FileHelper::deleteDir($hashPath);
236 236
             }
Please login to merge, or discard this patch.
src/controller/RouteController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
             $router->simpatize();
56 56
             Security::getInstance()->setFlash("callback_message", t("Rutas generadas correctamente"));
57 57
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
58
-        } catch (\Exception $e) {
58
+        }catch (\Exception $e) {
59 59
             Logger::log($e->getMessage(), LOG_ERR);
60 60
             Security::getInstance()->setFlash("callback_message", t("Algo no ha salido bien, revisa los logs"));
61 61
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
Please login to merge, or discard this patch.
src/controller/UserController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                 Logger::log('Configuration saved successful');
64 64
                 Security::getInstance()->setFlash("callback_message", t("Usuario agregado correctamente"));
65 65
                 Security::getInstance()->setFlash("callback_route", Router::getInstance()->getRoute("admin", true));
66
-            } else {
66
+            }else {
67 67
                 throw new ConfigException(t('Error al guardar los administradores, prueba a cambiar los permisos'));
68 68
             }
69 69
         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     {
100 100
         if ($this->isAdmin()) {
101 101
             return $this->redirect('admin');
102
-        } else {
102
+        }else {
103 103
             return Admin::staticAdminLogon($route);
104 104
         }
105 105
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                 $cookies = array(
132 132
                     array(
133 133
                         "name" => Security::getInstance()->getHash(),
134
-                        "value" => base64_encode($form->getFieldValue("user") . ":" . $form->getFieldValue("pass")),
134
+                        "value" => base64_encode($form->getFieldValue("user").":".$form->getFieldValue("pass")),
135 135
                         "expire" => time() + 3600,
136 136
                         "http" => true,
137 137
                     )
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                     'status_message' => t("Acceso permitido... redirigiendo!!"),
143 143
                     'delay' => 1,
144 144
                 );
145
-            } else {
145
+            }else {
146 146
                 $form->setError("user", t("El usuario no tiene acceso a la web"));
147 147
             }
148 148
         }
Please login to merge, or discard this patch.