Test Failed
Push — master ( 728bda...d24de4 )
by Fran
03:38
created
src/base/Cache.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use PSFS\base\config\Config;
5 5
 use PSFS\base\exception\ConfigException;
6
-use PSFS\base\types\helpers\RequestHelper;
7 6
 use PSFS\base\types\SingletonTrait;
8 7
 
9 8
 /**
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     private function saveTextToFile($data, $path, $absolute = false)
32 32
     {
33
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
33
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
34 34
         $filename = basename($absolutePath);
35 35
         Config::createDir(str_replace($filename, "", $absolutePath));
36 36
         if (false === file_put_contents($absolutePath, $data)) {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
50 50
     {
51 51
         $data = null;
52
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
52
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
53 53
         if (file_exists($absolutePath)) {
54 54
             $data = file_get_contents($absolutePath);
55 55
         }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
67 67
     {
68
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
68
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
69 69
         $lasModificationDate = filemtime($absolutePath);
70 70
         return ($lasModificationDate + $expires <= time());
71 71
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 break;
89 89
             case Cache::GZIP:
90 90
                 // TODO implementar
91
-                if(function_exists('gzuncompress')) {
91
+                if (function_exists('gzuncompress')) {
92 92
                     $data = gzuncompress($data ?: '');
93 93
                 }
94 94
                 break;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                 $data = Cache::transformData($data, Cache::GZIP);
114 114
                 break;
115 115
             case Cache::GZIP:
116
-                if(function_exists('gzcompress')) {
116
+                if (function_exists('gzcompress')) {
117 117
                     $data = gzcompress($data ?: '');
118 118
                 }
119 119
                 break;
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
146 146
     {
147 147
         $data = null;
148
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
148
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
149 149
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
150 150
                 $data = call_user_func($function);
151 151
                 $this->storeData($path, $data, $transform);
152
-            } else {
152
+            }else {
153 153
                 $data = $this->getDataFromFile($path, $transform);
154 154
             }
155 155
         }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     private function checkAdminSite() {
163 163
         $isAdminRequest = false;
164 164
         $lastRequest = Security::getInstance()->getSessionKey("lastRequest");
165
-        if(null !== $lastRequest) {
165
+        if (null !== $lastRequest) {
166 166
             $url = str_replace(Request::getInstance()->getRootUrl(true), '', $lastRequest['url']);
167 167
             $isAdminRequest = preg_match('/^\/admin\//i', $url);
168 168
         }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     public static function needCache()
177 177
     {
178 178
         $needCache = false;
179
-        if(!self::checkAdminSite()) {
179
+        if (!self::checkAdminSite()) {
180 180
             $action = Security::getInstance()->getSessionKey("__CACHE__");
181 181
             if (null !== $action && array_key_exists("cache", $action) && $action["cache"] > 0) {
182 182
                 $needCache = $action["cache"];
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         $hash = "";
195 195
         $action = Security::getInstance()->getSessionKey("__CACHE__");
196 196
         if (null !== $action && $action["cache"] > 0) {
197
-            $hash = $action["http"] . " " . $action["slug"];
197
+            $hash = $action["http"]." ".$action["slug"];
198 198
         }
199 199
         return sha1($hash);
200 200
     }
Please login to merge, or discard this patch.
src/base/config/Config.php 1 patch
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     /**
200 200
      * Method that returns a config value
201 201
      * @param string $param
202
-     * @param mixed $defaultValue
202
+     * @param boolean $defaultValue
203 203
      *
204 204
      * @return mixed|null
205 205
      */
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
     /**
285 285
      * Static wrapper for extracting params
286 286
      * @param string $key
287
-     * @param mixed|null $defaultValue
288
-     * @return mixed|null
287
+     * @param boolean $defaultValue
288
+     * @return string
289 289
      */
