Passed
Push — master ( 17804e...9c6a95 )
by Fran
06:14
created
src/services/GeneratorService.php 2 patches
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     /**
28 28
      * Método que revisa las traducciones directorio a directorio
29
-     * @param $path
29
+     * @param string $path
30 30
      * @param $locale
31 31
      * @return array
32 32
      */
@@ -85,7 +85,6 @@  discard block
 block discarded – undo
85 85
      * Service that creates the root paths for the modules
86 86
      * @param string $module
87 87
      * @param string $mod_path
88
-     * @param boolean $isModule
89 88
      */
90 89
     private function createModulePath($module, $mod_path)
91 90
     {
@@ -99,7 +98,7 @@  discard block
 block discarded – undo
99 98
      * Servicio que genera la estructura base
100 99
      * @param string $module
101 100
      * @param boolean $mod_path
102
-     * @return boolean
101
+     * @return boolean|null
103 102
      */
104 103
     private function createModulePathTree($module, $mod_path)
105 104
     {
@@ -464,7 +463,7 @@  discard block
 block discarded – undo
464 463
      * Method that copy resources recursively
465 464
      * @param string $dest
466 465
      * @param boolean $force
467
-     * @param $filename_path
466
+     * @param string $filename_path
468 467
      * @param boolean $debug
469 468
      */
470 469
     public static function copyResources($dest, $force, $filename_path, $debug)
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -32,24 +32,24 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public static function findTranslations($path, $locale)
34 34
     {
35
-        $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
36
-        $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
35
+        $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
36
+        $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR;
37 37
 
38 38
         $translations = array();
39 39
         if (file_exists($path)) {
40 40
             $d = dir($path);
41 41
             while (false !== ($dir = $d->read())) {
42 42
                 GeneratorHelper::createDir($locale_path);
43
-                if (!file_exists($locale_path . 'translations.po')) {
44
-                    file_put_contents($locale_path . 'translations.po', '');
43
+                if (!file_exists($locale_path.'translations.po')) {
44
+                    file_put_contents($locale_path.'translations.po', '');
45 45
                 }
46
-                $inspect_path = realpath($path . DIRECTORY_SEPARATOR . $dir);
47
-                $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext " .
48
-                    $inspect_path . DIRECTORY_SEPARATOR .
46
+                $inspect_path = realpath($path.DIRECTORY_SEPARATOR.$dir);
47
+                $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ".
48
+                    $inspect_path.DIRECTORY_SEPARATOR.
49 49
                     "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$locale_path}translations.po";
50
-                if (is_dir($path . DIRECTORY_SEPARATOR . $dir) && preg_match('/^\./', $dir) == 0) {
51
-                    $res = _('Revisando directorio: ') . $inspect_path;
52
-                    $res .= _('Comando ejecutado: ') . $cmd_php;
50
+                if (is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./', $dir) == 0) {
51
+                    $res = _('Revisando directorio: ').$inspect_path;
52
+                    $res .= _('Comando ejecutado: ').$cmd_php;
53 53
                     $res .= shell_exec($cmd_php);
54 54
                     usleep(10);
55 55
                     $translations[] = $res;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function createStructureModule($module, $force = false, $type = "", $apiClass = "")
72 72
     {
73
-        $mod_path = CORE_DIR . DIRECTORY_SEPARATOR;
73
+        $mod_path = CORE_DIR.DIRECTORY_SEPARATOR;
74 74
         $module = ucfirst($module);
75 75
         $this->createModulePath($module, $mod_path);
76 76
         $this->createModulePathTree($module, $mod_path);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         // Creates the src folder
93 93
         GeneratorHelper::createDir($mod_path);
94 94
         // Create module path
95
-        GeneratorHelper::createDir($mod_path . $module);
95
+        GeneratorHelper::createDir($mod_path.$module);
96 96
     }
97 97
 
98 98
     /**
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
         $paths = [
109 109
             "Api", "Api/base", "Config", "Controller", "Form", "Models", "Public", "Templates", "Services", "Test"
110 110
         ];
111
-        $module_path = $mod_path . $module;
111
+        $module_path = $mod_path.$module;
112 112
         foreach ($paths as $path) {
113
-            GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . $path);
113
+            GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR.$path);
114 114
         }
115 115
         //Creamos las carpetas de los assets
116 116
         $htmlPaths = array("css", "js", "img", "media", "font");
117 117
         foreach ($htmlPaths as $path) {
118
-            GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path);
118
+            GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path);
119 119
         }
120 120
     }
121 121
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     private function createModuleBaseFiles($module, $mod_path, $force = false, $controllerType = '')
130 130
     {
131
-        $module_path = $mod_path . $module;
131
+        $module_path = $mod_path.$module;
132 132
         $this->generateControllerTemplate($module, $module_path, $force, $controllerType);
133 133
         $this->generateServiceTemplate($module, $module_path, $force);
134 134
         $this->genereateAutoloaderTemplate($module, $module_path, $force);
@@ -146,28 +146,28 @@  discard block
 block discarded – undo
146 146
      */
147 147
     private function createModuleModels($module, $path)
148 148
     {
149
-        $module_path = $path . $module;
150
-        $module_path = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $module_path);
149
+        $module_path = $path.$module;
150
+        $module_path = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $module_path);
151 151
         //Generamos las clases de propel y la configuración
152
-        $exec = "export PATH=\$PATH:/opt/local/bin; " . BASE_DIR . DIRECTORY_SEPARATOR .
153
-            "vendor" . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "propel ";
154
-        $schemaOpt = " --schema-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path .
155
-            DIRECTORY_SEPARATOR . "Config";
156
-        $opt = " --config-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR .
157
-            "Config --output-dir=" . CORE_DIR . " --verbose";
158
-        $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n" . $exec . "build" . $opt . $schemaOpt);
159
-        $ret = shell_exec($exec . "build" . $opt . $schemaOpt);
152
+        $exec = "export PATH=\$PATH:/opt/local/bin; ".BASE_DIR.DIRECTORY_SEPARATOR.
153
+            "vendor".DIRECTORY_SEPARATOR."bin".DIRECTORY_SEPARATOR."propel ";
154
+        $schemaOpt = " --schema-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.
155
+            DIRECTORY_SEPARATOR."Config";
156
+        $opt = " --config-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR.
157
+            "Config --output-dir=".CORE_DIR." --verbose";
158
+        $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n".$exec."build".$opt.$schemaOpt);
159
+        $ret = shell_exec($exec."build".$opt.$schemaOpt);
160 160
 
161 161
         $this->log->infoLog("[GENERATOR] Generamos clases invocando a propel:\n $ret");
162
-        $ret = shell_exec($exec . "sql:build" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR .
163
-            $module_path . DIRECTORY_SEPARATOR . "Config" . $schemaOpt);
162
+        $ret = shell_exec($exec."sql:build".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR.
163
+            $module_path.DIRECTORY_SEPARATOR."Config".$schemaOpt);
164 164
         $this->log->infoLog("[GENERATOR] Generamos sql invocando a propel:\n $ret");
165 165
 
166 166
         $configTemplate = $this->tpl->dump("generator/config.propel.template.twig", array(
167 167
             "module" => $module,
168 168
         ));
169
-        $this->writeTemplateToFile($configTemplate, CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config" .
170
-            DIRECTORY_SEPARATOR . "config.php", true);
169
+        $this->writeTemplateToFile($configTemplate, CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config".
170
+            DIRECTORY_SEPARATOR."config.php", true);
171 171
         $this->log->infoLog("Generado config genérico para propel:\n $ret");
172 172
     }
173 173
 
@@ -188,32 +188,32 @@  discard block
 block discarded – undo
188 188
             "namespace" => preg_replace('/(\\\|\/)/', '\\', $module),
189 189
             "url" => preg_replace('/(\\\|\/)/', '/', $module),
190 190
             "class" => $class,
191
-            "controllerType" => $class . "Base",
191
+            "controllerType" => $class."Base",
192 192
             "is_base" => false
193 193
         ));
194
-        $controller = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" .
195
-            DIRECTORY_SEPARATOR . "{$class}Controller.php", $force);
194
+        $controller = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller".
195
+            DIRECTORY_SEPARATOR."{$class}Controller.php", $force);
196 196
 
197 197
         $controllerBody = $this->tpl->dump("generator/controller.template.twig", array(
198 198
             "module" => $module,
199 199
             "namespace" => preg_replace('/(\\\|\/)/', '\\', $module),
200 200
             "url" => preg_replace('/(\\\|\/)/', '/', $module),
201
-            "class" => $class . "Base",
201
+            "class" => $class."Base",
202 202
             "service" => $class,
203 203
             "controllerType" => $controllerType,
204 204
             "is_base" => true,
205 205
             "domain" => $class,
206 206
         ));
207
-        $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" .
208
-            DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true);
207
+        $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller".
208
+            DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true);
209 209
 
