@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function createStructureModule($module, $force = false, $type = "", $apiClass = "") |
| 41 | 41 | { |
| 42 | - $modPath = CORE_DIR . DIRECTORY_SEPARATOR; |
|
| 42 | + $modPath = CORE_DIR.DIRECTORY_SEPARATOR; |
|
| 43 | 43 | $module = ucfirst($module); |
| 44 | 44 | $this->createModulePath($module, $modPath); |
| 45 | 45 | $this->createModulePathTree($module, $modPath); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | private function createModuleBaseFiles($module, $modPath, $force = false, $controllerType = '') |
| 62 | 62 | { |
| 63 | - $modulePath = $modPath . $module; |
|
| 63 | + $modulePath = $modPath.$module; |
|
| 64 | 64 | $this->generateControllerTemplate($module, $modulePath, $force, $controllerType); |
| 65 | 65 | $this->generateServiceTemplate($module, $modulePath, $force); |
| 66 | 66 | $this->generateSchemaTemplate($module, $modulePath, $force); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $this->genereateAutoloaderTemplate($module, $modulePath, $force); |
| 81 | 81 | $this->generatePropertiesTemplate($module, $modulePath, $force); |
| 82 | 82 | $this->generateConfigTemplate($modulePath, $force); |
| 83 | - $this->createModuleModels($module, CORE_DIR . DIRECTORY_SEPARATOR); |
|
| 83 | + $this->createModuleModels($module, CORE_DIR.DIRECTORY_SEPARATOR); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -100,28 +100,28 @@ discard block |
||
| 100 | 100 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
| 101 | 101 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
| 102 | 102 | "class" => $class, |
| 103 | - "controllerType" => $class . "Base", |
|
| 103 | + "controllerType" => $class."Base", |
|
| 104 | 104 | "is_base" => false |
| 105 | 105 | )); |
| 106 | - $controller = $this->writeTemplateToFile($controllerBody, $modPath . DIRECTORY_SEPARATOR . "Controller" . |
|
| 107 | - DIRECTORY_SEPARATOR . "{$class}Controller.php", $force); |
|
| 106 | + $controller = $this->writeTemplateToFile($controllerBody, $modPath.DIRECTORY_SEPARATOR."Controller". |
|
| 107 | + DIRECTORY_SEPARATOR."{$class}Controller.php", $force); |
|
| 108 | 108 | |
| 109 | 109 | $controllerBody = $this->tpl->dump("generator/controller.template.twig", array( |
| 110 | 110 | "module" => $module, |
| 111 | 111 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
| 112 | 112 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
| 113 | - "class" => $class . "Base", |
|
| 113 | + "class" => $class."Base", |
|
| 114 | 114 | "service" => $class, |
| 115 | 115 | "controllerType" => $controllerType, |
| 116 | 116 | "is_base" => true, |
| 117 | 117 | "domain" => $class, |
| 118 | 118 | )); |
| 119 | - $controllerBase = $this->writeTemplateToFile($controllerBody, $modPath . DIRECTORY_SEPARATOR . "Controller" . |
|
| 120 | - DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true); |
|
| 119 | + $controllerBase = $this->writeTemplateToFile($controllerBody, $modPath.DIRECTORY_SEPARATOR."Controller". |
|
| 120 | + DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true); |
|
| 121 | 121 | |
| 122 | - $filename = $modPath . DIRECTORY_SEPARATOR . "Test" . DIRECTORY_SEPARATOR . "{$class}Test.php"; |
|
| 122 | + $filename = $modPath.DIRECTORY_SEPARATOR."Test".DIRECTORY_SEPARATOR."{$class}Test.php"; |
|
| 123 | 123 | $test = true; |
| 124 | - if(!file_exists($filename)) { |
|
| 124 | + if (!file_exists($filename)) { |
|
| 125 | 125 | $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array( |
| 126 | 126 | "module" => $module, |
| 127 | 127 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | private function createModuleModels($module, $path) |
| 142 | 142 | { |
| 143 | - $modulePath = $path . $module; |
|
| 144 | - $modulePath = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $modulePath); |
|
| 143 | + $modulePath = $path.$module; |
|
| 144 | + $modulePath = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $modulePath); |
|
| 145 | 145 | |
| 146 | 146 | $configGenerator = $this->getConfigGenerator($modulePath); |
| 147 | 147 | |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | $configTemplate = $this->tpl->dump("generator/config.propel.template.twig", array( |
| 152 | 152 | "module" => $module, |
| 153 | 153 | )); |
| 154 | - $this->writeTemplateToFile($configTemplate, CORE_DIR . DIRECTORY_SEPARATOR . $modulePath . DIRECTORY_SEPARATOR . "Config" . |
|
| 155 | - DIRECTORY_SEPARATOR . "config.php", true); |
|
| 154 | + $this->writeTemplateToFile($configTemplate, CORE_DIR.DIRECTORY_SEPARATOR.$modulePath.DIRECTORY_SEPARATOR."Config". |
|
| 155 | + DIRECTORY_SEPARATOR."config.php", true); |
|
| 156 | 156 | Logger::log("Generado config genérico para propel"); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | private function generateBaseApiTemplate($module, $modPath, $force = false, $apiClass = "") |
| 168 | 168 | { |
| 169 | 169 | $created = true; |
| 170 | - $modelPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
| 171 | - $apiPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Api'; |
|
| 170 | + $modelPath = $modPath.$module.DIRECTORY_SEPARATOR.'Models'; |
|
| 171 | + $apiPath = $modPath.$module.DIRECTORY_SEPARATOR.'Api'; |
|
| 172 | 172 | if (file_exists($modelPath)) { |
| 173 | 173 | $dir = dir($modelPath); |
| 174 | 174 | $this->generateApiFiles($module, $force, $apiClass, $dir, $apiPath); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | //Generamos el fichero de configuración |
| 187 | 187 | Logger::log("Generamos fichero vacío de configuración"); |
| 188 | 188 | return $this->writeTemplateToFile("<?php\n\t", |
| 189 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", |
|
| 189 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", |
|
| 190 | 190 | $force); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | "db" => $this->config->get("db_name"), |
| 208 | 208 | )); |
| 209 | 209 | return $this->writeTemplateToFile($schema, |
| 210 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", |
|
| 210 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", |
|
| 211 | 211 | $force); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | "namespace" => preg_replace('/(\\\|\/)/', '', $module), |
| 226 | 226 | )); |
| 227 | 227 | return $this->writeTemplateToFile($buildProperties, |
| 228 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.php", |
|
| 228 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.php", |
|
| 229 | 229 | $force); |
| 230 | 230 | } |
| 231 | 231 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | "module" => $module, |
| 244 | 244 | )); |
| 245 | 245 | return $this->writeTemplateToFile($index, |
| 246 | - $modPath . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", |
|
| 246 | + $modPath.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", |
|
| 247 | 247 | $force); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | )); |
| 274 | 274 | |
| 275 | 275 | return $this->writeTemplateToFile($controller, |
| 276 | - $modPath . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
| 276 | + $modPath.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | "package" => $package, |
| 299 | 299 | )); |
| 300 | 300 | |
| 301 | - return $this->writeTemplateToFile($controller, $modPath . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
| 301 | + return $this->writeTemplateToFile($controller, $modPath.DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -315,15 +315,15 @@ discard block |
||
| 315 | 315 | $base = $dir->path; |
| 316 | 316 | while ($file = $dir->read()) { |
| 317 | 317 | if (!in_array(strtolower($file), ['.', '..', 'base', 'map'])) { |
| 318 | - if (is_dir($base . DIRECTORY_SEPARATOR . $file)) { |
|
| 319 | - $this->generateApiFiles($module, $force, $apiClass, dir($base . DIRECTORY_SEPARATOR . $file), $apiPath . DIRECTORY_SEPARATOR . $file, $file); |
|
| 320 | - } else if (!preg_match('/Query\.php$/i', $file) |
|
| 318 | + if (is_dir($base.DIRECTORY_SEPARATOR.$file)) { |
|
| 319 | + $this->generateApiFiles($module, $force, $apiClass, dir($base.DIRECTORY_SEPARATOR.$file), $apiPath.DIRECTORY_SEPARATOR.$file, $file); |
|
| 320 | + }else if (!preg_match('/Query\.php$/i', $file) |
|
| 321 | 321 | && !preg_match('/I18n\.php$/i', $file) |
| 322 | 322 | && preg_match('/\.php$/i', $file) |
| 323 | 323 | ) { |
| 324 | 324 | $filename = str_replace(".php", "", $file); |
| 325 | 325 | $this->log->addLog("Generamos Api BASES para {$filename}"); |
| 326 | - if($this->checkIfIsModel($module, $filename, $package)) { |
|
| 326 | + if ($this->checkIfIsModel($module, $filename, $package)) { |
|
| 327 | 327 | $this->createApiBaseFile($module, $apiPath, $filename, $apiClass, $package); |
| 328 | 328 | $this->createApi($module, $apiPath, $force, $filename, $package); |
| 329 | 329 | } |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | $parts[] = $package; |
| 347 | 347 | } |
| 348 | 348 | $parts[] = $filename; |
| 349 | - $namespace = '\\' . implode('\\', $parts); |
|
| 349 | + $namespace = '\\'.implode('\\', $parts); |
|
| 350 | 350 | $reflectorClass = new \ReflectionClass($namespace); |
| 351 | 351 | $isModel = $reflectorClass->isInstantiable(); |
| 352 | 352 | return $isModel; |