@@ -33,10 +33,10 @@ |
||
33 | 33 | */ |
34 | 34 | private static function __init($instance) { |
35 | 35 | $loaded = false; |
36 | - if(method_exists($instance, 'isLoaded')) { |
|
36 | + if (method_exists($instance, 'isLoaded')) { |
|
37 | 37 | $loaded = $instance->isLoaded(); |
38 | 38 | } |
39 | - if(false === $loaded && method_exists($instance, "init")) { |
|
39 | + if (false === $loaded && method_exists($instance, "init")) { |
|
40 | 40 | $instance->init(); |
41 | 41 | } |
42 | 42 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | $translations = array(); |
22 | 22 | if (file_exists($absoluteTranslationFileName)) { |
23 | 23 | @include($absoluteTranslationFileName); |
24 | - } else { |
|
24 | + }else { |
|
25 | 25 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
26 | 26 | } |
27 | 27 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | unset($_SERVER["PHP_AUTH_USER"]); |
39 | 39 | unset($_SERVER["PHP_AUTH_PW"]); |
40 | 40 | header_remove("Authorization"); |
41 | - } else { |
|
41 | + }else { |
|
42 | 42 | header('Authorization:'); |
43 | 43 | } |
44 | 44 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | Logger::log('Adding debug headers to render response'); |
67 | 67 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
68 | 68 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
69 | - header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
70 | - header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
71 | - header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
69 | + header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
70 | + header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
71 | + header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return $vars; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | { |
217 | 217 | if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
218 | 218 | ob_start(); |
219 | - header('Location: ' . $url); |
|
219 | + header('Location: '.$url); |
|
220 | 220 | ob_end_clean(); |
221 | 221 | Security::getInstance()->updateSession(); |
222 | 222 | exit(_("Redireccionando...")); |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | $host = $this->getServerName(); |
262 | 262 | $protocol = $protocol ? $this->getProtocol() : ''; |
263 | 263 | $url = ''; |
264 | - if (!empty($host) && !empty($protocol)) $url = $protocol . $host; |
|
265 | - if(!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
|
266 | - $url .= ':' . $this->getServer('SERVER_PORT'); |
|
264 | + if (!empty($host) && !empty($protocol)) $url = $protocol.$host; |
|
265 | + if (!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
|
266 | + $url .= ':'.$this->getServer('SERVER_PORT'); |
|
267 | 267 | } |
268 | 268 | return $url; |
269 | 269 | } |
@@ -8,9 +8,10 @@ discard block |
||
8 | 8 | function getallheaders() |
9 | 9 | { |
10 | 10 | $headers = array(); |
11 | - foreach ($_SERVER as $h => $v) |
|
12 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
11 | + foreach ($_SERVER as $h => $v) { |
|
12 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
13 | 13 | $headers[$hp[1]] = $v; |
14 | + } |
|
14 | 15 | return $headers; |
15 | 16 | } |
16 | 17 | } |
@@ -214,7 +215,9 @@ discard block |
||
214 | 215 | */ |
215 | 216 | public function redirect($url = null) |
216 | 217 | { |
217 | - if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
|
218 | + if (null === $url) { |
|
219 | + $url = $this->getServer('HTTP_ORIGIN'); |
|
220 | + } |
|
218 | 221 | ob_start(); |
219 | 222 | header('Location: ' . $url); |
220 | 223 | ob_end_clean(); |
@@ -261,7 +264,9 @@ discard block |
||
261 | 264 | $host = $this->getServerName(); |
262 | 265 | $protocol = $protocol ? $this->getProtocol() : ''; |
263 | 266 | $url = ''; |
264 | - if (!empty($host) && !empty($protocol)) $url = $protocol . $host; |
|
267 | + if (!empty($host) && !empty($protocol)) { |
|
268 | + $url = $protocol . $host; |
|
269 | + } |
|
265 | 270 | if(!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
266 | 271 | $url .= ':' . $this->getServer('SERVER_PORT'); |
267 | 272 | } |
@@ -121,6 +121,9 @@ discard block |
||
121 | 121 | return self::getInstance()->getHeader($name); |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @return string |
|
126 | + */ |
|
124 | 127 | public function getHeader($name) |
125 | 128 | { |
126 | 129 | $header = null; |
@@ -171,7 +174,7 @@ discard block |
||
171 | 174 | * |
172 | 175 | * @param string $queryParams |
173 | 176 | * |
174 | - * @return mixed |
|
177 | + * @return string |
|
175 | 178 | */ |
176 | 179 | public function getQuery($queryParams) |
177 | 180 | { |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | public function render($template, array $vars = array(), $cookies = array(), $domain = null) |
36 | 36 | { |
37 | 37 | $vars['__menu__'] = $this->getMenu(); |
38 | - $domain = (null ===$domain) ? $this->getDomain() : $domain; |
|
39 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
38 | + $domain = (null === $domain) ? $this->getDomain() : $domain; |
|
39 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $vars['__menu__'] = $this->getMenu(); |
69 | 69 | $domain = $domain ?: $this->getDomain(); |
70 | - return $this->tpl->dump($domain . $template, $vars); |
|
70 | + return $this->tpl->dump($domain.$template, $vars); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | ///////////////////////////////////////////////////////////// |
97 | 97 | // Date in the past sets the value to already have been expired. |
98 | 98 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
99 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
99 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
100 | 100 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
101 | 101 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
102 | 102 | header("Pragma: no-cache"); |
103 | 103 | header("Expires: 0"); |
104 | 104 | header('Content-Transfer-Encoding: none'); |
105 | - header("Content-type: " . $content); |
|
106 | - header("Content-length: " . strlen($data)); |
|
107 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
105 | + header("Content-type: ".$content); |
|
106 | + header("Content-length: ".strlen($data)); |
|
107 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
108 | 108 | echo $data; |
109 | 109 | ob_flush(); |
110 | 110 | ob_end_clean(); |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace PSFS\base\types; |
4 | 4 | |
5 | -use PSFS\base\config\Config; |
|
6 | 5 | use PSFS\base\exception\RouterException; |
7 | 6 | use PSFS\base\Request; |
8 | 7 | use PSFS\base\Router; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Método que revisa las traducciones directorio a directorio |
29 | - * @param $path |
|
29 | + * @param string $path |
|
30 | 30 | * @param $locale |
31 | 31 | * @return array |
32 | 32 | */ |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string $module |
103 | 103 | * @param boolean $mod_path |
104 | 104 | * @param boolean $isModule |
105 | - * @return boolean |
|
105 | + * @return boolean|null |
|
106 | 106 | */ |
107 | 107 | private function createModulePathTree($module, $mod_path, $isModule = false) |
108 | 108 | { |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | * Method that copy resources recursively |
475 | 475 | * @param string $dest |
476 | 476 | * @param boolean $force |
477 | - * @param $filename_path |
|
477 | + * @param string $filename_path |
|
478 | 478 | * @param boolean $debug |
479 | 479 | */ |
480 | 480 | public static function copyResources($dest, $force, $filename_path, $debug) |
@@ -32,24 +32,24 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function findTranslations($path, $locale) |
34 | 34 | { |
35 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
36 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
35 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
36 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
37 | 37 | |
38 | 38 | $translations = array(); |
39 | 39 | if (file_exists($path)) { |
40 | 40 | $d = dir($path); |
41 | 41 | while (false !== ($dir = $d->read())) { |
42 | 42 | GeneratorHelper::createDir($locale_path); |
43 | - if (!file_exists($locale_path . 'translations.po')) { |
|
44 | - file_put_contents($locale_path . 'translations.po', ''); |
|
43 | + if (!file_exists($locale_path.'translations.po')) { |
|
44 | + file_put_contents($locale_path.'translations.po', ''); |
|
45 | 45 | } |
46 | - $inspect_path = realpath($path . DIRECTORY_SEPARATOR . $dir); |
|
47 | - $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext " . |
|
48 | - $inspect_path . DIRECTORY_SEPARATOR . |
|
46 | + $inspect_path = realpath($path.DIRECTORY_SEPARATOR.$dir); |
|
47 | + $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ". |
|
48 | + $inspect_path.DIRECTORY_SEPARATOR. |
|
49 | 49 | "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$locale_path}translations.po"; |
50 | - if (is_dir($path . DIRECTORY_SEPARATOR . $dir) && preg_match('/^\./', $dir) == 0) { |
|
51 | - $res = _('Revisando directorio: ') . $inspect_path; |
|
52 | - $res .= _('Comando ejecutado: ') . $cmd_php; |
|
50 | + if (is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./', $dir) == 0) { |
|
51 | + $res = _('Revisando directorio: ').$inspect_path; |
|
52 | + $res .= _('Comando ejecutado: ').$cmd_php; |
|
53 | 53 | $res .= shell_exec($cmd_php); |
54 | 54 | usleep(10); |
55 | 55 | $translations[] = $res; |
@@ -70,7 +70,7 @@ discard block |
||
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); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | GeneratorHelper::createDir($mod_path); |
94 | 94 | // Create module path |
95 | 95 | if (false === $isModule) { |
96 | - GeneratorHelper::createDir($mod_path . $module); |
|
96 | + GeneratorHelper::createDir($mod_path.$module); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -111,20 +111,20 @@ discard block |
||
111 | 111 | $paths = [ |
112 | 112 | "Api", "Api/base", "Config", "Controller", "Form", "Models", "Public", "Templates", "Services", "Test" |
113 | 113 | ]; |
114 | - $module_path = $isModule ? $mod_path : $mod_path . $module; |
|
114 | + $module_path = $isModule ? $mod_path : $mod_path.$module; |
|
115 | 115 | foreach ($paths as $path) { |
116 | - GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . $path); |
|
116 | + GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR.$path); |
|
117 | 117 | } |
118 | 118 | //Creamos las carpetas de los assets |
119 | 119 | $htmlPaths = array("css", "js", "img", "media", "font"); |
120 | 120 | foreach ($htmlPaths as $path) { |
121 | - GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path); |
|
121 | + GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | if ($isModule) { |
125 | 125 | return $this->writeTemplateToFile(json_encode([ |
126 | - "module" => "\\" . preg_replace('/(\\\|\/)/', '\\\\', $module), |
|
127 | - ], JSON_PRETTY_PRINT), $mod_path . DIRECTORY_SEPARATOR . "module.json", true); |
|
126 | + "module" => "\\".preg_replace('/(\\\|\/)/', '\\\\', $module), |
|
127 | + ], JSON_PRETTY_PRINT), $mod_path.DIRECTORY_SEPARATOR."module.json", true); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | private function createModuleBaseFiles($module, $mod_path, $force = false, $controllerType = '', $isModule = false) |
140 | 140 | { |
141 | - $module_path = $isModule ? $mod_path : $mod_path . $module; |
|
141 | + $module_path = $isModule ? $mod_path : $mod_path.$module; |
|
142 | 142 | $this->generateControllerTemplate($module, $module_path, $force, $controllerType); |
143 | 143 | $this->generateServiceTemplate($module, $module_path, $force); |
144 | 144 | $this->genereateAutoloaderTemplate($module, $module_path, $force, $isModule); |
@@ -157,24 +157,24 @@ discard block |
||
157 | 157 | */ |
158 | 158 | private function createModuleModels($module, $path, $isModule = false) |
159 | 159 | { |
160 | - $module_path = $isModule ? $path : $path . $module; |
|
161 | - $module_path = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $module_path); |
|
160 | + $module_path = $isModule ? $path : $path.$module; |
|
161 | + $module_path = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $module_path); |
|
162 | 162 | //Generamos las clases de propel y la configuración |
163 | - $exec = "export PATH=\$PATH:/opt/local/bin; " . BASE_DIR . DIRECTORY_SEPARATOR . |
|
164 | - "vendor" . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "propel "; |
|
165 | - $schemaOpt = " --schema-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . |
|
166 | - DIRECTORY_SEPARATOR . "Config"; |
|
167 | - $opt = " --config-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . |
|
168 | - "Config --output-dir=" . CORE_DIR . " --verbose"; |
|
169 | - $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n" . $exec . "build" . $opt . $schemaOpt); |
|
170 | - $ret = shell_exec($exec . "build" . $opt . $schemaOpt); |
|
163 | + $exec = "export PATH=\$PATH:/opt/local/bin; ".BASE_DIR.DIRECTORY_SEPARATOR. |
|
164 | + "vendor".DIRECTORY_SEPARATOR."bin".DIRECTORY_SEPARATOR."propel "; |
|
165 | + $schemaOpt = " --schema-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path. |
|
166 | + DIRECTORY_SEPARATOR."Config"; |
|
167 | + $opt = " --config-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR. |
|
168 | + "Config --output-dir=".CORE_DIR." --verbose"; |
|
169 | + $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n".$exec."build".$opt.$schemaOpt); |
|
170 | + $ret = shell_exec($exec."build".$opt.$schemaOpt); |
|
171 | 171 | |
172 | 172 | $this->log->infoLog("[GENERATOR] Generamos clases invocando a propel:\n $ret"); |
173 | - $ret = shell_exec($exec . "sql:build" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . |
|
174 | - $module_path . DIRECTORY_SEPARATOR . "Config" . $schemaOpt); |
|
173 | + $ret = shell_exec($exec."sql:build".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR. |
|
174 | + $module_path.DIRECTORY_SEPARATOR."Config".$schemaOpt); |
|
175 | 175 | $this->log->infoLog("[GENERATOR] Generamos sql invocando a propel:\n $ret"); |
176 | - $ret = shell_exec($exec . "config:convert" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . |
|
177 | - $module_path . DIRECTORY_SEPARATOR . "Config"); |
|
176 | + $ret = shell_exec($exec."config:convert".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR. |
|
177 | + $module_path.DIRECTORY_SEPARATOR."Config"); |
|
178 | 178 | $this->log->infoLog("[GENERATOR] Generamos configuración invocando a propel:\n $ret"); |
179 | 179 | } |
180 | 180 | |
@@ -195,32 +195,32 @@ discard block |
||
195 | 195 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
196 | 196 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
197 | 197 | "class" => $class, |
198 | - "controllerType" => $class . "Base", |
|
198 | + "controllerType" => $class."Base", |
|
199 | 199 | "is_base" => false |
200 | 200 | )); |
201 | - $controller = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" . |
|
202 | - DIRECTORY_SEPARATOR . "{$class}Controller.php", $force); |
|
201 | + $controller = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller". |
|
202 | + DIRECTORY_SEPARATOR."{$class}Controller.php", $force); |
|
203 | 203 | |
204 | 204 | $controllerBody = $this->tpl->dump("generator/controller.template.twig", array( |
205 | 205 | "module" => $module, |
206 | 206 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
207 | 207 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
208 | - "class" => $class . "Base", |
|
208 | + "class" => $class."Base", |
|
209 | 209 | "service" => $class, |
210 | 210 | "controllerType" => $controllerType, |
211 | 211 | "is_base" => true, |
212 | 212 | "domain" => $class, |
213 | 213 | )); |
214 | - $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" . |
|
215 | - DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true); |
|
214 | + $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller". |
|
215 | + DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true); |
|
216 | 216 | |
217 | 217 | $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array( |
218 | 218 | "module" => $module, |
219 | 219 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
220 | 220 | "class" => $class, |
221 | 221 | )); |
222 | - $test = $this->writeTemplateToFile($testTemplate, $mod_path . DIRECTORY_SEPARATOR . "Test" . |
|
223 | - DIRECTORY_SEPARATOR . "{$class}Test.php", true); |
|
222 | + $test = $this->writeTemplateToFile($testTemplate, $mod_path.DIRECTORY_SEPARATOR."Test". |
|
223 | + DIRECTORY_SEPARATOR."{$class}Test.php", true); |
|
224 | 224 | return ($controller && $controllerBase && $test); |
225 | 225 | } |
226 | 226 | |
@@ -235,11 +235,9 @@ discard block |
||
235 | 235 | { |
236 | 236 | $created = true; |
237 | 237 | $modelPath = $isModule ? |
238 | - $mod_path . DIRECTORY_SEPARATOR . 'Models' : |
|
239 | - $mod_path . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
238 | + $mod_path.DIRECTORY_SEPARATOR.'Models' : $mod_path.$module.DIRECTORY_SEPARATOR.'Models'; |
|
240 | 239 | $api_path = $isModule ? |
241 | - $mod_path . DIRECTORY_SEPARATOR . 'Api' : |
|
242 | - $mod_path . $module . DIRECTORY_SEPARATOR . 'Api'; |
|
240 | + $mod_path.DIRECTORY_SEPARATOR.'Api' : $mod_path.$module.DIRECTORY_SEPARATOR.'Api'; |
|
243 | 241 | if (file_exists($modelPath)) { |
244 | 242 | $dir = dir($modelPath); |
245 | 243 | while ($file = $dir->read()) { |
@@ -267,7 +265,7 @@ discard block |
||
267 | 265 | //Generamos el fichero de configuración |
268 | 266 | $this->log->infoLog("Generamos fichero vacío de configuración"); |
269 | 267 | return $this->writeTemplateToFile("<?php\n\t", |
270 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", |
|
268 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", |
|
271 | 269 | $force); |
272 | 270 | } |
273 | 271 | |
@@ -282,10 +280,10 @@ discard block |
||
282 | 280 | //Generamos el fichero de configuración |
283 | 281 | $this->log->infoLog("Generamos ficheros para assets base"); |
284 | 282 | $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", |
285 | - $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", |
|
283 | + $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", |
|
286 | 284 | $force); |
287 | 285 | $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", |
288 | - $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", |
|
286 | + $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", |
|
289 | 287 | $force); |
290 | 288 | return ($css && $js); |
291 | 289 | } |
@@ -307,7 +305,7 @@ discard block |
||
307 | 305 | "class" => $class, |
308 | 306 | )); |
309 | 307 | return $this->writeTemplateToFile($controller, |
310 | - $mod_path . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php", |
|
308 | + $mod_path.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php", |
|
311 | 309 | $force); |
312 | 310 | } |
313 | 311 | |
@@ -328,14 +326,14 @@ discard block |
||
328 | 326 | "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module), |
329 | 327 | "is_module" => $isModule, |
330 | 328 | )); |
331 | - $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force); |
|
329 | + $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force); |
|
332 | 330 | |
333 | 331 | $this->log->infoLog("Generamos el phpunit"); |
334 | 332 | $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array( |
335 | 333 | "module" => $module, |
336 | 334 | "is_module" => $isModule, |
337 | 335 | )); |
338 | - $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force); |
|
336 | + $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force); |
|
339 | 337 | return $autoload && $phpunit; |
340 | 338 | } |
341 | 339 | |
@@ -356,7 +354,7 @@ discard block |
||
356 | 354 | "db" => $this->config->get("db_name"), |
357 | 355 | )); |
358 | 356 | return $this->writeTemplateToFile($schema, |
359 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", |
|
357 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", |
|
360 | 358 | $force); |
361 | 359 | } |
362 | 360 | |
@@ -379,7 +377,7 @@ discard block |
||
379 | 377 | "namespace" => preg_replace('/(\\\|\/)/', '', $module), |
380 | 378 | )); |
381 | 379 | return $this->writeTemplateToFile($build_properties, |
382 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml", |
|
380 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml", |
|
383 | 381 | $force); |
384 | 382 | } |
385 | 383 | |
@@ -397,7 +395,7 @@ discard block |
||
397 | 395 | "module" => $module, |
398 | 396 | )); |
399 | 397 | return $this->writeTemplateToFile($index, |
400 | - $mod_path . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", |
|
398 | + $mod_path.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", |
|
401 | 399 | $force); |
402 | 400 | } |
403 | 401 | |
@@ -415,11 +413,11 @@ discard block |
||
415 | 413 | try { |
416 | 414 | $this->cache->storeData($filename, $fileContent, Cache::TEXT, true); |
417 | 415 | $created = true; |
418 | - } catch (\Exception $e) { |
|
416 | + }catch (\Exception $e) { |
|
419 | 417 | $this->log->errorLog($e->getMessage()); |
420 | 418 | } |
421 | - } else { |
|
422 | - $this->log->errorLog($filename . _(' not exists or cant write')); |
|
419 | + }else { |
|
420 | + $this->log->errorLog($filename._(' not exists or cant write')); |
|
423 | 421 | } |
424 | 422 | return $created; |
425 | 423 | } |
@@ -444,7 +442,7 @@ discard block |
||
444 | 442 | )); |
445 | 443 | |
446 | 444 | return $this->writeTemplateToFile($controller, |
447 | - $mod_path . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
445 | + $mod_path.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
448 | 446 | } |
449 | 447 | |
450 | 448 | /** |
@@ -467,7 +465,7 @@ discard block |
||
467 | 465 | "class" => $class, |
468 | 466 | )); |
469 | 467 | |
470 | - return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
468 | + return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
471 | 469 | } |
472 | 470 | |
473 | 471 | /** |
@@ -481,12 +479,12 @@ discard block |
||
481 | 479 | { |
482 | 480 | if (file_exists($filename_path)) { |
483 | 481 | $destfolder = basename($filename_path); |
484 | - if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) { |
|
482 | + if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) { |
|
485 | 483 | if (is_dir($filename_path)) { |
486 | - self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
487 | - } else { |
|
488 | - if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) { |
|
489 | - throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
484 | + self::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
485 | + }else { |
|
486 | + if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) { |
|
487 | + throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
490 | 488 | } |
491 | 489 | } |
492 | 490 | } |
@@ -505,10 +503,10 @@ discard block |
||
505 | 503 | GeneratorHelper::createDir($dst); |
506 | 504 | while (false !== ($file = readdir($dir))) { |
507 | 505 | if (($file != '.') && ($file != '..')) { |
508 | - if (is_dir($src . '/' . $file)) { |
|
509 | - self::copyr($src . '/' . $file, $dst . '/' . $file); |
|
510 | - } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) { |
|
511 | - throw new ConfigException("Can't copy " . $src . " to " . $dst); |
|
506 | + if (is_dir($src.'/'.$file)) { |
|
507 | + self::copyr($src.'/'.$file, $dst.'/'.$file); |
|
508 | + } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) { |
|
509 | + throw new ConfigException("Can't copy ".$src." to ".$dst); |
|
512 | 510 | } |
513 | 511 | } |
514 | 512 | } |
@@ -8,7 +8,6 @@ |
||
8 | 8 | use PSFS\base\Logger; |
9 | 9 | use PSFS\base\Request; |
10 | 10 | use PSFS\base\types\SingletonTrait; |
11 | -use PSFS\controller\UserController; |
|
12 | 11 | |
13 | 12 | /** |
14 | 13 | * Class Config |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | /** |
183 | 183 | * Method that returns a config value |
184 | 184 | * @param string $param |
185 | - * @param mixed $defaultValue |
|
185 | + * @param boolean $defaultValue |
|
186 | 186 | * |
187 | 187 | * @return mixed|null |
188 | 188 | */ |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * Static wrapper for extracting params |
224 | 224 | * @param string $key |
225 | - * @param mixed|null $defaultValue |
|
225 | + * @param boolean|string $defaultValue |
|
226 | 226 | * @return mixed|null |
227 | 227 | */ |
228 | 228 | public static function getParam($key, $defaultValue = null) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | protected function init() |
74 | 74 | { |
75 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) { |
|
75 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) { |
|
76 | 76 | $this->loadConfigData(); |
77 | 77 | } |
78 | 78 | return $this; |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | $final_data = self::saveExtraParams($data); |
171 | 171 | $saved = false; |
172 | 172 | try { |
173 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, $final_data, Cache::JSON, true); |
|
173 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, $final_data, Cache::JSON, true); |
|
174 | 174 | Config::getInstance()->loadConfigData(); |
175 | 175 | $saved = true; |
176 | - } catch (ConfigException $e) { |
|
176 | + }catch (ConfigException $e) { |
|
177 | 177 | Logger::log($e->getMessage(), LOG_ERR); |
178 | 178 | } |
179 | 179 | return $saved; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function loadConfigData() |
207 | 207 | { |
208 | - $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, |
|
208 | + $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, |
|
209 | 209 | Cache::JSON, |
210 | 210 | TRUE) ?: []; |
211 | 211 | $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE; |
@@ -7,6 +7,14 @@ |
||
7 | 7 | * @package PSFS\base\types\interfaces |
8 | 8 | */ |
9 | 9 | interface ControllerInterface { |
10 | + |
|
11 | + /** |
|
12 | + * @return string|null |
|
13 | + */ |
|
10 | 14 | public function render($template, array $vars = [], $cookies = []); |
15 | + |
|
16 | + /** |
|
17 | + * @return void |
|
18 | + */ |
|
11 | 19 | public function response($response, $type = 'text/html'); |
12 | 20 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | if (!Config::getInstance()->checkTryToSaveConfig() |
23 | 23 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || NULL !== Config::getInstance()->get('restricted')) |
24 | 24 | ) { |
25 | - if(!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
25 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
26 | 26 | //Si no hay fichero de usuarios redirigimos directamente al gestor |
27 | 27 | return UserController::showAdminManager(); |
28 | 28 | } |