290 290
     public static function getParam($key, $defaultValue = null) {
291 291
         $param = Config::getInstance()->get($key);
Please login to merge, or discard this patch.
src/bootstrap.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@
 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('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor');
14
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
15
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
16
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
17
-if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
13
+if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor');
14
+if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
15
+if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache');
16
+if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config');
17
+if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html');
18 18
 
19 19
 //Cargamos en memoria la función de desarrollo PRE
20 20
 if (!function_exists('pre')) {
Please login to merge, or discard this patch.
Braces   +35 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,20 +1,42 @@
 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('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor');
14
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
15
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
16
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
17
-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('VENDOR_DIR')) {
26
+    define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor');
27
+}
28
+if (!defined('LOG_DIR')) {
29
+    define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
30
+}
31
+if (!defined('CACHE_DIR')) {
32
+    define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
33
+}
34
+if (!defined('CONFIG_DIR')) {
35
+    define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
36
+}
37
+if (!defined('WEB_DIR')) {
38
+    define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
39
+}
18 40
 
19 41
 //Cargamos en memoria la función de desarrollo PRE
20 42
 if (!function_exists('pre')) {
Please login to merge, or discard this patch.
src/base/types/helpers/AdminHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     public static function sortByLabel(array $elementA, array $elementB) {
16 16
         $labelA = array_key_exists('label', $elementA) ? $elementA['label'] : '';
17 17
         $labelB = array_key_exists('label', $elementB) ? $elementB['label'] : '';
18
-        if($labelA == $labelB) {
18
+        if ($labelA == $labelB) {
19 19
             return 0;
20 20
         }
21 21
         return $labelA < $labelB ? -1 : 1;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             if (preg_match('/^\/admin(\/|$)/', $routePattern)) {
34 34
                 if (preg_match('/^\\\?PSFS/', $params["class"])) {
35 35
                     $profile = "superadmin";
36
-                } else {
36
+                }else {
37 37
                     $profile = "admin";
38 38
                 }
39 39
                 if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) {
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(str_replace('{__API__}', $api, $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.
src/base/types/Api.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
          *
181 181
          * @param ModelCriteria $query
182 182
          */
183
-        private function addOrders(ModelCriteria &$query)
183
+        private function addOrders(ModelCriteria & $query)
184 184
         {
185 185
             $orderAdded = FALSE;
186 186
             $tableMap = $this->getTableMap();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                     $orderAdded = TRUE;
190 190
                     if ($direction === Order::ASC) {
191 191
                         $query->addAscendingOrderByColumn($column->getPhpName());
192
-                    } else {
192
+                    }else {
193 193
                         $query->addDescendingOrderByColumn($column->getPhpName());
194 194
                     }
195 195
                 }
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
         private function addPkToList() {
206 206
             $tableMap = $this->getTableMap();
207 207
             $pks = $tableMap->getPrimaryKeys();
208
-            if(count($pks) == 1) {
208
+            if (count($pks) == 1) {
209 209
                 $pks = array_keys($pks);
210 210
                 $this->extraColumns[$pks[0]] = self::API_MODEL_KEY_FIELD;
211
-            } else {
211
+            }else {
212 212
                 throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta'));
213 213
             }
214 214
         }
@@ -217,19 +217,19 @@  discard block
 block discarded – undo
217 217
          * Method that add a new field with the Label of the row
218 218
          */
219 219
         private function addDefaultListField() {
220
-            if(!in_array(self::API_LIST_NAME_FIELD, $this->extraColumns)) {
220
+            if (!in_array(self::API_LIST_NAME_FIELD, $this->extraColumns)) {
221 221
                 $tableMap = $this->getTableMap();
222 222
                 $column = null;
223
-                if($tableMap->hasColumn('NAME')) {
223
+                if ($tableMap->hasColumn('NAME')) {
224 224
                     $column = $tableMap->getColumn('NAME');
225
-                } elseif($tableMap->hasColumn('TITLE')) {
225
+                } elseif ($tableMap->hasColumn('TITLE')) {
226 226
                     $column = $tableMap->getColumn('TITLE');
227
-                } elseif($tableMap->hasColumn('LABEL')) {
227
+                } elseif ($tableMap->hasColumn('LABEL')) {
228 228
                     $column = $tableMap->getColumn('LABEL');
229 229
                 }
230
-                if(null !== $column) {
230
+                if (null !== $column) {
231 231
                     $this->extraColumns[$column->getFullyQualifiedName()] = self::API_LIST_NAME_FIELD;
232
-                } else {
232
+                }else {
233 233
                     $this->addClassListName($tableMap);
234 234
                 }
235 235
             }
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
          *
242 242
          * @param ModelCriteria $query
243 243
          */
244
-        private function addExtraColumns(ModelCriteria &$query)
244
+        private function addExtraColumns(ModelCriteria & $query)
245 245
         {
246
-            if(self::API_ACTION_LIST === $this->action) {
246
+            if (self::API_ACTION_LIST === $this->action) {
247 247
                 $this->addDefaultListField();
248 248
                 $this->addPkToList();
249 249
             }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
          *
260 260
          * @param ModelCriteria $query
261 261
          */
262
-        protected function joinTables(ModelCriteria &$query)
262
+        protected function joinTables(ModelCriteria & $query)
263 263
         {
264 264
             //TODO for specific implementations
265 265
         }
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
          */
270 270
         protected function parseExtraColumns() {
271 271
             $columns = [];
272
-            foreach($this->extraColumns as $key => $columnName) {
272
+            foreach ($this->extraColumns as $key => $columnName) {
273 273
                 $columns[$columnName] = strtolower($columnName);
274 274
             }
275 275
             return $columns;
@@ -280,14 +280,14 @@  discard block
 block discarded – undo
280 280
          *
281 281
          * @param ModelCriteria $query
282 282
          */
283
-        private function addFilters(ModelCriteria &$query)
283
+        private function addFilters(ModelCriteria & $query)
284 284
         {
285 285
             if (count($this->query) > 0) {
286 286
                 $tableMap = $this->getTableMap();
287 287
                 foreach ($this->query as $field => $value) {
288
-                    if(self::API_COMBO_FIELD === $field) {
288
+                    if (self::API_COMBO_FIELD === $field) {
289 289
                         ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
290
-                    } else {
290
+                    }else {
291 291
                         ApiHelper::addModelField($tableMap, $query, $field, $value);
292 292
                     }
293 293
                 }
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
         /**
298 298
          * @param ModelCriteria $query
299 299
          */
300
-        private function checkReturnFields(ModelCriteria &$query) {
300
+        private function checkReturnFields(ModelCriteria & $query) {
301 301
             $returnFields = $this->getRequest()->getQuery('__fields');
302
-            if(null !== $returnFields) {
302
+            if (null !== $returnFields) {
303 303
                 $fields = explode(',', $returnFields);
304 304
                 $select = [];
305 305
                 $tablemap = $this->getTableMap();
306 306
                 foreach ($fields as $field) {
307
-                    if(in_array($field, $this->extraColumns)) {
307
+                    if (in_array($field, $this->extraColumns)) {
308 308
                         $select[] = $field;
309
-                    } elseif($tablemap->hasColumnByPhpName($field)) {
309
+                    } elseif ($tablemap->hasColumnByPhpName($field)) {
310 310
                         $select[] = $field;
311 311
                     }
312 312
                 }
313
-                if(count($select) > 0) {
313
+                if (count($select) > 0) {
314 314
                     $query->select($select);
315 315
                 }
316 316
             }
@@ -332,10 +332,10 @@  discard block
 block discarded – undo
332 332
                 list($page, $limit) = $this->extractPagination();
333 333
                 if ($limit == -1) {
334 334
                     $this->list = $query->find($this->con);
335
-                } else {
335
+                }else {
336 336
                     $this->list = $query->paginate($page, $limit, $this->con);
337 337
                 }
338
-            } catch (\Exception $e) {
338
+            }catch (\Exception $e) {
339 339
                 Logger::log($e->getMessage(), LOG_ERR);
340 340
             }
341 341
         }
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                 $this->joinTables($query);
353 353
                 $this->addExtraColumns($query);
354 354
                 $this->model = $query->findPk($pk);
355
-            } catch (\Exception $e) {
355
+            }catch (\Exception $e) {
356 356
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
357 357
             }
358 358
         }
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
                     $saved = TRUE;
444 444
                     $model = $this->model->toArray();
445 445
                 }
446
-            } catch (\Exception $e) {
447
-                $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage();
446
+            }catch (\Exception $e) {
447
+                $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage();
448 448
                 Logger::log($e->getMessage(), LOG_ERR);
449 449
             }
450 450
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
                         $this->model->delete($this->con);
475 475
                         $deleted = TRUE;
476 476
                     }
477
-                } catch (\Exception $e) {
477
+                }catch (\Exception $e) {
478 478
                     $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados');
479 479
                     Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
480 480
                 }
@@ -509,14 +509,14 @@  discard block
 block discarded – undo
509 509
                         $updated = TRUE;
510 510
                         $status = 200;
511 511
                         $model = $this->model->toArray();
512
-                    } else {
512
+                    }else {
513 513
                         $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
514 514
                     }
515
-                } catch(\Exception $e) {
515
+                }catch (\Exception $e) {
516 516
                     $model = $e->getMessage();
517 517
                     Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
518 518
                 }
519
-            } else {
519
+            }else {
520 520
                 $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
521 521
             }
522 522
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
          */
529 529
         private function extractQuery()
530 530
         {
531
-            $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query");
531
+            $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query");
532 532
             /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */
533 533
             $query = $queryReflector->getMethod('create')->invoke($this->con);
534 534
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
             if (null !== $this->con && $this->con->inTransaction()) {
573 573
                 if ($status === 200) {
574 574
                     $this->con->commit();
575
-                } else {
575
+                }else {
576 576
                     $this->con->rollBack();
577 577
                 }
578 578
             }
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
                 "domain" => $this->getDomain(),
625 625
                 "listLabel" => self::API_LIST_NAME_FIELD,
626 626
                 'modelId' => self::API_MODEL_KEY_FIELD,
627
-                'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)),
628
-                "url"    => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)),
627
+                'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)),
628
+                "url"    => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)),
629 629
             ), [], '');
630 630
         }
631 631
 
@@ -659,12 +659,12 @@  discard block
 block discarded – undo
659 659
             $pages = 0;
660 660
             try {
661 661
                 $this->paginate();
662
-                if(null !== $this->list) {
662
+                if (null !== $this->list) {
663 663
                     $return = $this->list->toArray();
664 664
                     $total = $this->list->getNbResults();
665 665
                     $pages = $this->list->getLastPage();
666 666
                 }
667
-            } catch (\Exception $e) {
667
+            }catch (\Exception $e) {
668 668
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
669 669
             }
670 670
 
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
             $return = array();
684 684
             if (NULL === $model && method_exists($model, 'toArray')) {
685 685
                 $code = 404;
686
-            } else {
686
+            }else {
687 687
                 $return = $model->toArray();
688 688
             }
689 689
 
@@ -698,10 +698,10 @@  discard block
 block discarded – undo
698 698
             $pks = '';
699 699
             $sep = '';
700 700
             foreach ($tableMap->getPrimaryKeys() as $pk) {
701
-                $pks .= $sep . $pk->getFullyQualifiedName();
701
+                $pks .= $sep.$pk->getFullyQualifiedName();
702 702
                 $sep = ', "|", ';
703 703
             }
704
-            $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = self::API_LIST_NAME_FIELD;
704
+            $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = self::API_LIST_NAME_FIELD;
705 705
         }
706 706
 
707 707
         /**
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +44 added lines, -44 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
                 }
@@ -194,20 +194,20 @@  discard block
 block discarded – undo
194 194
 
195 195
     private function checkExternalModules() {
196 196
         $externalModules = Config::getParam('modules.extend');
197
-        if(null !== $externalModules) {
197
+        if (null !== $externalModules) {
198 198
             $externalModules = explode(',', $externalModules);
199
-            foreach($externalModules as &$module) {
199
+            foreach ($externalModules as &$module) {
200 200
                 $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
201
-                $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
202
-                if(file_exists($externalModulePath)) {
201
+                $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
202
+                if (file_exists($externalModulePath)) {
203 203
                     $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
204
-                    if(!empty($externalModule)) {
205
-                        foreach($externalModule as $modulePath) {
204
+                    if (!empty($externalModule)) {
205
+                        foreach ($externalModule as $modulePath) {
206 206
                             $extModule = $modulePath->getBasename();
207
-                            $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
208
-                            if(file_exists($moduleAutoloader)) {
207
+                            $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
208
+                            if (file_exists($moduleAutoloader)) {
209 209
                                 @include $moduleAutoloader;
210
-                                $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, $extModule, $this->routing);
210
+                                $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, $extModule, $this->routing);
211 211
                             }
212 212
                         }
213 213
                     }
@@ -226,13 +226,13 @@  discard block
 block discarded – undo
226 226
         $this->routing = $this->inspectDir($base, "PSFS", array());
227 227
         if (file_exists($modulesPath)) {
228 228
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
229
-            foreach($modules as $modulePath) {
229
+            foreach ($modules as $modulePath) {
230 230
                 $module = $modulePath->getBasename();
231
-                $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
231
+                $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
232 232
             }
233 233
         }
234 234
         $this->checkExternalModules();
235
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);
235
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);
236 236
     }
237 237
 
238 238
     /**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             $home_params = NULL;
248 248
             foreach ($this->routing as $pattern => $params) {
249 249
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
250
-                if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) {
250
+                if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) {
251 251
                     $home_params = $params;
252 252
                 }
253 253
             }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php");
273 273
         foreach ($files as $file) {
274 274
             $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname()));
275
-            $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
275
+            $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
276 276
         }
277 277
         $this->finder = new Finder();
278 278
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
                 }
313 313
                 foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
314 314
                     list($route, $info) = RouterHelper::extractRouteInfo($method, $api, $module);
315
-                    if(null !== $route && null !== $info) {
315
+                    if (null !== $route && null !== $info) {
316 316
                         $info['class'] = $namespace;
317 317
                         $routing[$route] = $info;
318 318
                     }
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
     {
336 336
         //Calculamos los dominios para las plantillas
337 337
         if ($class->hasConstant("DOMAIN") && !$class->isAbstract()) {
338
-            if(!$this->domains) {
338
+            if (!$this->domains) {
339 339
                 $this->domains = [];
340 340
             }
341
-            $domain = "@" . $class->getConstant("DOMAIN") . "/";
342
-            if(!array_key_exists($domain, $this->domains)) {
341
+            $domain = "@".$class->getConstant("DOMAIN")."/";
342
+            if (!array_key_exists($domain, $this->domains)) {
343 343
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
344 344
             }
345 345
         }
@@ -353,11 +353,11 @@  discard block
 block discarded – undo
353 353
      */
354 354
     public function simpatize()
355 355
     {
356
-        $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";
357
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
356
+        $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";
357
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
358 358
         $this->generateSlugs($absoluteTranslationFileName);
359 359
         Config::createDir(CONFIG_DIR);
360
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
360
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
361 361
 
362 362
         return $this;
363 363
     }
@@ -375,16 +375,16 @@  discard block
 block discarded – undo
375 375
     public function getRoute($slug = '', $absolute = FALSE, $params = [])
376 376
     {
377 377
         if (strlen($slug) === 0) {
378
-            return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';
378
+            return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';
379 379
         }
380 380
         if (NULL === $slug || !array_key_exists($slug, $this->slugs)) {
381 381
             throw new RouterException(_("No existe la ruta especificada"));
382 382
         }
383
-        $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
383
+        $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
384 384
         if (!empty($params)) foreach ($params as $key => $value) {
385
-            $url = str_replace("{" . $key . "}", $value, $url);
385
+            $url = str_replace("{".$key."}", $value, $url);
386 386
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
387
-            $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
387
+            $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
388 388
         }
389 389
 
390 390
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -427,25 +427,25 @@  discard block
 block discarded – undo
427 427
      */
428 428
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
429 429
     {
430
-        Logger::log('Executing route ' . $route, LOG_INFO);
430
+        Logger::log('Executing route '.$route, LOG_INFO);
431 431
         Security::getInstance()->setSessionKey("__CACHE__", $action);
432 432
         $cache = Cache::needCache();
433 433
         $execute = TRUE;
434 434
         if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) {
435 435
             $cacheDataName = $this->cache->getRequestCacheHash();
436
-            $tmpDir = substr($cacheDataName, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheDataName, 2, 2) . DIRECTORY_SEPARATOR;
437
-            $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName,
438
-                $cache, function () {});
436
+            $tmpDir = substr($cacheDataName, 0, 2).DIRECTORY_SEPARATOR.substr($cacheDataName, 2, 2).DIRECTORY_SEPARATOR;
437
+            $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName,
438
+                $cache, function() {});
439 439
             if (NULL !== $cachedData) {
440
-                $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName . ".headers",
441
-                    $cache, function () {}, Cache::JSON);
440
+                $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName.".headers",
441
+                    $cache, function() {}, Cache::JSON);
442 442
                 Template::getInstance()->renderCache($cachedData, $headers);
443 443
                 $execute = FALSE;
444 444
             }
445 445
         }
446 446
         if ($execute) {
447 447
             Logger::log(_('Start executing action'), LOG_DEBUG);
448
-            if(false === call_user_func_array(array($class, $action['method']), $params)) {
448
+            if (false === call_user_func_array(array($class, $action['method']), $params)) {
449 449
                 Logger::log(_('An error ocurred trying to execute the action'), LOG_ERR, [error_get_last()]);
450 450
             }
451 451
         }
Please login to merge, or discard this patch.