210 210
         $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array(
211 211
             "module" => $module,
212 212
             "namespace" => preg_replace('/(\\\|\/)/', '\\', $module),
213 213
             "class" => $class,
214 214
         ));
215
-        $test = $this->writeTemplateToFile($testTemplate, $mod_path . DIRECTORY_SEPARATOR . "Test" .
216
-            DIRECTORY_SEPARATOR . "{$class}Test.php", true);
215
+        $test = $this->writeTemplateToFile($testTemplate, $mod_path.DIRECTORY_SEPARATOR."Test".
216
+            DIRECTORY_SEPARATOR."{$class}Test.php", true);
217 217
         return ($controller && $controllerBase && $test);
218 218
     }
219 219
 
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
     private function generateBaseApiTemplate($module, $mod_path, $force = false, $apiClass = "")
228 228
     {
229 229
         $created = true;
230
-        $modelPath = $mod_path . $module . DIRECTORY_SEPARATOR . 'Models';
231
-        $api_path = $mod_path . $module . DIRECTORY_SEPARATOR . 'Api';
230
+        $modelPath = $mod_path.$module.DIRECTORY_SEPARATOR.'Models';
231
+        $api_path = $mod_path.$module.DIRECTORY_SEPARATOR.'Api';
232 232
         if (file_exists($modelPath)) {
233 233
             $dir = dir($modelPath);
234 234
             while ($file = $dir->read()) {
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         //Generamos el fichero de configuración
257 257
         $this->log->infoLog("Generamos fichero vacío de configuración");
258 258
         return $this->writeTemplateToFile("<?php\n\t",
259
-            $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php",
259
+            $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php",
260 260
             $force);
261 261
     }
262 262
 
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
         //Generamos el fichero de configuración
272 272
         $this->log->infoLog("Generamos ficheros para assets base");
273 273
         $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n",
274
-            $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css",
274
+            $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css",
275 275
             $force);
276 276
         $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();",
277
-            $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js",
277
+            $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js",
278 278
             $force);
