Passed
Push — master ( 6539c2...56d8ac )
by Fran
07:30
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,28 +188,28 @@  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
-        $filename = $mod_path . DIRECTORY_SEPARATOR . "Test" . DIRECTORY_SEPARATOR . "{$class}Test.php";
210
+        $filename = $mod_path.DIRECTORY_SEPARATOR."Test".DIRECTORY_SEPARATOR."{$class}Test.php";
211 211
         $test = true;
212
-        if(!file_exists($filename)) {
212
+        if (!file_exists($filename)) {
213 213
             $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array(
214 214
                 "module" => $module,
215 215
                 "namespace" => preg_replace('/(\\\|\/)/', '\\', $module),
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
     private function generateBaseApiTemplate($module, $mod_path, $force = false, $apiClass = "")
231 231
     {
232 232
         $created = true;
233
-        $modelPath = $mod_path . $module . DIRECTORY_SEPARATOR . 'Models';
234
-        $api_path = $mod_path . $module . DIRECTORY_SEPARATOR . 'Api';
233
+        $modelPath = $mod_path.$module.DIRECTORY_SEPARATOR.'Models';
234
+        $api_path = $mod_path.$module.DIRECTORY_SEPARATOR.'Api';
235 235
         if (file_exists($modelPath)) {
236 236
             $dir = dir($modelPath);
237 237
             while ($file = $dir->read()) {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         //Generamos el fichero de configuración
260 260
         $this->log->infoLog("Generamos fichero vacío de configuración");
261 261
         return $this->writeTemplateToFile("<?php\n\t",
262
-            $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php",
262
+            $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php",
263 263
             $force);
264 264
     }
265 265
 
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
         //Generamos el fichero de configuración
275 275
         $this->log->infoLog("Generamos ficheros para assets base");
276 276
         $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n",
277
-            $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css",
277
+            $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css",
278 278
             $force);
279 279
         $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();",
280
-            $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js",
280
+            $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js",
281 281
             $force);
282 282
         return ($css && $js);
283 283
     }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
             "class" => $class,
300 300
         ));
301 301
         return $this->writeTemplateToFile($controller,
302
-            $mod_path . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php",
302
+            $mod_path.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php",
303 303
             $force);
304 304
     }
305 305
 
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
             "autoloader" => preg_replace('/(\\\|\/)/', '_', $module),
319 319
             "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module),
320 320
         ));
321
-        $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force);
321
+        $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force);
322 322
 
323 323
         $this->log->infoLog("Generamos el phpunit");
324 324
         $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array(
325 325
             "module" => $module,
326 326
         ));
327
-        $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force);
327
+        $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force);
328 328
         return $autoload && $phpunit;
329 329
     }
330 330
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
             "db" => $this->config->get("db_name"),
346 346
         ));
347 347
         return $this->writeTemplateToFile($schema,
348
-            $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml",
348
+            $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml",
349 349
             $force);
350 350
     }
351 351
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
             "namespace" => preg_replace('/(\\\|\/)/', '', $module),
369 369
         ));
370 370
         return $this->writeTemplateToFile($build_properties,
371
-            $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml",
371
+            $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml",
372 372
             $force);
373 373
     }
374 374
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
             "module" => $module,
387 387
         ));
388 388
         return $this->writeTemplateToFile($index,
389
-            $mod_path . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig",
389
+            $mod_path.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig",
390 390
             $force);
391 391
     }
392 392
 
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
             try {
405 405
                 $this->cache->storeData($filename, $fileContent, Cache::TEXT, true);
406 406
                 $created = true;
407
-            } catch (\Exception $e) {
407
+            }catch (\Exception $e) {
408 408
                 $this->log->errorLog($e->getMessage());
409 409
             }
410
-        } else {
411
-            $this->log->errorLog($filename . _(' not exists or cant write'));
410
+        }else {
411
+            $this->log->errorLog($filename._(' not exists or cant write'));
412 412
         }
413 413
         return $created;
414 414
     }
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
         ));
438 438
 
439 439
         return $this->writeTemplateToFile($controller,
440
-            $mod_path . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true);
440
+            $mod_path.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true);
441 441
     }
442 442
 
