@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function init() |
62 | 62 | { |
63 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) { |
|
63 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) { |
|
64 | 64 | $this->hydrateRouting(); |
65 | 65 | $this->simpatize(); |
66 | - } else { |
|
67 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE); |
|
68 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE); |
|
66 | + }else { |
|
67 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE); |
|
68 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | "success" => FALSE, |
90 | 90 | "error" => $e->getMessage(), |
91 | 91 | )), 'application/json'); |
92 | - } else { |
|
92 | + }else { |
|
93 | 93 | return $template->render('error.html.twig', array( |
94 | 94 | 'exception' => $e, |
95 | 95 | 'trace' => $e->getTraceAsString(), |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | SecurityHelper::checkRestrictedAccess($route); |
141 | 141 | //Search action and execute |
142 | 142 | $this->searchAction($route); |
143 | - } catch (AccessDeniedException $e) { |
|
143 | + }catch (AccessDeniedException $e) { |
|
144 | 144 | Logger::log(_('Solicitamos credenciales de acceso a zona restringida')); |
145 | 145 | return Admin::staticAdminLogon($route); |
146 | - } catch (RouterException $r) { |
|
146 | + }catch (RouterException $r) { |
|
147 | 147 | Logger::log($r->getMessage(), LOG_WARNING); |
148 | - } catch (\Exception $e) { |
|
148 | + }catch (\Exception $e) { |
|
149 | 149 | Logger::log($e->getMessage(), LOG_ERR); |
150 | 150 | throw $e; |
151 | 151 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function searchAction($route) |
164 | 164 | { |
165 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
165 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
166 | 166 | //Revisamos si tenemos la ruta registrada |
167 | 167 | $parts = parse_url($route); |
168 | 168 | $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $class = RouterHelper::getClassToCall($action); |
177 | 177 | try { |
178 | 178 | $this->executeCachedRoute($route, $action, $class, $get); |
179 | - } catch (\Exception $e) { |
|
179 | + }catch (\Exception $e) { |
|
180 | 180 | Logger::log($e->getMessage(), LOG_ERR); |
181 | 181 | throw new RouterException($e->getMessage(), 404, $e); |
182 | 182 | } |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | $externalModules = explode(',', $externalModules); |
202 | 202 | foreach ($externalModules as &$module) { |
203 | 203 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
204 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
204 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
205 | 205 | if (file_exists($externalModulePath)) { |
206 | 206 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
207 | 207 | if (!empty($externalModule)) { |
208 | 208 | foreach ($externalModule as $modulePath) { |
209 | 209 | $extModule = $modulePath->getBasename(); |
210 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
210 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
211 | 211 | if (file_exists($moduleAutoloader)) { |
212 | 212 | @include $moduleAutoloader; |
213 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, $extModule, $this->routing); |
|
213 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, $extModule, $this->routing); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | } |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
232 | 232 | foreach ($modules as $modulePath) { |
233 | 233 | $module = $modulePath->getBasename(); |
234 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
234 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | $this->checkExternalModules(); |
238 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
238 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $home_params = NULL; |
251 | 251 | foreach ($this->routing as $pattern => $params) { |
252 | 252 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
253 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
253 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
254 | 254 | $home_params = $params; |
255 | 255 | } |
256 | 256 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php"); |
276 | 276 | foreach ($files as $file) { |
277 | 277 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
278 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
278 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
279 | 279 | } |
280 | 280 | $this->finder = new Finder(); |
281 | 281 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | if (!$this->domains) { |
345 | 345 | $this->domains = []; |
346 | 346 | } |
347 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
347 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
348 | 348 | if (!array_key_exists($domain, $this->domains)) { |
349 | 349 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
350 | 350 | } |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | */ |
360 | 360 | public function simpatize() |
361 | 361 | { |
362 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
363 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
362 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
363 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
364 | 364 | $this->generateSlugs($absoluteTranslationFileName); |
365 | 365 | GeneratorHelper::createDir(CONFIG_DIR); |
366 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
366 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
367 | 367 | |
368 | 368 | return $this; |
369 | 369 | } |
@@ -381,16 +381,16 @@ discard block |
||
381 | 381 | public function getRoute($slug = '', $absolute = FALSE, $params = []) |
382 | 382 | { |
383 | 383 | if (strlen($slug) === 0) { |
384 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
384 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
385 | 385 | } |
386 | 386 | if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { |
387 | 387 | throw new RouterException(_("No existe la ruta especificada")); |
388 | 388 | } |
389 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
389 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
390 | 390 | if (!empty($params)) foreach ($params as $key => $value) { |
391 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
391 | + $url = str_replace("{".$key."}", $value, $url); |
|
392 | 392 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
393 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
393 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -451,19 +451,19 @@ discard block |
||
451 | 451 | */ |
452 | 452 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
453 | 453 | { |
454 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
454 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
455 | 455 | Security::getInstance()->setSessionKey("__CACHE__", $action); |
456 | 456 | $cache = Cache::needCache(); |
457 | 457 | $execute = TRUE; |
458 | 458 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
459 | 459 | $cacheDataName = $this->cache->getRequestCacheHash(); |
460 | - $tmpDir = substr($cacheDataName, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheDataName, 2, 2) . DIRECTORY_SEPARATOR; |
|
461 | - $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName, |
|
462 | - $cache, function () { |
|
460 | + $tmpDir = substr($cacheDataName, 0, 2).DIRECTORY_SEPARATOR.substr($cacheDataName, 2, 2).DIRECTORY_SEPARATOR; |
|
461 | + $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName, |
|
462 | + $cache, function() { |
|
463 | 463 | }); |
464 | 464 | if (NULL !== $cachedData) { |
465 | - $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName . ".headers", |
|
466 | - $cache, function () { |
|
465 | + $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName.".headers", |
|
466 | + $cache, function() { |
|
467 | 467 | }, Cache::JSON); |
468 | 468 | Template::getInstance()->renderCache($cachedData, $headers); |
469 | 469 | $execute = FALSE; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - Logger::log(get_class($this) . ' constructor invoked'); |
|
23 | + Logger::log(get_class($this).' constructor invoked'); |
|
24 | 24 | $this->init(); |
25 | 25 | } |
26 | 26 | |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | $calledClass = get_called_class(); |
91 | 91 | try { |
92 | 92 | $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
93 | - $setter = "set" . ucfirst($variable); |
|
93 | + $setter = "set".ucfirst($variable); |
|
94 | 94 | if (method_exists($calledClass, $setter)) { |
95 | 95 | $this->$setter($instance); |
96 | - } else { |
|
96 | + }else { |
|
97 | 97 | $this->$variable = $instance; |
98 | 98 | } |
99 | - } catch (\Exception $e) { |
|
100 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
99 | + }catch (\Exception $e) { |
|
100 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
101 | 101 | } |
102 | 102 | return $this; |
103 | 103 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | if (!$this->isLoaded()) { |
111 | 111 | $filename = sha1(get_class($this)); |
112 | - $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . ".json"; |
|
112 | + $cacheFilename = "reflections".DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.".json"; |
|
113 | 113 | /** @var \PSFS\base\Cache $cacheService */ |
114 | 114 | $cacheService = Cache::getInstance(); |
115 | 115 | /** @var \PSFS\base\config\Config $configService */ |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | $this->load($property, true, $class); |
125 | 125 | } |
126 | 126 | $this->setLoaded(); |
127 | - } else { |
|
128 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
127 | + }else { |
|
128 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public static function getClassToCall($action) |
21 | 21 | { |
22 | 22 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
23 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
23 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
24 | 24 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
25 | 25 | return $class; |
26 | 26 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $expr = preg_quote($expr, '/'); |
107 | 107 | $expr = str_replace('###', '(.*)', $expr); |
108 | 108 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
109 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
109 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
110 | 110 | return $matched; |
111 | 111 | } |
112 | 112 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
119 | 119 | { |
120 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
121 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
120 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
121 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
122 | 122 | $tpl_path = "templates"; |
123 | 123 | $public_path = "public"; |
124 | 124 | $model_path = "models"; |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | $model_path = ucfirst($model_path); |
129 | 129 | } |
130 | 130 | if ($class->hasConstant("TPL")) { |
131 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
131 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
132 | 132 | } |
133 | 133 | return [ |
134 | 134 | "base" => $path, |
135 | - "template" => $path . $tpl_path, |
|
136 | - "model" => $path . $model_path, |
|
137 | - "public" => $path . $public_path, |
|
135 | + "template" => $path.$tpl_path, |
|
136 | + "model" => $path.$model_path, |
|
137 | + "public" => $path.$public_path, |
|
138 | 138 | ]; |
139 | 139 | } |
140 | 140 | |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | if (count($parameters) > 0) foreach ($parameters as $param) { |
157 | 157 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
158 | 158 | $params[$param->getName()] = $param->getDefaultValue(); |
159 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
159 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
160 | 160 | } |
161 | - } else $default = $regex; |
|
161 | + }else $default = $regex; |
|
162 | 162 | |
163 | 163 | return array($regex, $default, $params); |
164 | 164 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $default = str_replace('{__DOMAIN__}', $module, $default); |
239 | 239 | $httpMethod = RouterHelper::extractReflectionHttpMethod($docComments); |
240 | 240 | $label = RouterHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
241 | - $route = $httpMethod . "#|#" . $regex; |
|
241 | + $route = $httpMethod."#|#".$regex; |
|
242 | 242 | $info = [ |
243 | 243 | "method" => $method->getName(), |
244 | 244 | "params" => $params, |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $default = Config::getInstance()->get('admin_action') ?: 'admin-login'; |
266 | 266 | |
267 | 267 | } |
268 | - if(null !== $default) { |
|
268 | + if (null !== $default) { |
|
269 | 269 | return Router::getInstance()->execute(Router::getInstance()->getRoute($default)); |
270 | 270 | } |
271 | 271 | return null; |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | $objects = scandir($dir); |
20 | 20 | foreach ($objects as $object) { |
21 | 21 | if ($object != "." && $object != "..") { |
22 | - if (filetype($dir . "/" . $object) == "dir") { |
|
23 | - self::deleteDir($dir . "/" . $object); |
|
24 | - } else { |
|
25 | - unlink($dir . "/" . $object); |
|
22 | + if (filetype($dir."/".$object) == "dir") { |
|
23 | + self::deleteDir($dir."/".$object); |
|
24 | + }else { |
|
25 | + unlink($dir."/".$object); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | { |
39 | 39 | $rootDirs = array("css", "js", "media", "font"); |
40 | 40 | foreach ($rootDirs as $dir) { |
41 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
41 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
42 | 42 | try { |
43 | - self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
44 | - } catch (\Exception $e) { |
|
43 | + self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
44 | + }catch (\Exception $e) { |
|
45 | 45 | Logger::log($e->getMessage()); |
46 | 46 | } |
47 | 47 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | { |
58 | 58 | try { |
59 | 59 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
60 | - throw new \Exception(_('Can\'t create directory ') . $dir); |
|
60 | + throw new \Exception(_('Can\'t create directory ').$dir); |
|
61 | 61 | } |
62 | - } catch (\Exception $e) { |
|
62 | + }catch (\Exception $e) { |
|
63 | 63 | Logger::log($e->getMessage(), LOG_WARNING); |
64 | 64 | if (!file_exists(dirname($dir))) { |
65 | - throw new GeneratorException($e->getMessage() . $dir); |
|
65 | + throw new GeneratorException($e->getMessage().$dir); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public static function getTemplatePath() |
75 | 75 | { |
76 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
76 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
77 | 77 | return realpath($path); |
78 | 78 | } |
79 | 79 | } |
80 | 80 | \ No newline at end of file |
@@ -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 | } |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | new InputArgument('path', InputArgument::OPTIONAL, 'Path en el que crear el Document Root'), |
14 | 14 | )) |
15 | 15 | ->setDescription('Comando de creación del Document Root del projecto') |
16 | - ->setCode(function (InputInterface $input, OutputInterface $output) { |
|
16 | + ->setCode(function(InputInterface $input, OutputInterface $output) { |
|
17 | 17 | // Creates the html path |
18 | 18 | $path = $input->getArgument('path'); |
19 | 19 | if (empty($path)) $path = WEB_DIR; |
20 | 20 | \PSFS\base\types\helpers\GeneratorHelper::createDir($path); |
21 | 21 | $paths = array("js", "css", "img", "media", "font"); |
22 | 22 | foreach ($paths as $htmlPath) { |
23 | - \PSFS\base\types\helpers\GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath); |
|
23 | + \PSFS\base\types\helpers\GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // Generates the root needed files |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | 'robots' => 'robots.txt', |
33 | 33 | ]; |
34 | 34 | foreach ($files as $templates => $filename) { |
35 | - $text = \PSFS\base\Template::getInstance()->dump("generator/html/" . $templates . '.html.twig'); |
|
36 | - if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) { |
|
37 | - $output->writeln('Can\t create the file ' . $filename); |
|
38 | - } else { |
|
39 | - $output->writeln($filename . ' created successfully'); |
|
35 | + $text = \PSFS\base\Template::getInstance()->dump("generator/html/".$templates.'.html.twig'); |
|
36 | + if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) { |
|
37 | + $output->writeln('Can\t create the file '.$filename); |
|
38 | + }else { |
|
39 | + $output->writeln($filename.' created successfully'); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | 43 | //Export base locale translations |
44 | - if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) { |
|
45 | - \PSFS\base\types\helpers\GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
46 | - \PSFS\Services\GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
44 | + if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
45 | + \PSFS\base\types\helpers\GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
46 | + \PSFS\Services\GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
47 | 47 | } |
48 | 48 | |
49 | - $output->writeln("Document root generado en " . $path); |
|
49 | + $output->writeln("Document root generado en ".$path); |
|
50 | 50 | }); |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | use Symfony\Component\Console\Input\InputInterface; |
7 | 7 | use Symfony\Component\Console\Output\OutputInterface; |
8 | 8 | |
9 | -if (!isset($console)) $console = new Application(); |
|
9 | +if (!isset($console)) { |
|
10 | + $console = new Application(); |
|
11 | +} |
|
10 | 12 | $console |
11 | 13 | ->register('psfs:create:root') |
12 | 14 | ->setDefinition(array( |
@@ -16,7 +18,9 @@ discard block |
||
16 | 18 | ->setCode(function (InputInterface $input, OutputInterface $output) { |
17 | 19 | // Creates the html path |
18 | 20 | $path = $input->getArgument('path'); |
19 | - if (empty($path)) $path = WEB_DIR; |
|
21 | + if (empty($path)) { |
|
22 | + $path = WEB_DIR; |
|
23 | + } |
|
20 | 24 | \PSFS\base\types\helpers\GeneratorHelper::createDir($path); |
21 | 25 | $paths = array("js", "css", "img", "media", "font"); |
22 | 26 | foreach ($paths as $htmlPath) { |
@@ -11,20 +11,20 @@ discard block |
||
11 | 11 | */ |
12 | 12 | // Load custom config |
13 | 13 | $pwd = getcwd(); |
14 | -$dir = $pwd . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR; |
|
14 | +$dir = $pwd.DIRECTORY_SEPARATOR."vendor".DIRECTORY_SEPARATOR; |
|
15 | 15 | |
16 | -require_once $dir . 'autoload.php'; |
|
16 | +require_once $dir.'autoload.php'; |
|
17 | 17 | |
18 | 18 | |
19 | -$project_path = $pwd . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR; |
|
20 | -if (file_exists($project_path . "bootstrap.php")) { |
|
21 | - include_once($project_path . "bootstrap.php"); |
|
19 | +$project_path = $pwd.DIRECTORY_SEPARATOR."src".DIRECTORY_SEPARATOR; |
|
20 | +if (file_exists($project_path."bootstrap.php")) { |
|
21 | + include_once($project_path."bootstrap.php"); |
|
22 | 22 | } |
23 | -if (file_exists($project_path . "autoload.php")) { |
|
24 | - include_once($project_path . "autoload.php"); |
|
23 | +if (file_exists($project_path."autoload.php")) { |
|
24 | + include_once($project_path."autoload.php"); |
|
25 | 25 | } |
26 | 26 | |
27 | -require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php'; |
|
27 | +require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'bootstrap.php'; |
|
28 | 28 | |
29 | 29 | $console = new Application(); |
30 | 30 | //Hidratamos con los comandos de PSFS |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | |
35 | 35 | //Hidratamos con los comandos de los módulos |
36 | 36 | $domains = Router::getInstance()->getDomains(); |
37 | -foreach($domains as $domain => $paths) { |
|
38 | - if(!preg_match('/ROOT/i', $domain)) { |
|
37 | +foreach ($domains as $domain => $paths) { |
|
38 | + if (!preg_match('/ROOT/i', $domain)) { |
|
39 | 39 | $commands = new Finder(); |
40 | 40 | $commands->in($paths['base'])->path("Command")->name("*.php"); |
41 | 41 | foreach ($commands as $com) include_once($com->getRealPath()); |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | //Hidratamos con los comandos de PSFS |
31 | 31 | $commands = new Finder(); |
32 | 32 | $commands->in(__DIR__)->notName("PSFSConsole.php"); |
33 | -foreach ($commands as $com) include_once($com->getRealPath()); |
|
33 | +foreach ($commands as $com) { |
|
34 | + include_once($com->getRealPath()); |
|
35 | +} |
|
34 | 36 | |
35 | 37 | //Hidratamos con los comandos de los módulos |
36 | 38 | $domains = Router::getInstance()->getDomains(); |
@@ -38,7 +40,9 @@ discard block |
||
38 | 40 | if(!preg_match('/ROOT/i', $domain)) { |
39 | 41 | $commands = new Finder(); |
40 | 42 | $commands->in($paths['base'])->path("Command")->name("*.php"); |
41 | - foreach ($commands as $com) include_once($com->getRealPath()); |
|
43 | + foreach ($commands as $com) { |
|
44 | + include_once($com->getRealPath()); |
|
45 | + } |
|
42 | 46 | } |
43 | 47 | } |
44 | 48 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use PSFS\base\types\helpers\GeneratorHelper; |
17 | 17 | use PSFS\controller\ConfigController; |
18 | 18 | |
19 | -require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php"; |
|
19 | +require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php"; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Class Dispatcher |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | private function setLocale() |
78 | 78 | { |
79 | 79 | $this->locale = $this->config->get("default_language"); |
80 | - Logger::log('Set locale to project [' . $this->locale . ']'); |
|
80 | + Logger::log('Set locale to project ['.$this->locale.']'); |
|
81 | 81 | // Load translations |
82 | - putenv("LC_ALL=" . $this->locale); |
|
82 | + putenv("LC_ALL=".$this->locale); |
|
83 | 83 | setlocale(LC_ALL, $this->locale); |
84 | 84 | // Load the locale path |
85 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
86 | - Logger::log('Set locale dir ' . $locale_path); |
|
85 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
86 | + Logger::log('Set locale dir '.$locale_path); |
|
87 | 87 | GeneratorHelper::createDir($locale_path); |
88 | 88 | bindtextdomain('translations', $locale_path); |
89 | 89 | textdomain('translations'); |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | if (!$this->parser->isFile()) { |
105 | 105 | return $this->router->execute($this->actualUri); |
106 | 106 | } |
107 | - } else { |
|
107 | + }else { |
|
108 | 108 | return ConfigController::getInstance()->config(); |
109 | 109 | } |
110 | - } catch (ConfigException $c) { |
|
110 | + }catch (ConfigException $c) { |
|
111 | 111 | return $this->dumpException($c); |
112 | - } catch (SecurityException $s) { |
|
112 | + }catch (SecurityException $s) { |
|
113 | 113 | return $this->security->notAuthorized($this->actualUri); |
114 | - } catch (UserAuthException $u) { |
|
114 | + }catch (UserAuthException $u) { |
|
115 | 115 | $this->redirectToHome(); |
116 | - } catch (RouterException $r) { |
|
116 | + }catch (RouterException $r) { |
|
117 | 117 | return $this->router->httpNotFound($r); |
118 | - } catch (\Exception $e) { |
|
118 | + }catch (\Exception $e) { |
|
119 | 119 | return $this->dumpException($e); |
120 | 120 | } |
121 | 121 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $use /= 1024; |
163 | 163 | break; |
164 | 164 | case "MBytes": |
165 | - $use /= (1024 * 1024); |
|
165 | + $use /= (1024*1024); |
|
166 | 166 | break; |
167 | 167 | case "Bytes": |
168 | 168 | default: |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | if ($this->config->getDebugMode() && $this->config->get('errors.strict', false)) { |
189 | 189 | Logger::log('Added handlers for errors'); |
190 | 190 | //Warning & Notice handler |
191 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
191 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
192 | 192 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]); |
193 | 193 | throw new \Exception($errstr, 500); |
194 | 194 | }); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | Logger::log('Initializing stats (mem + ts)'); |
204 | 204 | if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) { |
205 | 205 | $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT']; |
206 | - } else { |
|
206 | + }else { |
|
207 | 207 | $this->ts = $this->parser->getTs(); |
208 | 208 | } |
209 | 209 | $this->mem = memory_get_usage(); |