@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Método que revisa las traducciones directorio a directorio |
28 | - * @param $path |
|
28 | + * @param string $path |
|
29 | 29 | * @param $locale |
30 | 30 | * @return array |
31 | 31 | */ |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param string $module |
66 | 66 | * @param boolean $force |
67 | 67 | * @param string $type |
68 | - * @param boolean $is_module |
|
68 | + * @param boolean $isModule |
|
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | 71 | public function createStructureModule($module, $force = false, $type = "", $isModule = false) |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Servicio que genera la estructura base |
102 | - * @param $module |
|
103 | - * @param $mod_path |
|
102 | + * @param string $module |
|
103 | + * @param string $mod_path |
|
104 | 104 | * @param boolean $isModule |
105 | 105 | */ |
106 | 106 | private function createModulePathTree($module, $mod_path, $isModule = false) |
@@ -230,7 +230,6 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | - * @param string $module |
|
234 | 233 | * @param string $mod_path |
235 | 234 | * @param boolean $force |
236 | 235 | * @return boolean |
@@ -402,7 +401,7 @@ discard block |
||
402 | 401 | * Method that copy resources recursively |
403 | 402 | * @param string $dest |
404 | 403 | * @param boolean $force |
405 | - * @param $filename_path |
|
404 | + * @param string $filename_path |
|
406 | 405 | * @param boolean $debug |
407 | 406 | */ |
408 | 407 | public static function copyResources($dest, $force, $filename_path, $debug) |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use PSFS\base\exception\ConfigException; |
7 | 7 | use PSFS\base\Service; |
8 | 8 | |
9 | - class GeneratorService extends Service{ |
|
9 | + class GeneratorService extends Service { |
|
10 | 10 | /** |
11 | 11 | * @Inyectable |
12 | 12 | * @var \PSFS\base\config\Config Servicio de configuración |
@@ -31,25 +31,25 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public static function findTranslations($path, $locale) |
33 | 33 | { |
34 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
35 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
34 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
35 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
36 | 36 | |
37 | 37 | $translations = array(); |
38 | - if(file_exists($path)) |
|
38 | + if (file_exists($path)) |
|
39 | 39 | { |
40 | 40 | $d = dir($path); |
41 | - while(false !== ($dir = $d->read())) |
|
41 | + while (false !== ($dir = $d->read())) |
|
42 | 42 | { |
43 | 43 | Config::createDir($locale_path); |
44 | - if(!file_exists($locale_path . 'translations.po')) { |
|
45 | - file_put_contents($locale_path . 'translations.po', ''); |
|
44 | + if (!file_exists($locale_path.'translations.po')) { |
|
45 | + file_put_contents($locale_path.'translations.po', ''); |
|
46 | 46 | } |
47 | 47 | $inspect_path = realpath($path.DIRECTORY_SEPARATOR.$dir); |
48 | - $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"; |
|
49 | - if(is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./',$dir) == 0) |
|
48 | + $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"; |
|
49 | + if (is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./', $dir) == 0) |
|
50 | 50 | { |
51 | - $res = _('Revisando directorio: ') . $inspect_path; |
|
52 | - $res .= _('Comando ejecutado: '). $cmd_php; |
|
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 |
||
70 | 70 | */ |
71 | 71 | public function createStructureModule($module, $force = false, $type = "", $isModule = false) |
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, $isModule); |
76 | 76 | $this->createModulePathTree($module, $mod_path, $isModule); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | // Creates the src folder |
93 | 93 | Config::createDir($mod_path); |
94 | 94 | // Create module path |
95 | - if(false === $isModule) { |
|
96 | - Config::createDir($mod_path . $module); |
|
95 | + if (false === $isModule) { |
|
96 | + Config::createDir($mod_path.$module); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | //Creamos las carpetas CORE del módulo |
109 | 109 | $this->log->infoLog("Generamos la estructura"); |
110 | 110 | $paths = array("Api", "Api/base", "Config", "Controller", "Form", "Models", "Public", "Templates", "Services", "Test"); |
111 | - $module_path = $isModule ? $mod_path : $mod_path . $module; |
|
112 | - foreach($paths as $path) { |
|
113 | - Config::createDir($module_path . DIRECTORY_SEPARATOR . $path); |
|
111 | + $module_path = $isModule ? $mod_path : $mod_path.$module; |
|
112 | + foreach ($paths as $path) { |
|
113 | + Config::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 | - foreach($htmlPaths as $path) { |
|
118 | - Config::createDir($module_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path); |
|
117 | + foreach ($htmlPaths as $path) { |
|
118 | + Config::createDir($module_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path); |
|
119 | 119 | } |
120 | 120 | |
121 | - if($isModule) { |
|
121 | + if ($isModule) { |
|
122 | 122 | return $this->writeTemplateToFile(json_encode([ |
123 | - "module" => "\\" . preg_replace('/(\\\|\/)/', '\\\\',$module), |
|
124 | - ], JSON_PRETTY_PRINT), $mod_path . DIRECTORY_SEPARATOR . "module.json", true); |
|
123 | + "module" => "\\".preg_replace('/(\\\|\/)/', '\\\\', $module), |
|
124 | + ], JSON_PRETTY_PRINT), $mod_path.DIRECTORY_SEPARATOR."module.json", true); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | private function createModuleBaseFiles($module, $mod_path, $force = false, $controllerType = '', $isModule = false) |
137 | 137 | { |
138 | - $module_path = $isModule ? $mod_path : $mod_path . $module; |
|
138 | + $module_path = $isModule ? $mod_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, $isModule); |
@@ -154,19 +154,19 @@ discard block |
||
154 | 154 | */ |
155 | 155 | private function createModuleModels($module, $path, $isModule = false) |
156 | 156 | { |
157 | - $module_path = $isModule ? $path : $path . $module; |
|
158 | - $module_path = str_replace(BASE_DIR . DIRECTORY_SEPARATOR, '', $module_path); |
|
157 | + $module_path = $isModule ? $path : $path.$module; |
|
158 | + $module_path = str_replace(BASE_DIR.DIRECTORY_SEPARATOR, '', $module_path); |
|
159 | 159 | //Generamos las clases de propel y la configuración |
160 | - $exec = "export PATH=\$PATH:/opt/local/bin; " . BASE_DIR . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "propel "; |
|
161 | - $schemaOpt = " --schema-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config"; |
|
162 | - $opt = " --config-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config --output-dir=" . CORE_DIR . " --verbose"; |
|
163 | - $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n" . $exec . "build" . $opt . $schemaOpt); |
|
164 | - $ret = shell_exec($exec . "build" . $opt . $schemaOpt); |
|
160 | + $exec = "export PATH=\$PATH:/opt/local/bin; ".BASE_DIR.DIRECTORY_SEPARATOR."vendor".DIRECTORY_SEPARATOR."bin".DIRECTORY_SEPARATOR."propel "; |
|
161 | + $schemaOpt = " --schema-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config"; |
|
162 | + $opt = " --config-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config --output-dir=".CORE_DIR." --verbose"; |
|
163 | + $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n".$exec."build".$opt.$schemaOpt); |
|
164 | + $ret = shell_exec($exec."build".$opt.$schemaOpt); |
|
165 | 165 | |
166 | 166 | $this->log->infoLog("[GENERATOR] Generamos clases invocando a propel:\n $ret"); |
167 | - $ret = shell_exec($exec . "sql:build" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config" . $schemaOpt); |
|
167 | + $ret = shell_exec($exec."sql:build".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config".$schemaOpt); |
|
168 | 168 | $this->log->infoLog("[GENERATOR] Generamos sql invocando a propel:\n $ret"); |
169 | - $ret = shell_exec($exec . "config:convert" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config"); |
|
169 | + $ret = shell_exec($exec."config:convert".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config"); |
|
170 | 170 | $this->log->infoLog("[GENERATOR] Generamos configuración invocando a propel:\n $ret"); |
171 | 171 | } |
172 | 172 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | "class" => $class, |
190 | 190 | "controllerType" => $controllerType, |
191 | 191 | )); |
192 | - return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "Controller" . DIRECTORY_SEPARATOR . "{$class}Controller.php", $force); |
|
192 | + return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."Controller".DIRECTORY_SEPARATOR."{$class}Controller.php", $force); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | private function generateBaseApiTemplate($module, $mod_path, $force = false, $controllerType = "") |
203 | 203 | { |
204 | 204 | $created = true; |
205 | - $modelPath = $mod_path . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
206 | - if(file_exists($modelPath)) { |
|
205 | + $modelPath = $mod_path.$module.DIRECTORY_SEPARATOR.'Models'; |
|
206 | + if (file_exists($modelPath)) { |
|
207 | 207 | $dir = dir($modelPath); |
208 | - while($file = $dir->read()) { |
|
209 | - if(!in_array($file, array('.', '..')) && !preg_match('/Query\.php$/i', $file) && preg_match('/\.php$/i', $file)) { |
|
208 | + while ($file = $dir->read()) { |
|
209 | + if (!in_array($file, array('.', '..')) && !preg_match('/Query\.php$/i', $file) && preg_match('/\.php$/i', $file)) { |
|
210 | 210 | $filename = str_replace(".php", "", $file); |
211 | 211 | $this->log->infoLog("Generamos Api BASES para {$filename}"); |
212 | 212 | $this->createApiBaseFile($module, $mod_path, $filename); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | //Generamos el fichero de configuración |
228 | 228 | $this->log->infoLog("Generamos fichero vacío de configuración"); |
229 | - return $this->writeTemplateToFile("<?php\n\t", $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", $force); |
|
229 | + return $this->writeTemplateToFile("<?php\n\t", $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", $force); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | { |
240 | 240 | //Generamos el fichero de configuración |
241 | 241 | $this->log->infoLog("Generamos ficheros para assets base"); |
242 | - $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", $force); |
|
243 | - $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", $force); |
|
242 | + $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", $force); |
|
243 | + $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", $force); |
|
244 | 244 | return ($css && $js); |
245 | 245 | } |
246 | 246 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
261 | 261 | "class" => $class, |
262 | 262 | )); |
263 | - return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php", $force); |
|
263 | + return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php", $force); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module), |
281 | 281 | "is_module" => $isModule, |
282 | 282 | )); |
283 | - return $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force); |
|
283 | + return $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | "prefix" => preg_replace('/(\\\|\/)/', '', $module), |
300 | 300 | "db" => $this->config->get("db_name"), |
301 | 301 | )); |
302 | - return $this->writeTemplateToFile($schema, $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", $force); |
|
302 | + return $this->writeTemplateToFile($schema, $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", $force); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | "db" => $this->config->get("db_name"), |
321 | 321 | "namespace" => preg_replace('/(\\\|\/)/', '', $module), |
322 | 322 | )); |
323 | - return $this->writeTemplateToFile($build_properties, $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml", $force); |
|
323 | + return $this->writeTemplateToFile($build_properties, $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml", $force); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $index = $this->tpl->dump("generator/index.template.twig", array( |
337 | 337 | "module" => $module, |
338 | 338 | )); |
339 | - return $this->writeTemplateToFile($index, $mod_path . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", $force); |
|
339 | + return $this->writeTemplateToFile($index, $mod_path.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", $force); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | $created = false; |
351 | 351 | if ($force || !file_exists($filename)) { |
352 | 352 | try { |
353 | - $this->cache->storeData($filename, $fileContent, Cache::TEXT,true); |
|
353 | + $this->cache->storeData($filename, $fileContent, Cache::TEXT, true); |
|
354 | 354 | $created = true; |
355 | - } catch(\Exception $e) { |
|
355 | + }catch (\Exception $e) { |
|
356 | 356 | $this->log->errorLog($e->getMessage()); |
357 | 357 | } |
358 | - } else{ |
|
359 | - $this->log->errorLog($filename . _(' not exists or cant write')); |
|
358 | + }else { |
|
359 | + $this->log->errorLog($filename._(' not exists or cant write')); |
|
360 | 360 | } |
361 | 361 | return $created; |
362 | 362 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | "api" => $api |
377 | 377 | )); |
378 | 378 | |
379 | - return $this->writeTemplateToFile($controller, $mod_path . $module . DIRECTORY_SEPARATOR . "Api" . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
379 | + return $this->writeTemplateToFile($controller, $mod_path.$module.DIRECTORY_SEPARATOR."Api".DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | "api" => $api |
396 | 396 | )); |
397 | 397 | |
398 | - return $this->writeTemplateToFile($controller, $mod_path . $module . DIRECTORY_SEPARATOR . "Api" . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
398 | + return $this->writeTemplateToFile($controller, $mod_path.$module.DIRECTORY_SEPARATOR."Api".DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -30,7 +30,7 @@ discard block |
||
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,9 +61,9 @@ discard block |
||
61 | 61 | $this->gen->createStructureModule($module, $force, $type, (bool)$is_module); |
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) { |
|
64 | + }catch (\Exception $e) { |
|
65 | 65 | pre($e->getMessage(), true); |
66 | - Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]"); |
|
66 | + Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]"); |
|
67 | 67 | throw new ConfigException('Error al generar el módulo, prueba a cambiar los permisos', 403); |
68 | 68 | } |
69 | 69 | } |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function init() |
56 | 56 | { |
57 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) { |
|
57 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) { |
|
58 | 58 | $this->hydrateRouting(); |
59 | 59 | $this->simpatize(); |
60 | - } else { |
|
61 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE); |
|
62 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE); |
|
60 | + }else { |
|
61 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE); |
|
62 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | "success" => FALSE, |
80 | 80 | "error" => $e->getMessage(), |
81 | 81 | )), 'application/json'); |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | if (NULL === $e) { |
84 | 84 | Logger::log('Not found page throwed without previus exception'); |
85 | 85 | $e = new \Exception(_('Page not found'), 404); |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function getAllRoutes() { |
110 | 110 | $routes = []; |
111 | - foreach($this->routing as $path => $route) { |
|
112 | - if(array_key_exists('slug', $route)) { |
|
111 | + foreach ($this->routing as $path => $route) { |
|
112 | + if (array_key_exists('slug', $route)) { |
|
113 | 113 | $routes[$route['slug']] = $path; |
114 | 114 | } |
115 | 115 | } |
@@ -134,24 +134,24 @@ discard block |
||
134 | 134 | $this->checkRestrictedAccess($route); |
135 | 135 | //Search action and execute |
136 | 136 | $this->searchAction($route); |
137 | - } catch (AccessDeniedException $e) { |
|
137 | + }catch (AccessDeniedException $e) { |
|
138 | 138 | Logger::log(_('Solicitamos credenciales de acceso a zona restringida')); |
139 | 139 | if ('login' === Config::getInstance()->get('admin_login')) { |
140 | 140 | return $this->redirectLogin($route); |
141 | - } else { |
|
141 | + }else { |
|
142 | 142 | return $this->sentAuthHeader(); |
143 | 143 | } |
144 | - } catch (RouterException $r) { |
|
144 | + }catch (RouterException $r) { |
|
145 | 145 | if (FALSE !== preg_match('/\/$/', $route)) { |
146 | 146 | if (preg_match('/admin/', $route)) { |
147 | 147 | $default = Config::getInstance()->get('admin_action'); |
148 | - } else { |
|
148 | + }else { |
|
149 | 149 | $default = Config::getInstance()->get('home_action'); |
150 | 150 | } |
151 | 151 | |
152 | 152 | return $this->execute($this->getRoute($default)); |
153 | 153 | } |
154 | - } catch (\Exception $e) { |
|
154 | + }catch (\Exception $e) { |
|
155 | 155 | Logger::log($e->getMessage(), LOG_ERR); |
156 | 156 | throw $e; |
157 | 157 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $class = $this->getClassToCall($action); |
229 | 229 | try { |
230 | 230 | $this->executeCachedRoute($route, $action, $class, $get); |
231 | - } catch (\Exception $e) { |
|
231 | + }catch (\Exception $e) { |
|
232 | 232 | Logger::log($e->getMessage(), LOG_ERR); |
233 | 233 | throw new RouterException($e->getMessage(), 404, $e); |
234 | 234 | } |
@@ -317,19 +317,19 @@ discard block |
||
317 | 317 | $this->routing = $this->inspectDir($base, "PSFS", array()); |
318 | 318 | if (file_exists($modules)) { |
319 | 319 | $module = ""; |
320 | - if(file_exists($modules . DIRECTORY_SEPARATOR . 'module.json')) { |
|
321 | - $mod_cfg = json_decode(file_get_contents($modules . DIRECTORY_SEPARATOR . 'module.json'), true); |
|
320 | + if (file_exists($modules.DIRECTORY_SEPARATOR.'module.json')) { |
|
321 | + $mod_cfg = json_decode(file_get_contents($modules.DIRECTORY_SEPARATOR.'module.json'), true); |
|
322 | 322 | $module = $mod_cfg['module']; |
323 | 323 | } |
324 | 324 | $this->routing = $this->inspectDir($modules, $module, $this->routing); |
325 | 325 | } |
326 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
326 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
327 | 327 | $home = Config::getInstance()->get('home_action'); |
328 | 328 | if (NULL !== $home || $home !== '') { |
329 | 329 | $home_params = NULL; |
330 | 330 | foreach ($this->routing as $pattern => $params) { |
331 | 331 | list($method, $route) = $this->extractHttpRoute($pattern); |
332 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
332 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
333 | 333 | $home_params = $params; |
334 | 334 | } |
335 | 335 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php"); |
355 | 355 | foreach ($files as $file) { |
356 | 356 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
357 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing); |
|
357 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing); |
|
358 | 358 | } |
359 | 359 | $this->finder = new Finder(); |
360 | 360 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $httpMethod = $this->extractReflectionHttpMethod($docComments); |
405 | 405 | $visible = $this->extractReflectionVisibility($docComments); |
406 | 406 | $expiration = $this->extractReflectionCacheability($docComments); |
407 | - $routing[$httpMethod . "#|#" . $regex] = array( |
|
407 | + $routing[$httpMethod."#|#".$regex] = array( |
|
408 | 408 | "class" => $namespace, |
409 | 409 | "method" => $method->getName(), |
410 | 410 | "params" => $params, |
@@ -434,9 +434,9 @@ discard block |
||
434 | 434 | { |
435 | 435 | //Calculamos los dominios para las plantillas |
436 | 436 | if ($class->hasConstant("DOMAIN")) { |
437 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
438 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
439 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
437 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
438 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
439 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
440 | 440 | $tpl_path = "templates"; |
441 | 441 | $public_path = "public"; |
442 | 442 | $model_path = "models"; |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | $model_path = ucfirst($model_path); |
447 | 447 | } |
448 | 448 | if ($class->hasConstant("TPL")) { |
449 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
449 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
450 | 450 | } |
451 | 451 | $this->domains[$domain] = array( |
452 | - "template" => $path . $tpl_path, |
|
453 | - "model" => $path . $model_path, |
|
454 | - "public" => $path . $public_path, |
|
452 | + "template" => $path.$tpl_path, |
|
453 | + "model" => $path.$model_path, |
|
454 | + "public" => $path.$public_path, |
|
455 | 455 | ); |
456 | 456 | } |
457 | 457 | |
@@ -464,11 +464,11 @@ discard block |
||
464 | 464 | */ |
465 | 465 | public function simpatize() |
466 | 466 | { |
467 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
468 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
467 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
468 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
469 | 469 | $this->generateSlugs($absoluteTranslationFileName); |
470 | 470 | Config::createDir(CONFIG_DIR); |
471 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
471 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
472 | 472 | |
473 | 473 | return $this; |
474 | 474 | } |
@@ -519,16 +519,16 @@ discard block |
||
519 | 519 | public function getRoute($slug = '', $absolute = FALSE, $params = NULL) |
520 | 520 | { |
521 | 521 | if (strlen($slug) === 0) { |
522 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
522 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
523 | 523 | } |
524 | 524 | if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { |
525 | 525 | throw new RouterException(_("No existe la ruta especificada")); |
526 | 526 | } |
527 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
527 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
528 | 528 | if (!empty($params)) foreach ($params as $key => $value) { |
529 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
529 | + $url = str_replace("{".$key."}", $value, $url); |
|
530 | 530 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
531 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
531 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | if (preg_match('/^\/admin(\/|$)/', $routePattern)) { |
547 | 547 | if (preg_match('/^\\\?PSFS/', $params["class"])) { |
548 | 548 | $profile = "superadmin"; |
549 | - } else { |
|
549 | + }else { |
|
550 | 550 | $profile = "admin"; |
551 | 551 | } |
552 | 552 | if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) { |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | protected function getClassToCall($action) |
599 | 599 | { |
600 | 600 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
601 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
601 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
602 | 602 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
603 | 603 | return $class; |
604 | 604 | } |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | $expr = preg_quote($expr, '/'); |
618 | 618 | $expr = str_replace('###', '(.*)', $expr); |
619 | 619 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
620 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
620 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
621 | 621 | return $matched; |
622 | 622 | } |
623 | 623 | |
@@ -654,9 +654,9 @@ discard block |
||
654 | 654 | if (count($parameters) > 0) foreach ($parameters as $param) { |
655 | 655 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
656 | 656 | $params[$param->getName()] = $param->getDefaultValue(); |
657 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
657 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
658 | 658 | } |
659 | - } else $default = $regex; |
|
659 | + }else $default = $regex; |
|
660 | 660 | |
661 | 661 | return array($regex, $default, $params); |
662 | 662 | } |
@@ -712,16 +712,16 @@ discard block |
||
712 | 712 | */ |
713 | 713 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
714 | 714 | { |
715 | - Logger::log('Executing route ' . $route); |
|
715 | + Logger::log('Executing route '.$route); |
|
716 | 716 | Security::getInstance()->setSessionKey("__CACHE__", $action); |
717 | 717 | $cache = Cache::needCache(); |
718 | 718 | $execute = TRUE; |
719 | 719 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
720 | 720 | $cacheDataName = $this->cache->getRequestCacheHash(); |
721 | - $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, $cache, function () { |
|
721 | + $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, $cache, function() { |
|
722 | 722 | }); |
723 | 723 | if (NULL !== $cachedData) { |
724 | - $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", $cache, function () { |
|
724 | + $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", $cache, function() { |
|
725 | 725 | }, Cache::JSON); |
726 | 726 | Template::getInstance()->renderCache($cachedData, $headers); |
727 | 727 | $execute = FALSE; |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | $translations = array(); |
769 | 769 | if (file_exists($absoluteTranslationFileName)) { |
770 | 770 | include($absoluteTranslationFileName); |
771 | - } else { |
|
771 | + }else { |
|
772 | 772 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
773 | 773 | } |
774 | 774 |