443 443
     /**
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
             "class" => $class,
461 461
         ));
462 462
 
463
-        return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "{$api}.php", $force);
463
+        return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."{$api}.php", $force);
464 464
     }
465 465
 
466 466
     /**
@@ -474,12 +474,12 @@  discard block
 block discarded – undo
474 474
     {
475 475
         if (file_exists($filename_path)) {
476 476
             $destfolder = basename($filename_path);
477
-            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
477
+            if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) {
478 478
                 if (is_dir($filename_path)) {
479
-                    self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
480
-                } else {
481
-                    if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
482
-                        throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
479
+                    self::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
480
+                }else {
481
+                    if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) {
482
+                        throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
483 483
                     }
484 484
                 }
485 485
             }
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
         GeneratorHelper::createDir($dst);
499 499
         while (false !== ($file = readdir($dir))) {
500 500
             if (($file != '.') && ($file != '..')) {
501
-                if (is_dir($src . '/' . $file)) {
502
-                    self::copyr($src . '/' . $file, $dst . '/' . $file);
503
-                } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) {
504
-                    throw new ConfigException("Can't copy " . $src . " to " . $dst);
501
+                if (is_dir($src.'/'.$file)) {
502
+                    self::copyr($src.'/'.$file, $dst.'/'.$file);
503
+                } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) {
504
+                    throw new ConfigException("Can't copy ".$src." to ".$dst);
505 505
                 }
506 506
             }
507 507
         }
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/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.
src/controller/GeneratorController.php 1 patch
Spacing   +3 added lines, -3 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();
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
                 $this->gen->createStructureModule($module, false, $type, $apiClass);
62 62
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente")));
63 63
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
64
-            } catch (\Exception $e) {
65
-                Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
64
+            }catch (\Exception $e) {
65
+                Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
66 66
                 Security::getInstance()->setFlash("callback_message", $e->getMessage());
67 67
             }
68 68
         }
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +16 added lines, -16 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
 
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
      * @throws GeneratorException
92 92
      */
93 93
     public static function checkCustomNamespaceApi($namespace) {
94
-        if(!empty($namespace)) {
95
-            if(class_exists($namespace)) {
94
+        if (!empty($namespace)) {
95
+            if (class_exists($namespace)) {
96 96
                 $reflector = new \ReflectionClass($namespace);
97
-                if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
97
+                if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
98 98
                     throw new GeneratorException(_('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501);
99
-                } elseif(!$reflector->isAbstract()) {
99
+                } elseif (!$reflector->isAbstract()) {
100 100
                     throw new GeneratorException(_('La clase definida debe ser abstracta'), 501);
101 101
                 }
102
-            } else {
102
+            }else {
103 103
                 throw new GeneratorException(_('La clase definida para extender la API no existe'), 501);
104 104
             }
105 105
         }
Please login to merge, or discard this patch.
src/base/Cache.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
     /**
148 148
      * Método que guarda en fichero los datos pasados
149
-     * @param $path
149
+     * @param string $path
150 150
      * @param $data
151 151
      * @param int $transform
152 152
      * @param boolean $absolute
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
     /**
203 203
      * Método estático que revisa si se necesita cachear la respuesta de un servicio o no
204
-     * @return integer|boolean
204
+     * @return integer
205 205
      */
206 206
     public static function needCache()
207 207
     {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     {
46 46
         GeneratorHelper::createDir(dirname($path));
47 47
         if (false === FileHelper::writeFile($path, $data)) {
48
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
48
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path);
49 49
         }
50 50
     }
51 51
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
60 60
     {
61 61
         $data = null;
62
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
62
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
63 63
         if (file_exists($absolutePath)) {
64 64
             $data = FileHelper::readFile($absolutePath);
65 65
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
77 77
     {
78
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
78
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
79 79
         $lasModificationDate = filemtime($absolutePath);
80 80
         return ($lasModificationDate + $expires <= time());
81 81
     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     public function storeData($path, $data, $transform = Cache::TEXT, $absolute = false, $expires = 600)
142 142
     {
143 143
         $data = Cache::transformData($data, $transform);
144
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
144
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
145 145
         $this->saveTextToFile($data, $absolutePath);
146 146
     }
147 147
 
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
157 157
     {
158 158
         $data = null;
159
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
159
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
160 160
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
161 161
                 $data = call_user_func($function);
162 162
                 $this->storeData($path, $data, $transform, false, $expires);
163
-            } else {
163
+            }else {
164 164
                 $data = $this->getDataFromFile($path, $transform);
165 165
             }
166 166
         }
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
         $action = Security::getInstance()->getSessionKey("__CACHE__");
203 203
         if (null !== $action && $action["cache"] > 0) {
204 204
             $class = GeneratorHelper::extractClassFromNamespace($action['class']);
205
-            $filename = sha1($action["http"] . " " . $action["slug"]);
206
-            $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2);
207
-            $hashPath = $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR;
205
+            $filename = sha1($action["http"]." ".$action["slug"]);
206
+            $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2);
207
+            $hashPath = $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR;
208 208
         }
209 209
         return [$hashPath, $filename];
210 210
     }
Please login to merge, or discard this patch.
src/base/config/Config.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     protected function init()
76 76
     {
77
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) {
77
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) {
78 78
             $this->loadConfigData();
79 79
         }
80 80
         return $this;
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
             $final_data = array_filter($final_data, function($key, $value) {
183 183
                 return in_array($key, Config::$required) || !empty($value);
184 184
             }, ARRAY_FILTER_USE_BOTH);
185
-            $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT)));
185
+            $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT)));
186 186
             Config::getInstance()->loadConfigData();
