@@ -21,7 +21,7 @@ |
||
21 | 21 | { |
22 | 22 | $array = array(); |
23 | 23 | $array['fields'] = array(); |
24 | - foreach($this->fields as $field) { |
|
24 | + foreach ($this->fields as $field) { |
|
25 | 25 | $array['fields'][] = $field->__toArray(); |
26 | 26 | } |
27 | 27 | return $array; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @param ModelCriteria $query |
176 | 176 | */ |
177 | - private function addOrders(ModelCriteria &$query) |
|
177 | + private function addOrders(ModelCriteria & $query) |
|
178 | 178 | { |
179 | 179 | $orderAdded = FALSE; |
180 | 180 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $orderAdded = TRUE; |
183 | 183 | if ($direction === Order::ASC) { |
184 | 184 | $query->addAscendingOrderByColumn($field); |
185 | - } else { |
|
185 | + }else { |
|
186 | 186 | $query->addDescendingOrderByColumn($field); |
187 | 187 | } |
188 | 188 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param ModelCriteria $query |
199 | 199 | */ |
200 | - private function addFilters(ModelCriteria &$query) |
|
200 | + private function addFilters(ModelCriteria & $query) |
|
201 | 201 | { |
202 | 202 | if (count($this->query) > 0) { |
203 | 203 | foreach ($this->query as $field => $value) { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
215 | 215 | $text = preg_replace('/(\'|\")/', '', $value); |
216 | 216 | $query->filterBy($tableField, $text, Criteria::LIKE); |
217 | - } else { |
|
217 | + }else { |
|
218 | 218 | $query->filterBy($tableField, $value, Criteria::EQUAL); |
219 | 219 | } |
220 | 220 | } |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | list($page, $limit) = $this->extractPagination(); |
236 | 236 | if ($limit == -1) { |
237 | 237 | $this->list = $query->find($this->con); |
238 | - } else { |
|
238 | + }else { |
|
239 | 239 | $this->list = $query->paginate($page, $limit, $this->con); |
240 | 240 | } |
241 | - } catch (\Exception $e) { |
|
241 | + }catch (\Exception $e) { |
|
242 | 242 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
243 | 243 | } |
244 | 244 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | try { |
254 | 254 | $query = $this->extractQuery(); |
255 | 255 | $this->model = $query->findPk($pk); |
256 | - } catch (\Exception $e) { |
|
256 | + }catch (\Exception $e) { |
|
257 | 257 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
258 | 258 | } |
259 | 259 | } |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | $return = $this->list->toArray(); |
282 | 282 | $total = $this->list->getNbResults(); |
283 | 283 | $pages = $this->list->getLastPage(); |
284 | - } catch (\Exception $e) { |
|
284 | + }catch (\Exception $e) { |
|
285 | 285 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
286 | 286 | } |
287 | - } else { |
|
287 | + }else { |
|
288 | 288 | $this->hydrateModel($pk); |
289 | 289 | $return = ($this->getModel() instanceof ActiveRecordInterface) ? $this->getModel()->toArray() : NULL; |
290 | 290 | if (NULL === $return) { |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $saved = TRUE; |
327 | 327 | $model = $this->model->toArray(); |
328 | 328 | } |
329 | - } catch (\Exception $e) { |
|
329 | + }catch (\Exception $e) { |
|
330 | 330 | Logger::getInstance()->errorLog($e->getMessage()); |
331 | 331 | } |
332 | 332 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $this->model->delete($this->con); |
355 | 355 | $deleted = TRUE; |
356 | 356 | } |
357 | - } catch (\Exception $e) { |
|
357 | + }catch (\Exception $e) { |
|
358 | 358 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
359 | 359 | } |
360 | 360 | } |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | */ |
398 | 398 | private function extractQuery() |
399 | 399 | { |
400 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
400 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
401 | 401 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
402 | 402 | $query = $queryReflector->getMethod('create')->invoke(NULL); |
403 | 403 | |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | if ($this->con->inTransaction()) { |
442 | 442 | if ($status === 200) { |
443 | 443 | $this->con->commit(); |
444 | - } else { |
|
444 | + }else { |
|
445 | 445 | $this->con->rollBack(); |
446 | 446 | } |
447 | 447 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | return $this->render('api.admin.html.twig', array( |
485 | 485 | "api" => $this->getApi(), |
486 | 486 | "domain" => $this->domain, |
487 | - "url" => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)), |
|
487 | + "url" => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)), |
|
488 | 488 | )); |
489 | 489 | } |
490 | 490 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use PSFS\base\config\Config; |
6 | 6 | use PSFS\base\Service; |
7 | 7 | |
8 | - class GeneratorService extends Service{ |
|
8 | + class GeneratorService extends Service { |
|
9 | 9 | /** |
10 | 10 | * @Inyectable |
11 | 11 | * @var \PSFS\base\config\Config Servicio de configuración |
@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public static function findTranslations($path, $locale) |
32 | 32 | { |
33 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
34 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
33 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
34 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
35 | 35 | |
36 | 36 | $translations = array(); |
37 | - if(file_exists($path)) |
|
37 | + if (file_exists($path)) |
|
38 | 38 | { |
39 | 39 | $d = dir($path); |
40 | - while(false !== ($dir = $d->read())) |
|
40 | + while (false !== ($dir = $d->read())) |
|
41 | 41 | { |
42 | 42 | Config::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 | 46 | $inspect_path = realpath($path.DIRECTORY_SEPARATOR.$dir); |
47 | - $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ". $inspect_path . DIRECTORY_SEPARATOR ."*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$locale_path}translations.po"; |
|
48 | - if(is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./',$dir) == 0) |
|
47 | + $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ".$inspect_path.DIRECTORY_SEPARATOR."*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$locale_path}translations.po"; |
|
48 | + if (is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./', $dir) == 0) |
|
49 | 49 | { |
50 | - $res = _('Revisando directorio: ') . $inspect_path; |
|
51 | - $res .= _('Comando ejecutado: '). $cmd_php; |
|
52 | - $res .= shell_exec($cmd_php);// . " >> " . __DIR__ . DIRECTORY_SEPARATOR . "debug.log 2>&1"); |
|
50 | + $res = _('Revisando directorio: ').$inspect_path; |
|
51 | + $res .= _('Comando ejecutado: ').$cmd_php; |
|
52 | + $res .= shell_exec($cmd_php); // . " >> " . __DIR__ . DIRECTORY_SEPARATOR . "debug.log 2>&1"); |
|
53 | 53 | usleep(10); |
54 | 54 | $translations[] = $res; |
55 | 55 | $translations = array_merge($translations, self::findTranslations($inspect_path, $locale)); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function createStructureModule($module, $force = false, $type = "") |
70 | 70 | { |
71 | - $mod_path = CORE_DIR . DIRECTORY_SEPARATOR; |
|
71 | + $mod_path = CORE_DIR.DIRECTORY_SEPARATOR; |
|
72 | 72 | $module = ucfirst($module); |
73 | 73 | $this->createModulePath($module, $mod_path); |
74 | 74 | $this->createModulePathTree($module, $mod_path); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | //Creamos el directorio base de los módulos |
90 | 90 | Config::createDir($mod_path); |
91 | 91 | //Creamos la carpeta del módulo |
92 | - Config::createDir($mod_path . $module); |
|
92 | + Config::createDir($mod_path.$module); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | //Creamos las carpetas CORE del módulo |
103 | 103 | $this->log->infoLog("Generamos la estructura"); |
104 | 104 | $paths = array("Api", "Api/base", "Config", "Controller", "Form", "Models", "Public", "Templates", "Services", "Test"); |
105 | - foreach($paths as $path) { |
|
106 | - Config::createDir($mod_path . $module . DIRECTORY_SEPARATOR . $path); |
|
105 | + foreach ($paths as $path) { |
|
106 | + Config::createDir($mod_path.$module.DIRECTORY_SEPARATOR.$path); |
|
107 | 107 | } |
108 | 108 | //Creamos las carpetas de los assets |
109 | 109 | $htmlPaths = array("css", "js", "img", "media", "font"); |
110 | - foreach($htmlPaths as $path) { |
|
111 | - Config::createDir($mod_path . $module . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path); |
|
110 | + foreach ($htmlPaths as $path) { |
|
111 | + Config::createDir($mod_path.$module.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -138,15 +138,15 @@ discard block |
||
138 | 138 | private function createModuleModels($module) |
139 | 139 | { |
140 | 140 | //Generamos las clases de propel y la configuración |
141 | - $exec = "export PATH=\$PATH:/opt/local/bin; " . BASE_DIR . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "propel "; |
|
142 | - $schemaOpt = " --schema-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Config"; |
|
143 | - $opt = " --config-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Config --output-dir=" . CORE_DIR . " --verbose"; |
|
144 | - $ret = shell_exec($exec . "build" . $opt . $schemaOpt); |
|
141 | + $exec = "export PATH=\$PATH:/opt/local/bin; ".BASE_DIR.DIRECTORY_SEPARATOR."vendor".DIRECTORY_SEPARATOR."bin".DIRECTORY_SEPARATOR."propel "; |
|
142 | + $schemaOpt = " --schema-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Config"; |
|
143 | + $opt = " --config-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Config --output-dir=".CORE_DIR." --verbose"; |
|
144 | + $ret = shell_exec($exec."build".$opt.$schemaOpt); |
|
145 | 145 | |
146 | 146 | $this->log->infoLog("Generamos clases invocando a propel:\n $ret"); |
147 | - $ret = shell_exec($exec . "sql:build" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Config" . $schemaOpt); |
|
147 | + $ret = shell_exec($exec."sql:build".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Config".$schemaOpt); |
|
148 | 148 | $this->log->infoLog("Generamos sql invocando a propel:\n $ret"); |
149 | - $ret = shell_exec($exec . "config:convert" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Config"); |
|
149 | + $ret = shell_exec($exec."config:convert".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Config"); |
|
150 | 150 | $this->log->infoLog("Generamos configuración invocando a propel:\n $ret"); |
151 | 151 | } |
152 | 152 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | "module" => $module, |
166 | 166 | "controllerType" => $controllerType, |
167 | 167 | )); |
168 | - return $this->writeTemplateToFile($controller, $mod_path . $module . DIRECTORY_SEPARATOR . "Controller" . DIRECTORY_SEPARATOR . "{$module}Controller.php", $force); |
|
168 | + return $this->writeTemplateToFile($controller, $mod_path.$module.DIRECTORY_SEPARATOR."Controller".DIRECTORY_SEPARATOR."{$module}Controller.php", $force); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | private function generateBaseApiTemplate($module, $mod_path, $force = false, $controllerType = "") |
179 | 179 | { |
180 | 180 | $created = true; |
181 | - $modelPath = $mod_path . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
182 | - if(file_exists($modelPath)) { |
|
181 | + $modelPath = $mod_path.$module.DIRECTORY_SEPARATOR.'Models'; |
|
182 | + if (file_exists($modelPath)) { |
|
183 | 183 | $dir = dir($modelPath); |
184 | - while($file = $dir->read()) { |
|
185 | - if(!in_array($file, array('.', '..')) && !preg_match('/Query\.php$/i', $file) && preg_match('/\.php$/i', $file)) { |
|
184 | + while ($file = $dir->read()) { |
|
185 | + if (!in_array($file, array('.', '..')) && !preg_match('/Query\.php$/i', $file) && preg_match('/\.php$/i', $file)) { |
|
186 | 186 | $filename = str_replace(".php", "", $file); |
187 | 187 | $this->log->infoLog("Generamos Api BASES para {$filename}"); |
188 | 188 | $this->createApiBaseFile($module, $mod_path, $filename); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | { |
204 | 204 | //Generamos el fichero de configuración |
205 | 205 | $this->log->infoLog("Generamos fichero vacío de configuración"); |
206 | - return $this->writeTemplateToFile("<?php\n\t", $mod_path . $module . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", $force); |
|
206 | + return $this->writeTemplateToFile("<?php\n\t", $mod_path.$module.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", $force); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | { |
217 | 217 | //Generamos el fichero de configuración |
218 | 218 | $this->log->infoLog("Generamos ficheros para assets base"); |
219 | - $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", $mod_path . $module . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", false); |
|
220 | - $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", $mod_path . $module . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", false); |
|
219 | + $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", $mod_path.$module.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", false); |
|
220 | + $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", $mod_path.$module.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", false); |
|
221 | 221 | return ($css && $js); |
222 | 222 | } |
223 | 223 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $controller = $this->tpl->dump("generator/service.template.twig", array( |
235 | 235 | "module" => $module, |
236 | 236 | )); |
237 | - return $this->writeTemplateToFile($controller, $mod_path . $module . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$module}Service.php", $force); |
|
237 | + return $this->writeTemplateToFile($controller, $mod_path.$module.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$module}Service.php", $force); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $autoloader = $this->tpl->dump("generator/autoloader.template.twig", array( |
251 | 251 | "module" => $module, |
252 | 252 | )); |
253 | - return $this->writeTemplateToFile($autoloader, $mod_path . $module . DIRECTORY_SEPARATOR . "autoload.php", $force); |
|
253 | + return $this->writeTemplateToFile($autoloader, $mod_path.$module.DIRECTORY_SEPARATOR."autoload.php", $force); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | "module" => $module, |
268 | 268 | "db" => $this->config->get("db_name"), |
269 | 269 | )); |
270 | - return $this->writeTemplateToFile($schema, $mod_path . $module . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", $force); |
|
270 | + return $this->writeTemplateToFile($schema, $mod_path.$module.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", $force); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | "pass" => $this->config->get("db_password"), |
288 | 288 | "db" => $this->config->get("db_name"), |
289 | 289 | )); |
290 | - return $this->writeTemplateToFile($build_properties, $mod_path . $module . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml", $force); |
|
290 | + return $this->writeTemplateToFile($build_properties, $mod_path.$module.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml", $force); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $index = $this->tpl->dump("generator/index.template.twig", array( |
304 | 304 | "module" => $module, |
305 | 305 | )); |
306 | - return $this->writeTemplateToFile($index, $mod_path . $module . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", $force); |
|
306 | + return $this->writeTemplateToFile($index, $mod_path.$module.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", $force); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | $created = false; |
318 | 318 | if ($force || !file_exists($filename)) { |
319 | 319 | try { |
320 | - $this->cache->storeData($filename, $fileContent, Cache::TEXT,true); |
|
320 | + $this->cache->storeData($filename, $fileContent, Cache::TEXT, true); |
|
321 | 321 | $created = true; |
322 | - } catch(\Exception $e) { |
|
322 | + }catch (\Exception $e) { |
|
323 | 323 | $this->log->errorLog($e->getMessage()); |
324 | 324 | } |
325 | - } else{ |
|
326 | - $this->log->errorLog($filename . _(' not exists or cant write')); |
|
325 | + }else { |
|
326 | + $this->log->errorLog($filename._(' not exists or cant write')); |
|
327 | 327 | } |
328 | 328 | return $created; |
329 | 329 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | "api" => $api |
344 | 344 | )); |
345 | 345 | |
346 | - return $this->writeTemplateToFile($controller, $mod_path . $module . DIRECTORY_SEPARATOR . "Api" . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
346 | + return $this->writeTemplateToFile($controller, $mod_path.$module.DIRECTORY_SEPARATOR."Api".DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -362,6 +362,6 @@ discard block |
||
362 | 362 | "api" => $api |
363 | 363 | )); |
364 | 364 | |
365 | - return $this->writeTemplateToFile($controller, $mod_path . $module . DIRECTORY_SEPARATOR . "Api" . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
365 | + return $this->writeTemplateToFile($controller, $mod_path.$module.DIRECTORY_SEPARATOR."Api".DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
366 | 366 | } |
367 | 367 | } |