279 279
         return ($css && $js);
280 280
     }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
             "class" => $class,
297 297
         ));
298 298
         return $this->writeTemplateToFile($controller,
299
-            $mod_path . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php",
299
+            $mod_path.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php",
300 300
             $force);
301 301
     }
302 302
 
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
             "autoloader" => preg_replace('/(\\\|\/)/', '_', $module),
316 316
             "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module),
317 317
         ));
318
-        $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force);
318
+        $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force);
319 319
 
320 320
         $this->log->infoLog("Generamos el phpunit");
321 321
         $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array(
322 322
             "module" => $module,
323 323
         ));
324
-        $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force);
324
+        $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force);
325 325
         return $autoload && $phpunit;
326 326
     }
327 327
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             "db" => $this->config->get("db_name"),
343 343
         ));
344 344
         return $this->writeTemplateToFile($schema,
345
-            $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml",
345
+            $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml",
346 346
             $force);
347 347
     }
348 348
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
             "namespace" => preg_replace('/(\\\|\/)/', '', $module),
366 366
         ));
367 367
         return $this->writeTemplateToFile($build_properties,
368
-            $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml",
368
+            $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml",
369 369
             $force);
370 370
     }
371 371
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             "module" => $module,
384 384
         ));
385 385
         return $this->writeTemplateToFile($index,
386
-            $mod_path . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig",
386
+            $mod_path.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig",
387 387
             $force);
388 388
     }
389 389
 
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
             try {
402 402
                 $this->cache->storeData($filename, $fileContent, Cache::TEXT, true);
403 403
                 $created = true;
404
-            } catch (\Exception $e) {
404
+            }catch (\Exception $e) {
405 405
                 $this->log->errorLog($e->getMessage());
406 406
             }
407
-        } else {
408
-            $this->log->errorLog($filename . _(' not exists or cant write'));
407
+        }else {
408
+            $this->log->errorLog($filename._(' not exists or cant write'));
409 409
         }
410 410
         return $created;
411 411
     }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
         ));
435 435
 
436 436
         return $this->writeTemplateToFile($controller,
437
-            $mod_path . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true);
437
+            $mod_path.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true);
438 438
     }
439 439
 
