@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $label = self::getLabel($property->getDocComment()); |
32 | 32 | $values = self::getValues($property->getDocComment()); |
33 | 33 | $isArray = (bool)preg_match('/\[\]$/', $instanceType); |
34 | - if($isArray) { |
|
34 | + if ($isArray) { |
|
35 | 35 | $instanceType = str_replace('[]', '', $instanceType); |
36 | 36 | } |
37 | - if($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
37 | + if ($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
38 | 38 | list($type, $format) = DocumentorHelper::translateSwaggerFormats($instanceType); |
39 | 39 | $variables[$property->getName()] = [ |
40 | 40 | 'type' => $type, |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 'required' => $isRequired, |
43 | 43 | 'description' => $label, |
44 | 44 | ]; |
45 | - } else { |
|
45 | + }else { |
|
46 | 46 | $instance = new ReflectionClass($instanceType); |
47 | 47 | $variables[$property->getName()] = [ |
48 | 48 | 'is_array' => $isArray, |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | 'properties' => self::extractVariables($instance), |
52 | 52 | ]; |
53 | 53 | } |
54 | - if(!empty($values)){ |
|
54 | + if (!empty($values)) { |
|
55 | 55 | $variables[$property->getName()]['enum'] = $values; |
56 | 56 | } |
57 | 57 | } |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public static function constructInjectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
157 | 157 | { |
158 | - Logger::log('Create inyectable instance for ' . $classNameSpace); |
|
158 | + Logger::log('Create inyectable instance for '.$classNameSpace); |
|
159 | 159 | $reflector = new ReflectionClass($calledClass); |
160 | 160 | $property = $reflector->getProperty($variable); |
161 | 161 | $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace; |
162 | 162 | if (true === $singleton && method_exists($varInstanceType, 'getInstance')) { |
163 | 163 | $instance = $varInstanceType::getInstance(); |
164 | - } else { |
|
164 | + }else { |
|
165 | 165 | $instance = new $varInstanceType(); |
166 | 166 | } |
167 | 167 | return $instance; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public static function getClassProperties($class) |
176 | 176 | { |
177 | 177 | $properties = []; |
178 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
178 | + Logger::log('Extracting annotations properties from class '.$class); |
|
179 | 179 | $selfReflector = new ReflectionClass($class); |
180 | 180 | if (false !== $selfReflector->getParentClass()) { |
181 | 181 | $properties = self::getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -92,7 +92,7 @@ |
||
92 | 92 | * @return string|null |
93 | 93 | */ |
94 | 94 | public static function extractFromDoc($needle, $comments, $default = null) { |
95 | - preg_match('/@' . $needle . '\ (.*)(\n|\r)/im', $comments, $matches); |
|
95 | + preg_match('/@'.$needle.'\ (.*)(\n|\r)/im', $comments, $matches); |
|
96 | 96 | return (count($matches) > 0) ? $matches[1] : $default; |
97 | 97 | } |
98 | 98 | } |
@@ -39,24 +39,24 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function findTranslations($path, $locale) |
41 | 41 | { |
42 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
43 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
42 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
43 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
44 | 44 | |
45 | 45 | $translations = array(); |
46 | 46 | if (file_exists($path)) { |
47 | 47 | $d = dir($path); |
48 | 48 | while (false !== ($dir = $d->read())) { |
49 | 49 | GeneratorHelper::createDir($localePath); |
50 | - if (!file_exists($localePath . 'translations.po')) { |
|
51 | - file_put_contents($localePath . 'translations.po', ''); |
|
50 | + if (!file_exists($localePath.'translations.po')) { |
|
51 | + file_put_contents($localePath.'translations.po', ''); |
|
52 | 52 | } |
53 | - $inspect_path = realpath($path . DIRECTORY_SEPARATOR . $dir); |
|
54 | - $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext " . |
|
55 | - $inspect_path . DIRECTORY_SEPARATOR . |
|
53 | + $inspect_path = realpath($path.DIRECTORY_SEPARATOR.$dir); |
|
54 | + $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ". |
|
55 | + $inspect_path.DIRECTORY_SEPARATOR. |
|
56 | 56 | "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po"; |
57 | - if (is_dir($path . DIRECTORY_SEPARATOR . $dir) && preg_match('/^\./', $dir) == 0) { |
|
58 | - $res = t('Revisando directorio: ') . $inspect_path; |
|
59 | - $res .= t('Comando ejecutado: ') . $cmd_php; |
|
57 | + if (is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./', $dir) == 0) { |
|
58 | + $res = t('Revisando directorio: ').$inspect_path; |
|
59 | + $res .= t('Comando ejecutado: ').$cmd_php; |
|
60 | 60 | $res .= shell_exec($cmd_php); |
61 | 61 | usleep(10); |
62 | 62 | $translations[] = $res; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function createStructureModule($module, $force = false, $type = "", $apiClass = "") |
79 | 79 | { |
80 | - $mod_path = CORE_DIR . DIRECTORY_SEPARATOR; |
|
80 | + $mod_path = CORE_DIR.DIRECTORY_SEPARATOR; |
|
81 | 81 | $module = ucfirst($module); |
82 | 82 | $this->createModulePath($module, $mod_path); |
83 | 83 | $this->createModulePathTree($module, $mod_path); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // Creates the src folder |
99 | 99 | GeneratorHelper::createDir($mod_path); |
100 | 100 | // Create module path |
101 | - GeneratorHelper::createDir($mod_path . $module); |
|
101 | + GeneratorHelper::createDir($mod_path.$module); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | $this->log->addLog("Generamos la estructura"); |
114 | 114 | $paths = [ |
115 | 115 | "Api", "Config", "Controller", "Models", "Public", "Templates", "Services", "Test", "Doc", |
116 | - "Locale", "Locale/" . Config::getParam('default.locale', 'es_ES'), "Locale/" . Config::getParam('default.locale', 'es_ES') . "/LC_MESSAGES" |
|
116 | + "Locale", "Locale/".Config::getParam('default.locale', 'es_ES'), "Locale/".Config::getParam('default.locale', 'es_ES')."/LC_MESSAGES" |
|
117 | 117 | ]; |
118 | - $module_path = $mod_path . $module; |
|
118 | + $module_path = $mod_path.$module; |
|
119 | 119 | foreach ($paths as $path) { |
120 | - GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . $path); |
|
120 | + GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR.$path); |
|
121 | 121 | } |
122 | 122 | //Creamos las carpetas de los assets |
123 | 123 | $htmlPaths = array("css", "js", "img", "media", "font"); |
124 | 124 | foreach ($htmlPaths as $path) { |
125 | - GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path); |
|
125 | + GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | private function createModuleBaseFiles($module, $mod_path, $force = false, $controllerType = '') |
137 | 137 | { |
138 | - $module_path = $mod_path . $module; |
|
138 | + $module_path = $mod_path.$module; |
|
139 | 139 | $this->generateControllerTemplate($module, $module_path, $force, $controllerType); |
140 | 140 | $this->generateServiceTemplate($module, $module_path, $force); |
141 | 141 | $this->genereateAutoloaderTemplate($module, $module_path, $force); |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | private function createModuleModels($module, $path) |
155 | 155 | { |
156 | - $module_path = $path . $module; |
|
157 | - $module_path = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $module_path); |
|
156 | + $module_path = $path.$module; |
|
157 | + $module_path = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $module_path); |
|
158 | 158 | |
159 | 159 | $configGenerator = $this->getConfigGenerator($module_path); |
160 | 160 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | $configTemplate = $this->tpl->dump("generator/config.propel.template.twig", array( |
165 | 165 | "module" => $module, |
166 | 166 | )); |
167 | - $this->writeTemplateToFile($configTemplate, CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config" . |
|
168 | - DIRECTORY_SEPARATOR . "config.php", true); |
|
167 | + $this->writeTemplateToFile($configTemplate, CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config". |
|
168 | + DIRECTORY_SEPARATOR."config.php", true); |
|
169 | 169 | $this->log->addLog("Generado config genérico para propel"); |
170 | 170 | } |
171 | 171 | |
@@ -187,28 +187,28 @@ discard block |
||
187 | 187 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
188 | 188 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
189 | 189 | "class" => $class, |
190 | - "controllerType" => $class . "Base", |
|
190 | + "controllerType" => $class."Base", |
|
191 | 191 | "is_base" => false |
192 | 192 | )); |
193 | - $controller = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" . |
|
194 | - DIRECTORY_SEPARATOR . "{$class}Controller.php", $force); |
|
193 | + $controller = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller". |
|
194 | + DIRECTORY_SEPARATOR."{$class}Controller.php", $force); |
|
195 | 195 | |
196 | 196 | $controllerBody = $this->tpl->dump("generator/controller.template.twig", array( |
197 | 197 | "module" => $module, |
198 | 198 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
199 | 199 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
200 | - "class" => $class . "Base", |
|
200 | + "class" => $class."Base", |
|
201 | 201 | "service" => $class, |
202 | 202 | "controllerType" => $controllerType, |
203 | 203 | "is_base" => true, |
204 | 204 | "domain" => $class, |
205 | 205 | )); |
206 | - $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" . |
|
207 | - DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true); |
|
206 | + $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller". |
|
207 | + DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true); |
|
208 | 208 | |
209 | - $filename = $mod_path . DIRECTORY_SEPARATOR . "Test" . DIRECTORY_SEPARATOR . "{$class}Test.php"; |
|
209 | + $filename = $mod_path.DIRECTORY_SEPARATOR."Test".DIRECTORY_SEPARATOR."{$class}Test.php"; |
|
210 | 210 | $test = true; |
211 | - if(!file_exists($filename)) { |
|
211 | + if (!file_exists($filename)) { |
|
212 | 212 | $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array( |
213 | 213 | "module" => $module, |
214 | 214 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | private function generateBaseApiTemplate($module, $modPath, $force = false, $apiClass = "") |
230 | 230 | { |
231 | 231 | $created = true; |
232 | - $modelPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
233 | - $apiPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Api'; |
|
232 | + $modelPath = $modPath.$module.DIRECTORY_SEPARATOR.'Models'; |
|
233 | + $apiPath = $modPath.$module.DIRECTORY_SEPARATOR.'Api'; |
|
234 | 234 | if (file_exists($modelPath)) { |
235 | 235 | $dir = dir($modelPath); |
236 | 236 | $this->generateApiFiles($module, $force, $apiClass, $dir, $apiPath); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | //Generamos el fichero de configuración |
249 | 249 | $this->log->addLog("Generamos fichero vacío de configuración"); |
250 | 250 | return $this->writeTemplateToFile("<?php\n\t", |
251 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", |
|
251 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", |
|
252 | 252 | $force); |
253 | 253 | } |
254 | 254 | |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | //Generamos el fichero de configuración |
264 | 264 | $this->log->addLog("Generamos ficheros para assets base"); |
265 | 265 | $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", |
266 | - $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", |
|
266 | + $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", |
|
267 | 267 | $force); |
268 | 268 | $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", |
269 | - $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", |
|
269 | + $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", |
|
270 | 270 | $force); |
271 | 271 | return ($css && $js); |
272 | 272 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | "class" => $class, |
289 | 289 | )); |
290 | 290 | return $this->writeTemplateToFile($controller, |
291 | - $mod_path . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php", |
|
291 | + $mod_path.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php", |
|
292 | 292 | $force); |
293 | 293 | } |
294 | 294 | |
@@ -307,13 +307,13 @@ discard block |
||
307 | 307 | "autoloader" => preg_replace('/(\\\|\/)/', '_', $module), |
308 | 308 | "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module), |
309 | 309 | )); |
310 | - $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force); |
|
310 | + $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force); |
|
311 | 311 | |
312 | 312 | $this->log->addLog("Generamos el phpunit"); |
313 | 313 | $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array( |
314 | 314 | "module" => $module, |
315 | 315 | )); |
316 | - $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force); |
|
316 | + $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force); |
|
317 | 317 | return $autoload && $phpunit; |
318 | 318 | } |
319 | 319 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | "db" => $this->config->get("db_name"), |
335 | 335 | )); |
336 | 336 | return $this->writeTemplateToFile($schema, |
337 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", |
|
337 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", |
|
338 | 338 | $force); |
339 | 339 | } |
340 | 340 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | "namespace" => preg_replace('/(\\\|\/)/', '', $module), |
353 | 353 | )); |
354 | 354 | return $this->writeTemplateToFile($build_properties, |
355 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml", |
|
355 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml", |
|
356 | 356 | $force); |
357 | 357 | } |
358 | 358 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | "module" => $module, |
371 | 371 | )); |
372 | 372 | return $this->writeTemplateToFile($index, |
373 | - $mod_path . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", |
|
373 | + $mod_path.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", |
|
374 | 374 | $force); |
375 | 375 | } |
376 | 376 | |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | try { |
389 | 389 | $this->cache->storeData($filename, $fileContent, Cache::TEXT, true); |
390 | 390 | $created = true; |
391 | - } catch (\Exception $e) { |
|
391 | + }catch (\Exception $e) { |
|
392 | 392 | Logger::log($e->getMessage(), LOG_ERR); |
393 | 393 | } |
394 | - } else { |
|
395 | - Logger::log($filename . t(' not exists or cant write'), LOG_ERR); |
|
394 | + }else { |
|
395 | + Logger::log($filename.t(' not exists or cant write'), LOG_ERR); |
|
396 | 396 | } |
397 | 397 | return $created; |
398 | 398 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | )); |
424 | 424 | |
425 | 425 | return $this->writeTemplateToFile($controller, |
426 | - $mod_path . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
426 | + $mod_path.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | "package" => $package, |
449 | 449 | )); |
450 | 450 | |
451 | - return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
451 | + return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -462,12 +462,12 @@ discard block |
||
462 | 462 | { |
463 | 463 | if (file_exists($filename_path)) { |
464 | 464 | $destfolder = basename($filename_path); |
465 | - if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) { |
|
465 | + if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) { |
|
466 | 466 | if (is_dir($filename_path)) { |
467 | - self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
468 | - } else { |
|
469 | - if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) { |
|
470 | - throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
467 | + self::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
468 | + }else { |
|
469 | + if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) { |
|
470 | + throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | GeneratorHelper::createDir($dst); |
487 | 487 | while (false !== ($file = readdir($dir))) { |
488 | 488 | if (($file != '.') && ($file != '..')) { |
489 | - if (is_dir($src . '/' . $file)) { |
|
490 | - self::copyr($src . '/' . $file, $dst . '/' . $file); |
|
491 | - } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) { |
|
492 | - throw new ConfigException("Can't copy " . $src . " to " . $dst); |
|
489 | + if (is_dir($src.'/'.$file)) { |
|
490 | + self::copyr($src.'/'.$file, $dst.'/'.$file); |
|
491 | + } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) { |
|
492 | + throw new ConfigException("Can't copy ".$src." to ".$dst); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | */ |
503 | 503 | private function getPropelPaths($module_path) |
504 | 504 | { |
505 | - $moduleDir = CORE_DIR . DIRECTORY_SEPARATOR . $module_path; |
|
505 | + $moduleDir = CORE_DIR.DIRECTORY_SEPARATOR.$module_path; |
|
506 | 506 | GeneratorHelper::createDir($moduleDir); |
507 | 507 | $moduleDir = realpath($moduleDir); |
508 | - $configDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config'; |
|
509 | - $sqlDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Sql'; |
|
510 | - $migrationDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Migrations'; |
|
508 | + $configDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'; |
|
509 | + $sqlDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Sql'; |
|
510 | + $migrationDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Migrations'; |
|
511 | 511 | $paths = [ |
512 | 512 | 'projectDir' => $moduleDir, |
513 | 513 | 'outputDir' => $moduleDir, |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | private function setupManager(GeneratorConfig $configGenerator, AbstractManager &$manager, $workingDir = CORE_DIR) |
573 | 573 | { |
574 | 574 | $manager->setGeneratorConfig($configGenerator); |
575 | - $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'] . DIRECTORY_SEPARATOR . 'schema.xml'); |
|
575 | + $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'].DIRECTORY_SEPARATOR.'schema.xml'); |
|
576 | 576 | $manager->setSchemas([$schemaFile]); |
577 | - $manager->setLoggerClosure(function ($message) { |
|
577 | + $manager->setLoggerClosure(function($message) { |
|
578 | 578 | Logger::log($message, LOG_INFO); |
579 | 579 | }); |
580 | 580 | $manager->setWorkingDirectory($workingDir); |
@@ -593,15 +593,15 @@ discard block |
||
593 | 593 | $base = $dir->path; |
594 | 594 | while ($file = $dir->read()) { |
595 | 595 | if (!in_array(strtolower($file), ['.', '..', 'base', 'map'])) { |
596 | - if (is_dir($base . DIRECTORY_SEPARATOR . $file)) { |
|
597 | - $this->generateApiFiles($module, $force, $apiClass, dir($base . DIRECTORY_SEPARATOR . $file), $apiPath . DIRECTORY_SEPARATOR . $file, $file); |
|
598 | - } else if (!preg_match('/Query\.php$/i', $file) |
|
596 | + if (is_dir($base.DIRECTORY_SEPARATOR.$file)) { |
|
597 | + $this->generateApiFiles($module, $force, $apiClass, dir($base.DIRECTORY_SEPARATOR.$file), $apiPath.DIRECTORY_SEPARATOR.$file, $file); |
|
598 | + }else if (!preg_match('/Query\.php$/i', $file) |
|
599 | 599 | && !preg_match('/I18n\.php$/i', $file) |
600 | 600 | && preg_match('/\.php$/i', $file) |
601 | 601 | ) { |
602 | 602 | $filename = str_replace(".php", "", $file); |
603 | 603 | $this->log->addLog("Generamos Api BASES para {$filename}"); |
604 | - if($this->checkIfIsModel($module, $filename, $package)) { |
|
604 | + if ($this->checkIfIsModel($module, $filename, $package)) { |
|
605 | 605 | $this->createApiBaseFile($module, $apiPath, $filename, $apiClass, $package); |
606 | 606 | $this->createApi($module, $apiPath, $force, $filename, $package); |
607 | 607 | } |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | $parts[] = $package; |
625 | 625 | } |
626 | 626 | $parts[] = $filename; |
627 | - $namespace = '\\' . implode('\\', $parts); |
|
627 | + $namespace = '\\'.implode('\\', $parts); |
|
628 | 628 | $reflectorClass = new \ReflectionClass($namespace); |
629 | 629 | $isModel = $reflectorClass->isInstantiable(); |
630 | 630 | return $isModel; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if (count($pks) === 1) { |
82 | 82 | $pks = array_keys($pks); |
83 | 83 | return [ |
84 | - $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD |
|
84 | + $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD |
|
85 | 85 | ]; |
86 | 86 | } |
87 | 87 | if (count($pks) > 1) { |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | $principal = ''; |
90 | 90 | $sep = 'CONCAT('; |
91 | 91 | foreach ($pks as $pk) { |
92 | - $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName(); |
|
93 | - $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName(); |
|
94 | - $sep = ', "' . Api::API_PK_SEPARATOR . '", '; |
|
92 | + $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName(); |
|
93 | + $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName(); |
|
94 | + $sep = ', "'.Api::API_PK_SEPARATOR.'", '; |
|
95 | 95 | } |
96 | 96 | $principal .= ')'; |
97 | 97 | $apiPks[$principal] = Api::API_MODEL_KEY_FIELD; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $pks = ''; |
119 | 119 | $sep = ''; |
120 | 120 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
121 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
121 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
122 | 122 | $sep = ', "|", '; |
123 | 123 | } |
124 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD; |
|
124 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | if (null !== $column) { |
145 | 145 | $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD; |
146 | - } else { |
|
146 | + }else { |
|
147 | 147 | $this->addClassListName($tableMap); |
148 | 148 | } |
149 | 149 | } |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | $this->addPkToList(); |
162 | 162 | } |
163 | 163 | if (!empty($this->extraColumns)) { |
164 | - if(Config::getParam('api.extrafields.compat', true)) { |
|
164 | + if (Config::getParam('api.extrafields.compat', true)) { |
|
165 | 165 | $fields = array_values($this->extraColumns); |
166 | - } else { |
|
166 | + }else { |
|
167 | 167 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
168 | 168 | $fields = explode(',', $returnFields ?: ''); |
169 | 169 | $fields[] = self::API_MODEL_KEY_FIELD; |
170 | 170 | } |
171 | 171 | foreach ($this->extraColumns as $expression => $columnName) { |
172 | - if(empty($fields) || in_array($columnName, $fields)) { |
|
172 | + if (empty($fields) || in_array($columnName, $fields)) { |
|
173 | 173 | $query->withColumn($expression, $columnName); |
174 | 174 | } |
175 | 175 | } |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | { |
201 | 201 | $this->extractApiLang(); |
202 | 202 | $model = $this->getModelNamespace(); |
203 | - $modelI18n = $model . 'I18n'; |
|
203 | + $modelI18n = $model.'I18n'; |
|
204 | 204 | if (method_exists($query, 'useI18nQuery')) { |
205 | 205 | $query->useI18nQuery($this->lang); |
206 | 206 | $modelParts = explode('\\', $modelI18n); |
207 | - $i18nMapClass = str_replace(end($modelParts), 'Map\\' . end($modelParts), $modelI18n) . 'TableMap'; |
|
207 | + $i18nMapClass = str_replace(end($modelParts), 'Map\\'.end($modelParts), $modelI18n).'TableMap'; |
|
208 | 208 | /** @var TableMap $modelI18nTableMap */ |
209 | 209 | $modelI18nTableMap = $i18nMapClass::getTableMap(); |
210 | - foreach($modelI18nTableMap->getColumns() as $columnMap) { |
|
211 | - if(!$columnMap->isPrimaryKey()) { |
|
210 | + foreach ($modelI18nTableMap->getColumns() as $columnMap) { |
|
211 | + if (!$columnMap->isPrimaryKey()) { |
|
212 | 212 | $query->withColumn($columnMap->getFullyQualifiedName(), ApiHelper::getColumnMapName($columnMap)); |
213 | - } elseif(!$columnMap->isForeignKey()) { |
|
214 | - $query->withColumn('IFNULL(' . $columnMap->getFullyQualifiedName() . ', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap)); |
|
213 | + } elseif (!$columnMap->isForeignKey()) { |
|
214 | + $query->withColumn('IFNULL('.$columnMap->getFullyQualifiedName().', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap)); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | } |
@@ -225,22 +225,22 @@ discard block |
||
225 | 225 | $model->fromArray($data, ApiHelper::getFieldTypes()); |
226 | 226 | $tableMap = $this->getTableMap(); |
227 | 227 | try { |
228 | - if($tableMap->hasRelation($tableMap->getPhpName() . 'I18n')) |
|
228 | + if ($tableMap->hasRelation($tableMap->getPhpName().'I18n')) |
|
229 | 229 | { |
230 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
230 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
231 | 231 | $i18NTableMap = $relateI18n->getLocalTable(); |
232 | 232 | $model->setLocale(array_key_exists('Locale', $data) ? $data['Locale'] : (array_key_exists('locale', $data) ? $data['locale'] : Request::header(Api::HEADER_API_LANG, 'es_ES'))); |
233 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
234 | - $method = 'set' . $columnMap->getPhpName(); |
|
233 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
234 | + $method = 'set'.$columnMap->getPhpName(); |
|
235 | 235 | $dtoColumnName = ApiHelper::getColumnMapName($columnMap); |
236 | - if(array_key_exists($dtoColumnName, $data) |
|
236 | + if (array_key_exists($dtoColumnName, $data) |
|
237 | 237 | && method_exists($model, $method) |
238 | 238 | && !($columnMap->isPrimaryKey() && $columnMap->isForeignKey())) { |
239 | 239 | $model->$method($data[$dtoColumnName]); |
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
243 | - } catch(Exception $e) { |
|
243 | + }catch (Exception $e) { |
|
244 | 244 | Logger::log($e->getMessage(), LOG_DEBUG); |
245 | 245 | } |
246 | 246 | } |
@@ -122,27 +122,27 @@ discard block |
||
122 | 122 | $behaviors = $tableMap->getBehaviors(); |
123 | 123 | foreach ($map::getFieldNames() as $field) { |
124 | 124 | $fDto = self::parseFormField($domain, $tableMap, $field, $behaviors); |
125 | - if(null !== $fDto) { |
|
125 | + if (null !== $fDto) { |
|
126 | 126 | $form->addField($fDto); |
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - if(array_key_exists('i18n', $behaviors)) { |
|
131 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
132 | - if(null !== $relateI18n) { |
|
130 | + if (array_key_exists('i18n', $behaviors)) { |
|
131 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
132 | + if (null !== $relateI18n) { |
|
133 | 133 | $i18NTableMap = $relateI18n->getLocalTable(); |
134 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
134 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
135 | 135 | $columnName = self::getColumnMapName($columnMap); |
136 | - if(!$form->fieldExists($columnName)) { |
|
136 | + if (!$form->fieldExists($columnName)) { |
|
137 | 137 | /** @var Field $fDto */ |
138 | 138 | $fDto = self::parseFormField($domain, $i18NTableMap, $columnMap->getPhpName(), $i18NTableMap->getBehaviors()); |
139 | - if(null !== $fDto) { |
|
139 | + if (null !== $fDto) { |
|
140 | 140 | $fDto->pk = false; |
141 | 141 | $fDto->required = true; |
142 | - if(strtolower($fDto->name) === 'locale') { |
|
142 | + if (strtolower($fDto->name) === 'locale') { |
|
143 | 143 | $fDto->type = Field::COMBO_TYPE; |
144 | 144 | $languages = explode(',', Config::getParam('i18n.locales', Config::getParam('default.language', 'es_ES'))); |
145 | - foreach($languages as $language) { |
|
145 | + foreach ($languages as $language) { |
|
146 | 146 | $fDto->data[] = [ |
147 | 147 | $fDto->name => $language, |
148 | 148 | 'Label' => t($language), |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | { |
170 | 170 | $column = null; |
171 | 171 | try { |
172 | - foreach($tableMap->getColumns() as $tableMapColumn) { |
|
172 | + foreach ($tableMap->getColumns() as $tableMapColumn) { |
|
173 | 173 | $columnName = $tableMapColumn->getPhpName(); |
174 | - if(preg_match('/^'.$field.'$/i', $columnName)) { |
|
174 | + if (preg_match('/^'.$field.'$/i', $columnName)) { |
|
175 | 175 | $column = $tableMapColumn; |
176 | 176 | break; |
177 | 177 | } |
178 | 178 | } |
179 | - } catch (\Exception $e) { |
|
179 | + }catch (\Exception $e) { |
|
180 | 180 | Logger::log($e->getMessage(), LOG_DEBUG); |
181 | 181 | } |
182 | 182 | return $column; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public static function getFieldTypes() { |
189 | 189 | $configType = Config::getParam('api.field.case', TableMap::TYPE_PHPNAME); |
190 | - switch($configType) { |
|
190 | + switch ($configType) { |
|
191 | 191 | default: |
192 | 192 | case 'UpperCamelCase': |
193 | 193 | case TableMap::TYPE_PHPNAME: |