187 187
             $saved = true;
188
-        } catch (ConfigException $e) {
188
+        }catch (ConfigException $e) {
189 189
             Logger::log($e->getMessage(), LOG_ERR);
190 190
         }
191 191
         return $saved;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      */
218 218
     public function loadConfigData()
219 219
     {
220
-        $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: [];
220
+        $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: [];
221 221
         $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE;
222 222
     }
223 223
 
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     /**
193 193
      * Method that returns a config value
194 194
      * @param string $param
195
-     * @param mixed $defaultValue
195
+     * @param string $defaultValue
196 196
      *
197 197
      * @return mixed|null
198 198
      */
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     /**
231 231
      * Static wrapper for extracting params
232 232
      * @param string $key
233
-     * @param mixed|null $defaultValue
233
+     * @param string|boolean $defaultValue
234 234
      * @return mixed|null
235 235
      */
236 236
     public static function getParam($key, $defaultValue = null)
Please login to merge, or discard this patch.
src/base/types/Api.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -603,6 +603,9 @@  discard block
 block discarded – undo
603 603
         $this->con->useDebug($this->debug);
604 604
     }
605 605
 
606
+    /**
607
+     * @return string
608
+     */
606 609
     private function getApi()
607 610
     {
608 611
         $model = explode("\\", $this->getModelNamespace());
@@ -610,6 +613,9 @@  discard block
 block discarded – undo
610 613
         return $model[count($model) - 1];
611 614
     }
612 615
 
616
+    /**
617
+     * @return string
618
+     */
613 619
     public function getDomain()
614 620
     {
615 621
         $model = explode("\\", $this->getModelNamespace());
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -14,12 +14,10 @@
 block discarded – undo
14 14
 use PSFS\base\Request;
15 15
 use PSFS\base\Router;
16 16
 use PSFS\base\Singleton;
17
-use PSFS\base\Template;
18 17
 use PSFS\base\types\helpers\ApiFormHelper;
19 18
 use PSFS\base\types\helpers\ApiHelper;
20 19
 use PSFS\base\types\traits\JsonTrait;
21 20
 use PSFS\base\types\traits\RouteTrait;
22
-use PSFS\base\types\traits\SingletonTrait;
23 21
 
24 22
 /**
25 23
  * Class Api
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      *
187 187
      * @param ModelCriteria $query
188 188
      */
189
-    private function addOrders(ModelCriteria &$query)
189
+    private function addOrders(ModelCriteria & $query)
190 190
     {
191 191
         $orderAdded = FALSE;
192 192
         $tableMap = $this->getTableMap();
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                 $orderAdded = TRUE;
196 196
                 if ($direction === Order::ASC) {
197 197
                     $query->addAscendingOrderByColumn($column->getPhpName());
198
-                } else {
198
+                }else {
199 199
                     $query->addDescendingOrderByColumn($column->getPhpName());
200 200
                 }
201 201
             }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         if (count($pks) == 1) {
216 216
             $pks = array_keys($pks);
217 217
             $this->extraColumns[$pks[0]] = self::API_MODEL_KEY_FIELD;
218
-        } else {
218
+        }else {
219 219
             throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta'));
220 220
         }
221 221
     }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             }
238 238
             if (null !== $column) {
239 239
                 $this->extraColumns[$column->getFullyQualifiedName()] = self::API_LIST_NAME_FIELD;
240
-            } else {
240
+            }else {
241 241
                 $this->addClassListName($tableMap);
242 242
             }