440 440
     /**
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             "class" => $class,
458 458
         ));
459 459
 
460
-        return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "{$api}.php", $force);
460
+        return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."{$api}.php", $force);
461 461
     }
462 462
 
463 463
     /**
@@ -471,12 +471,12 @@  discard block
 block discarded – undo
471 471
     {
472 472
         if (file_exists($filename_path)) {
473 473
             $destfolder = basename($filename_path);
474
-            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
474
+            if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) {
475 475
                 if (is_dir($filename_path)) {
476
-                    self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
477
-                } else {
478
-                    if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
479
-                        throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
476
+                    self::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
477
+                }else {
478
+                    if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) {
479
+                        throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
480 480
                     }
481 481
                 }
482 482
             }
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
         GeneratorHelper::createDir($dst);
496 496
         while (false !== ($file = readdir($dir))) {
497 497
             if (($file != '.') && ($file != '..')) {
498
-                if (is_dir($src . '/' . $file)) {
499
-                    self::copyr($src . '/' . $file, $dst . '/' . $file);
500
-                } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) {
501
-                    throw new ConfigException("Can't copy " . $src . " to " . $dst);
498
+                if (is_dir($src.'/'.$file)) {
499
+                    self::copyr($src.'/'.$file, $dst.'/'.$file);
500
+                } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) {
501
+                    throw new ConfigException("Can't copy ".$src." to ".$dst);
502 502
                 }
503 503
             }
504 504
         }
Please login to merge, or discard this patch.
src/controller/GeneratorController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function generateModule()
32 32
     {
33
-        Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri());
33
+        Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri());
34 34
         /* @var $form \PSFS\base\config\ConfigForm */
35 35
         $form = new ModuleForm();
36 36
         $form->build();
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
             try {
58 58
                 $module = preg_replace('/(\\\|\/)/', '/', $module);
59 59
                 $module = preg_replace('/^\//', '', $module);
60
-                if(!empty($apiClass) && !class_exists($apiClass)) {
60
+                if (!empty($apiClass) && !class_exists($apiClass)) {
61 61
                     throw new ConfigException(_('La clase definida para la API no existe'), 501);
62 62
                 }
63 63
                 $this->gen->createStructureModule($module, false, $type, $apiClass);
64 64
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente")));
65 65
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
66
-            } catch (\Exception $e) {
67
-                Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
66
+            }catch (\Exception $e) {
67
+                Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
68 68
                 Security::getInstance()->setFlash("callback_message", $e->getMessage());
69 69
             }
70 70
         }
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function init()
62 62
     {
63
-        if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) {
63
+        if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) {
64 64
             $this->hydrateRouting();
65 65
             $this->simpatize();
66
-        } else {
67
-            list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE);
68
-            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE);
66
+        }else {
67
+            list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE);
68
+            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE);
69 69
             $this->checkExternalModules(false);
70 70
         }
71 71
     }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 "success" => FALSE,
91 91
                 "error" => $e->getMessage(),
92 92
             )), 'application/json');
93
-        } else {
93
+        }else {
94 94
             return $template->render('error.html.twig', array(
95 95
                 'exception' => $e,
96 96
                 'trace' => $e->getTraceAsString(),
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
             SecurityHelper::checkRestrictedAccess($route);
149 149
             //Search action and execute
150 150
             $this->searchAction($route);
151
-        } catch (AccessDeniedException $e) {
151
+        }catch (AccessDeniedException $e) {
152 152
             Logger::log(_('Solicitamos credenciales de acceso a zona restringida'));
153 153
             return Admin::staticAdminLogon($route);
154
-        } catch (RouterException $r) {
154
+        }catch (RouterException $r) {
155 155
             Logger::log($r->getMessage(), LOG_WARNING);
156
-        } catch (\Exception $e) {
156
+        }catch (\Exception $e) {
157 157
             Logger::log($e->getMessage(), LOG_ERR);
158 158
             throw $e;
159 159
         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     protected function searchAction($route)
172 172
     {
173
-        Logger::log('Searching action to execute: ' . $route, LOG_INFO);
173
+        Logger::log('Searching action to execute: '.$route, LOG_INFO);
174 174
         //Revisamos si tenemos la ruta registrada
175 175
         $parts = parse_url($route);
176 176
         $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 $class = RouterHelper::getClassToCall($action);
185 185
                 try {
186 186
                     $this->executeCachedRoute($route, $action, $class, $get);
187
-                } catch (\Exception $e) {
187
+                }catch (\Exception $e) {
188 188
                     Logger::log($e->getMessage(), LOG_ERR);
189 189
                     throw new RouterException($e->getMessage(), 404, $e);
190 190
                 }
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
             $externalModules = explode(',', $externalModules);
214 214
             foreach ($externalModules as &$module) {
215 215
                 $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
216
-                $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
216
+                $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
217 217
                 if (file_exists($externalModulePath)) {
218 218
                     $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
219 219
                     if (!empty($externalModule)) {
220 220
                         foreach ($externalModule as $modulePath) {
221 221
                             $extModule = $modulePath->getBasename();
222
-                            $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
222
+                            $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
223 223
                             if (file_exists($moduleAutoloader)) {
224 224
                                 @include $moduleAutoloader;
225 225
                                 if ($hydrateRoute) {
226
-                                    $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing);
226
+                                    $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing);
227 227
                                 }
228 228
                             }
229 229
                         }
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
246 246
             foreach ($modules as $modulePath) {
247 247
                 $module = $modulePath->getBasename();
248
-                $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
248
+                $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
249 249
             }
250 250
         }
251 251
         $this->checkExternalModules();
252
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);
252
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);
253 253
     }
254 254
 
255 255
     /**
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             $home_params = NULL;
265 265
             foreach ($this->routing as $pattern => $params) {
266 266
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
267
-                if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) {
267
+                if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) {
268 268
                     $home_params = $params;
269 269
                 }
270 270
             }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php");
290 290
         foreach ($files as $file) {
291 291
             $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname()));
292
-            $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
292
+            $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
293 293
         }
294 294
         $this->finder = new Finder();
295 295
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             if (!$this->domains) {
360 360
                 $this->domains = [];
361 361
             }
362
-            $domain = "@" . $class->getConstant("DOMAIN") . "/";
362
+            $domain = "@".$class->getConstant("DOMAIN")."/";
363 363
             if (!array_key_exists($domain, $this->domains)) {
364 364
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
365 365
             }
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
      */
375 375
     public function simpatize()
376 376
     {
377
-        $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";
378
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
377
+        $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";
378
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
379 379
         $this->generateSlugs($absoluteTranslationFileName);
380 380
         GeneratorHelper::createDir(CONFIG_DIR);
381
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
381
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
382 382
 
383 383
         return $this;
384 384
     }
@@ -396,16 +396,16 @@  discard block
 block discarded – undo
396 396
     public function getRoute($slug = '', $absolute = FALSE, $params = [])
397 397
     {
398 398
         if (strlen($slug) === 0) {
399
-            return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';
399
+            return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';
400 400
         }
401 401
         if (NULL === $slug || !array_key_exists($slug, $this->slugs)) {
402 402
             throw new RouterException(_("No existe la ruta especificada"));
403 403
         }
404
-        $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
404
+        $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
405 405
         if (!empty($params)) foreach ($params as $key => $value) {
406
-            $url = str_replace("{" . $key . "}", $value, $url);
406
+            $url = str_replace("{".$key."}", $value, $url);
407 407
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
408
-            $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
408
+            $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
409 409
         }
410 410
 
411 411
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -450,19 +450,19 @@  discard block
 block discarded – undo
450 450
      */
451 451
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
452 452
     {
453
-        Logger::log('Executing route ' . $route, LOG_INFO);
453
+        Logger::log('Executing route '.$route, LOG_INFO);
454 454
         Security::getInstance()->setSessionKey("__CACHE__", $action);
455 455
         $cache = Cache::needCache();
456 456
         $execute = TRUE;
457 457
         if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) {
458 458
             $cacheDataName = $this->cache->getRequestCacheHash();
459
-            $tmpDir = substr($cacheDataName, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheDataName, 2, 2) . DIRECTORY_SEPARATOR;
460
-            $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName,
461
-                $cache, function () {
459
+            $tmpDir = substr($cacheDataName, 0, 2).DIRECTORY_SEPARATOR.substr($cacheDataName, 2, 2).DIRECTORY_SEPARATOR;
460
+            $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName,
461
+                $cache, function() {
462 462
                 });
463 463
             if (NULL !== $cachedData) {
464
-                $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName . ".headers",
465
-                    $cache, function () {
464
+                $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName.".headers",
465
+                    $cache, function() {
466 466
                     }, Cache::JSON);
467 467
                 Template::getInstance()->renderCache($cachedData, $headers);
468 468
                 $execute = FALSE;
Please login to merge, or discard this patch.
src/base/config/Config.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     protected function init()
74 74
     {
75
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) {
75
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) {
76 76
             $this->loadConfigData();
77 77
         }
78 78
         return $this;
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
             $final_data = array_filter($final_data, function($value) {
174 174
                 return !empty($value);
175 175
             });
176
-            Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, $final_data, Cache::JSON, true);
176
+            Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, $final_data, Cache::JSON, true);
177 177
             Config::getInstance()->loadConfigData();
178 178
             $saved = true;
179
-        } catch (ConfigException $e) {
179
+        }catch (ConfigException $e) {
180 180
             Logger::log($e->getMessage(), LOG_ERR);
181 181
         }
182 182
         return $saved;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function loadConfigData()
210 210
     {
211
-        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE,
211
+        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE,
212 212
             Cache::JSON,
213 213
             TRUE) ?: [];
214 214
         $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE;
Please login to merge, or discard this patch.
src/base/config/ModuleForm.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
             "Auth" => _("Requiere autenticación de usuario"),
35 35
             "AuthAdmin" => _("Requiere autenticación de administrador"),
36 36
         );