243 243
         }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      *
250 250
      * @param ModelCriteria $query
251 251
      */
252
-    private function addExtraColumns(ModelCriteria &$query)
252
+    private function addExtraColumns(ModelCriteria & $query)
253 253
     {
254 254
         if (self::API_ACTION_LIST === $this->action) {
255 255
             $this->addDefaultListField();
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      *
268 268
      * @param ModelCriteria $query
269 269
      */
270
-    protected function joinTables(ModelCriteria &$query)
270
+    protected function joinTables(ModelCriteria & $query)
271 271
     {
272 272
         //TODO for specific implementations
273 273
     }
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
      *
290 290
      * @param ModelCriteria $query
291 291
      */
292
-    private function addFilters(ModelCriteria &$query)
292
+    private function addFilters(ModelCriteria & $query)
293 293
     {
294 294
         if (count($this->query) > 0) {
295 295
             $tableMap = $this->getTableMap();
296 296
             foreach ($this->query as $field => $value) {
297 297
                 if (self::API_COMBO_FIELD === $field) {
298 298
                     ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
299
-                } else {
299
+                }else {
300 300
                     ApiHelper::addModelField($tableMap, $query, $field, $value);
301 301
                 }
302 302
             }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     /**
307 307
      * @param ModelCriteria $query
308 308
      */
309
-    private function checkReturnFields(ModelCriteria &$query)
309
+    private function checkReturnFields(ModelCriteria & $query)
310 310
     {
311 311
         $returnFields = $this->getRequest()->getQuery('__fields');
312 312
         if (null !== $returnFields) {
@@ -342,10 +342,10 @@  discard block
 block discarded – undo
342 342
             list($page, $limit) = $this->extractPagination();
343 343
             if ($limit == -1) {
344 344
                 $this->list = $query->find($this->con);
345
-            } else {
345
+            }else {
346 346
                 $this->list = $query->paginate($page, $limit, $this->con);
347 347
             }
348
-        } catch (\Exception $e) {
348
+        }catch (\Exception $e) {
349 349
             Logger::log($e->getMessage(), LOG_ERR);
350 350
         }
351 351
     }
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
             $this->joinTables($query);
363 363
             $this->addExtraColumns($query);
364 364
             $this->model = $query->findPk($pk);
365
-        } catch (\Exception $e) {
365
+        }catch (\Exception $e) {
366 366
             Logger::getInstance(get_class($this))->errorLog($e->getMessage());
367 367
         }
368 368
     }
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
                 $saved = TRUE;
454 454
                 $model = $this->model->toArray();
455 455
             }
456
-        } catch (\Exception $e) {
457
-            $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage();
456
+        }catch (\Exception $e) {
457
+            $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage();
458 458
             Logger::log($e->getMessage(), LOG_ERR);
459 459
         }
460 460
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
                     $this->model->delete($this->con);
485 485
                     $deleted = TRUE;
486 486
                 }
487
-            } catch (\Exception $e) {
487
+            }catch (\Exception $e) {
488 488
                 $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados');
489 489
                 Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
490 490
             }
@@ -519,14 +519,14 @@  discard block
 block discarded – undo
519 519
                     $updated = TRUE;
520 520
                     $status = 200;
521 521
                     $model = $this->model->toArray();
522
-                } else {
522
+                }else {
523 523
                     $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
524 524
                 }
525
-            } catch (\Exception $e) {
525
+            }catch (\Exception $e) {
526 526
                 $model = $e->getMessage();
527 527
                 Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());
528 528
             }
529
-        } else {
529
+        }else {
530 530
             $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
531 531
         }
532 532
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
      */
539 539
     private function extractQuery()
540 540
     {
541
-        $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query");
541
+        $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query");
542 542
         /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */
543 543
         $query = $queryReflector->getMethod('create')->invoke($this->con);
544 544
 
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
         if (null !== $this->con && $this->con->inTransaction()) {
583 583
             if ($status === 200) {
584 584
                 $this->con->commit();
585
-            } else {
585
+            }else {
586 586
                 $this->con->rollBack();
587 587
             }
588 588
         }
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
             "domain" => $this->getDomain(),
635 635
             "listLabel" => self::API_LIST_NAME_FIELD,
636 636
             'modelId' => self::API_MODEL_KEY_FIELD,
637
-            'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)),
638
-            "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)),
637
+            'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)),
638
+            "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)),
639 639
         ), [], '');
640 640
     }
641 641
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
                 $total = $this->list->getNbResults();
676 676
                 $pages = $this->list->getLastPage();
677 677
             }
678
-        } catch (\Exception $e) {
678
+        }catch (\Exception $e) {
679 679
             Logger::getInstance(get_class($this))->errorLog($e->getMessage());
680 680
         }
681 681
 
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
         $return = array();
695 695
         if (NULL === $model && method_exists($model, 'toArray')) {
696 696
             $code = 404;
697
-        } else {
697
+        }else {
698 698
             $return = $model->toArray();
699 699
         }
700 700
 
@@ -709,9 +709,9 @@  discard block
 block discarded – undo
709 709
         $pks = '';
710 710
         $sep = '';
711 711
         foreach ($tableMap->getPrimaryKeys() as $pk) {
712
-            $pks .= $sep . $pk->getFullyQualifiedName();
712
+            $pks .= $sep.$pk->getFullyQualifiedName();
713 713
             $sep = ', "|", ';
714 714
         }
715
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = self::API_LIST_NAME_FIELD;
715
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = self::API_LIST_NAME_FIELD;
716 716
     }
717 717
 }
Please login to merge, or discard this patch.
src/base/types/helpers/ApiHelper.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             } elseif ($mappedColumn->isText()) {
41 41
                 if ($mappedColumn->getSize() > 100) {
42 42
                     $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required);
43
-                } else {
43
+                }else {
44 44
                     $fDto = self::generateStringField($field, $required);
45 45
                 }
46 46
             } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         $fDto->entity = $relatedModel;
84 84
         $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName());
85 85
         $fDto->relatedField = $relatedField->getPhpName();
86
-        $fDto->url = Router::getInstance()->getRoute('api-' . $relatedModel);
86
+        $fDto->url = Router::getInstance()->getRoute('api-'.$relatedModel);
87 87
         return $fDto;
88 88
     }
89 89
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     {
191 191
         try {
192 192
             $column = $tableMap->getColumnByPhpName($field);
193
-        } catch (\Exception $e) {
193
+        }catch (\Exception $e) {
194 194
             Logger::log($e->getMessage(), LOG_ERR);
195 195
             $column = null;
196 196
         }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      * @param ModelCriteria $query
203 203
      * @param mixed $value
204 204
      */
205
-    private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null)
205
+    private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null)
206 206
     {
207 207
         $tableField = $column->getPhpName();
208 208
         if (preg_match('/^<=/', $value)) {
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
         } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) {
217 217
             $text = preg_replace('/(\'|\")/', '', $value);
218 218
             $text = preg_replace('/\ /', '%', $text);
219
-            $query->filterBy($tableField, '%' . $text . '%', Criteria::LIKE);
220
-        } else {
219
+            $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE);
220
+        }else {
221 221
             $query->filterBy($tableField, $value, Criteria::EQUAL);
222 222
         }
223 223
     }
@@ -228,24 +228,24 @@  discard block
 block discarded – undo
228 228
      * @param array $extraColumns
229 229
      * @param mixed $value
230 230
      */
231
-    public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null)
231
+    public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null)
232 232
     {
233 233
         $exp = 'CONCAT(';
234 234
         $sep = '';
235 235
         foreach ($tableMap->getColumns() as $column) {
236 236
             if ($column->isText()) {
237
-                $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")';
237
+                $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")';
238 238
                 $sep = ', " ", ';
239 239
             }
240 240
         }
241 241
         foreach ($extraColumns as $extra => $name) {
242
-            $exp .= $sep . $extra;
242
+            $exp .= $sep.$extra;
243 243
             $sep = ', " ", ';
244 244
         }
245 245
         $exp .= ")";
246 246
         $text = preg_replace('/(\'|\")/', '', $value);
247 247
         $text = preg_replace('/\ /', '%', $text);
248
-        $query->where($exp . Criteria::LIKE . '"%' . $text . '%"');
248
+        $query->where($exp.Criteria::LIKE.'"%'.$text.'%"');
249 249
     }
250 250
 
251 251
     /**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
      * @param string $field
256 256
      * @param mixed $value
257 257
      */
258
-    public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null)
258
+    public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null)
259 259
     {
260 260
         if ($column = self::checkFieldExists($tableMap, $field)) {
261 261
             self::addQueryFilter($column, $query, $value);
Please login to merge, or discard this patch.