37
-        if(Config::getParam('psfs.auth')) {
37
+        if (Config::getParam('psfs.auth')) {
38 38
             $controllerTypes['SessionAuthApi'] = _('Requiere autenticación usando PSFS AUTH');
39 39
         }
40 40
         $this->add('module', array(
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
             $objects = scandir($dir);
20 20
             foreach ($objects as $object) {
21 21
                 if ($object != "." && $object != "..") {
22
-                    if (filetype($dir . "/" . $object) == "dir") {
23
-                        self::deleteDir($dir . "/" . $object);
24
-                    } else {
25
-                        unlink($dir . "/" . $object);
22
+                    if (filetype($dir."/".$object) == "dir") {
23
+                        self::deleteDir($dir."/".$object);
24
+                    }else {
25
+                        unlink($dir."/".$object);
26 26
                     }
27 27
                 }
28 28
             }
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $rootDirs = array("css", "js", "media", "font");
40 40
         foreach ($rootDirs as $dir) {
41
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
41
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
42 42
                 try {
43
-                    self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir);
44
-                } catch (\Exception $e) {
43
+                    self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir);
44
+                }catch (\Exception $e) {
45 45
                     Logger::log($e->getMessage());
46 46
                 }
47 47
             }
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
     {
58 58
         try {
59 59
             if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
60
-                throw new \Exception(_('Can\'t create directory ') . $dir);
60
+                throw new \Exception(_('Can\'t create directory ').$dir);
61 61
             }
62
-        } catch (\Exception $e) {
62
+        }catch (\Exception $e) {
63 63
             Logger::log($e->getMessage(), LOG_WARNING);
64 64
             if (!file_exists(dirname($dir))) {
65
-                throw new GeneratorException($e->getMessage() . $dir);
65
+                throw new GeneratorException($e->getMessage().$dir);
66 66
             }
67 67
         }
68 68
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public static function getTemplatePath()
75 75
     {
76
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
76
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
77 77
         return realpath($path);
78 78
     }
79 79
 
Please login to merge, or discard this patch.
src/base/types/helpers/AdminHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $routes = [];
33 33
         foreach ($systemRoutes as $route => $params) {
34
-            if(isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) {
34
+            if (isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) {
35 35
                 $module = strtoupper($params['module']);
36 36
                 $mode = $params["visible"] ? 'visible' : 'hidden';
37 37
                 $routes[$module][$mode][] = [
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
                 ];
42 42
             }
43 43
         }
44
-        foreach($routes as $module => &$route) {
45
-            if(array_key_exists('visible', $route)) {
44
+        foreach ($routes as $module => &$route) {
45
+            if (array_key_exists('visible', $route)) {
46 46
                 uasort($route["visible"], '\PSFS\base\types\helpers\AdminHelper::sortByLabel');
47 47
             }
48
-            if(array_key_exists('hidden', $route)) {
48
+            if (array_key_exists('hidden', $route)) {
49 49
                 uasort($route["hidden"], '\PSFS\base\types\helpers\AdminHelper::sortByLabel');
50 50
             }
51 51
         }
Please login to merge, or discard this patch.