@@ -415,7 +415,7 @@ |
||
415 | 415 | * @param array $parts |
416 | 416 | * @param int $partLength |
417 | 417 | * |
418 | - * @return array |
|
418 | + * @return string[] |
|
419 | 419 | */ |
420 | 420 | private static function extractTsAndMod(array &$parts, $partLength) |
421 | 421 | { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } |
63 | 63 | $this->user = (array_key_exists(self::USER_ID_TOKEN, $this->session)) ? unserialize($this->session[self::USER_ID_TOKEN]) : NULL; |
64 | 64 | $this->admin = (array_key_exists(self::ADMIN_ID_TOKEN, $this->session)) ? unserialize($this->session[self::ADMIN_ID_TOKEN]) : NULL; |
65 | - if(null === $this->admin) { |
|
65 | + if (null === $this->admin) { |
|
66 | 66 | $this->checkAdmin(); |
67 | 67 | } |
68 | 68 | } |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | public static function save($user) |
122 | 122 | { |
123 | 123 | $admins = array(); |
124 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
125 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
124 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
125 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
126 | 126 | } |
127 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
127 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
128 | 128 | $admins[$user['username']]['profile'] = $user['profile']; |
129 | 129 | |
130 | - return (FALSE !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
130 | + return (FALSE !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | public function getAdmins() |
162 | 162 | { |
163 | 163 | $admins = array(); |
164 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
165 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
164 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
165 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | return $admins; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | { |
182 | 182 | Logger::log('Checking admin session'); |
183 | 183 | if (!$this->authorized && !$this->checked) { |
184 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
184 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
185 | 185 | $request = Request::getInstance(); |
186 | 186 | $admins = $this->getAdmins(); |
187 | 187 | //Sacamos las credenciales de la petición |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | } |
193 | 193 | if (!empty($user) && !empty($admins[$user])) { |
194 | 194 | $auth = $admins[$user]['hash']; |
195 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
196 | - if($this->authorized) { |
|
195 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
196 | + if ($this->authorized) { |
|
197 | 197 | $this->admin = array( |
198 | 198 | 'alias' => $user, |
199 | 199 | 'profile' => $admins[$user]['profile'], |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | $axis = 0; |
417 | 417 | $parts = array(); |
418 | 418 | try { |
419 | - $partLength = floor(strlen($token) / 10); |
|
420 | - for ($i = 0, $ct = ceil(strlen($token) / $partLength); $i < $ct; $i++) { |
|
419 | + $partLength = floor(strlen($token)/10); |
|
420 | + for ($i = 0, $ct = ceil(strlen($token)/$partLength); $i < $ct; $i++) { |
|
421 | 421 | $parts[] = substr($token, $axis, $partLength); |
422 | 422 | $axis += $partLength; |
423 | 423 | } |
424 | - } catch (\Exception $e) { |
|
424 | + }catch (\Exception $e) { |
|
425 | 425 | $partLength = 0; |
426 | 426 | } |
427 | 427 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $decoded = NULL; |
462 | 462 | list($partLength, $parts) = self::extractTokenParts($token); |
463 | 463 | list($ts, $mod) = self::extractTsAndMod($parts, $partLength); |
464 | - $hashMod = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
464 | + $hashMod = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
465 | 465 | if (time() - (integer)$ts < 300 && $hashMod === $mod) { |
466 | 466 | $decoded = implode('', $parts); |
467 | 467 | } |
@@ -478,16 +478,16 @@ discard block |
||
478 | 478 | public static function generateToken($secret, $module = 'PSFS') |
479 | 479 | { |
480 | 480 | $ts = time(); |
481 | - $hashModule = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
481 | + $hashModule = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
482 | 482 | $hash = hash('sha256', $secret); |
483 | - $insert = floor(strlen($hash) / strlen($ts)); |
|
483 | + $insert = floor(strlen($hash)/strlen($ts)); |
|
484 | 484 | $j = 0; |
485 | 485 | $token = ''; |
486 | 486 | for ($i = 0, $ct = strlen($ts); $i < $ct; $i++) { |
487 | - $token .= substr($ts, $i, 1) . substr($hash, $j, $insert) . substr($hashModule, $i, 2); |
|
487 | + $token .= substr($ts, $i, 1).substr($hash, $j, $insert).substr($hashModule, $i, 2); |
|
488 | 488 | $j += $insert; |
489 | 489 | } |
490 | - $token .= substr($hash, ($insert * strlen($ts)), strlen($hash) - ($insert * strlen($ts))); |
|
490 | + $token .= substr($hash, ($insert*strlen($ts)), strlen($hash) - ($insert*strlen($ts))); |
|
491 | 491 | return $token; |
492 | 492 | } |
493 | 493 |
@@ -125,8 +125,8 @@ |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | - * @param $header |
|
129 | - * @param null $content |
|
128 | + * @param string $header |
|
129 | + * @param string $content |
|
130 | 130 | * |
131 | 131 | * @return $this |
132 | 132 | */ |
@@ -177,7 +177,7 @@ |
||
177 | 177 | $this->url = NULL; |
178 | 178 | $this->params = array(); |
179 | 179 | $this->headers = array(); |
180 | - Logger::log("Context service for " . get_called_class() . " cleared!"); |
|
180 | + Logger::log("Context service for ".get_called_class()." cleared!"); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -135,9 +135,11 @@ |
||
135 | 135 | $cacheService->storeData($cacheFilename, $properties, Cache::JSON); |
136 | 136 | } |
137 | 137 | /** @var \ReflectionProperty $property */ |
138 | - if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { |
|
138 | + if (!empty($properties) && is_array($properties)) { |
|
139 | + foreach ($properties as $property => $class) { |
|
139 | 140 | $this->load($property, true, $class); |
140 | 141 | } |
142 | + } |
|
141 | 143 | $this->setLoaded(); |
142 | 144 | } else { |
143 | 145 | Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
@@ -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 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | public function init() |
109 | 109 | { |
110 | 110 | if (!$this->isLoaded()) { |
111 | - $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . sha1(get_class($this)) . ".json"; |
|
111 | + $cacheFilename = "reflections".DIRECTORY_SEPARATOR.sha1(get_class($this)).".json"; |
|
112 | 112 | /** @var \PSFS\base\Cache $cacheService */ |
113 | 113 | $cacheService = Cache::getInstance(); |
114 | 114 | /** @var \PSFS\base\config\Config $configService */ |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | $this->load($property, true, $class); |
124 | 124 | } |
125 | 125 | $this->setLoaded(); |
126 | - } else { |
|
127 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
126 | + }else { |
|
127 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |
@@ -21,11 +21,11 @@ |
||
21 | 21 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
22 | 22 | |
23 | 23 | // filepath |
24 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
24 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
25 | 25 | if (!file_exists($abs_path)) { |
26 | - pre('→ ' . $class); |
|
27 | - pre('→ ' . $path); |
|
28 | - pre('→ ' . $abs_path); |
|
26 | + pre('→ '.$class); |
|
27 | + pre('→ '.$path); |
|
28 | + pre('→ '.$abs_path); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // require the file |
@@ -4,16 +4,16 @@ |
||
4 | 4 | |
5 | 5 | if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
6 | 6 | if (preg_match('/vendor/', SOURCE_DIR)) { |
7 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
8 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
9 | -} else { |
|
10 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
11 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
7 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
8 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
9 | +}else { |
|
10 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
11 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
12 | 12 | } |
13 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
14 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
15 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
16 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
13 | +if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
14 | +if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
15 | +if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
16 | +if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
17 | 17 | |
18 | 18 | //Cargamos en memoria la función de desarrollo PRE |
19 | 19 | if (!function_exists('pre')) { |
@@ -1,19 +1,39 @@ |
||
1 | 1 | <?php |
2 | -if (defined('PSFS_BOOTSTRAP_LOADED')) return; |
|
2 | +if (defined('PSFS_BOOTSTRAP_LOADED')) { |
|
3 | + return; |
|
4 | +} |
|
3 | 5 | use Symfony\Component\Finder\Finder; |
4 | 6 | |
5 | -if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
|
7 | +if (!defined('SOURCE_DIR')) { |
|
8 | + define('SOURCE_DIR', __DIR__); |
|
9 | +} |
|
6 | 10 | if (preg_match('/vendor/', SOURCE_DIR)) { |
7 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
8 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
9 | -} else { |
|
10 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
11 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
12 | -} |
|
13 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
14 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
15 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
16 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
11 | + if (!defined('BASE_DIR')) { |
|
12 | + define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
13 | + } |
|
14 | + if (!defined('CORE_DIR')) { |
|
15 | + define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
16 | + } |
|
17 | + } else { |
|
18 | + if (!defined('BASE_DIR')) { |
|
19 | + define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
20 | + } |
|
21 | + if (!defined('CORE_DIR')) { |
|
22 | + define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
23 | + } |
|
24 | + } |
|
25 | +if (!defined('LOG_DIR')) { |
|
26 | + define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
27 | +} |
|
28 | +if (!defined('CACHE_DIR')) { |
|
29 | + define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
30 | +} |
|
31 | +if (!defined('CONFIG_DIR')) { |
|
32 | + define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
33 | +} |
|
34 | +if (!defined('WEB_DIR')) { |
|
35 | + define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
36 | +} |
|
17 | 37 | |
18 | 38 | //Cargamos en memoria la función de desarrollo PRE |
19 | 39 | if (!function_exists('pre')) { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Método que guarda en fichero los datos pasados |
124 | - * @param $path |
|
124 | + * @param string $path |
|
125 | 125 | * @param $data |
126 | 126 | * @param int $transform |
127 | 127 | * @param boolean $absolutePath |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Método estático que revisa si se necesita cachear la respuesta de un servicio o no |
159 | - * @return integer|boolean |
|
159 | + * @return integer |
|
160 | 160 | */ |
161 | 161 | public static function needCache() |
162 | 162 | { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | private function saveTextToFile($data, $path, $absolute = false) |
31 | 31 | { |
32 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
32 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
33 | 33 | $filename = basename($absolutePath); |
34 | 34 | Config::createDir(str_replace($filename, "", $absolutePath)); |
35 | 35 | if (false === file_put_contents($absolutePath, $data)) { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false) |
49 | 49 | { |
50 | 50 | $data = null; |
51 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
51 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
52 | 52 | if (file_exists($absolutePath)) { |
53 | 53 | $data = file_get_contents($absolutePath); |
54 | 54 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
66 | 66 | { |
67 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
67 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
68 | 68 | $lasModificationDate = filemtime($absolutePath); |
69 | 69 | return ($lasModificationDate + $expires <= time()); |
70 | 70 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | break; |
88 | 88 | case Cache::GZIP: |
89 | 89 | // TODO implementar |
90 | - if(function_exists('gzuncompress')) { |
|
90 | + if (function_exists('gzuncompress')) { |
|
91 | 91 | $data = gzuncompress($data ?: ''); |
92 | 92 | } |
93 | 93 | break; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $data = Cache::transformData($data, Cache::GZIP); |
113 | 113 | break; |
114 | 114 | case Cache::GZIP: |
115 | - if(function_exists('gzcompress')) { |
|
115 | + if (function_exists('gzcompress')) { |
|
116 | 116 | $data = gzcompress($data ?: ''); |
117 | 117 | } |
118 | 118 | break; |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT) |
145 | 145 | { |
146 | 146 | $data = null; |
147 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
147 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
148 | 148 | if (null !== $function && $this->hasExpiredCache($path, $expires)) { |
149 | 149 | $data = call_user_func($function); |
150 | 150 | $this->storeData($path, $data, $transform); |
151 | - } else { |
|
151 | + }else { |
|
152 | 152 | $data = $this->getDataFromFile($path, $transform); |
153 | 153 | } |
154 | 154 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $hash = ""; |
179 | 179 | $action = Security::getInstance()->getSessionKey("__CACHE__"); |
180 | 180 | if (null !== $action && $action["cache"] > 0) { |
181 | - $hash = $action["http"] . " " . $action["slug"]; |
|
181 | + $hash = $action["http"]." ".$action["slug"]; |
|
182 | 182 | } |
183 | 183 | return sha1($hash); |
184 | 184 | } |
@@ -32,18 +32,18 @@ |
||
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')) { |
|
44 | + if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
45 | 45 | \PSFS\base\config\Config::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
46 | - \PSFS\Services\GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', 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 | 49 | $output->writeln("Document root generado en ".$path); |
@@ -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\config\Config::createDir($path); |
21 | 25 | $paths = array("js", "css", "img", "media", "font"); |
22 | 26 | foreach ($paths as $htmlPath) { |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @GET |
21 | 21 | * @route /admin/config/params |
22 | 22 | * @visible false |
23 | - * @return mixed |
|
23 | + * @return string|null |
|
24 | 24 | */ |
25 | 25 | public function getConfigParams() { |
26 | 26 | $response = array_merge(Config::$required, Config::$optional); |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | public function getConfigParams() { |
26 | 26 | $response = array_merge(Config::$required, Config::$optional); |
27 | 27 | $domains = Router::getInstance()->getDomains(); |
28 | - foreach($domains as $domain => $routes) { |
|
28 | + foreach ($domains as $domain => $routes) { |
|
29 | 29 | $pDomain = str_replace('@', '', $domain); |
30 | 30 | $pDomain = str_replace('/', '', $pDomain); |
31 | - $response[] = strtolower($pDomain) . '.api.secret'; |
|
31 | + $response[] = strtolower($pDomain).'.api.secret'; |
|
32 | 32 | } |
33 | 33 | return $this->json($response); |
34 | 34 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function config() |
44 | 44 | { |
45 | - Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri()); |
|
45 | + Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri()); |
|
46 | 46 | /* @var $form \PSFS\base\config\ConfigForm */ |
47 | 47 | $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig()); |
48 | 48 | $form->build(); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | Security::getInstance()->setFlash("callback_message", _("Configuración actualizada correctamente")); |
81 | 81 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true)); |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403); |
84 | 84 | } |
85 | 85 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * @GET |
29 | 29 | * @route /admin/routes/show |
30 | 30 | * @visible false |
31 | - * @return mixed |
|
31 | + * @return string|null |
|
32 | 32 | */ |
33 | 33 | public function getRouting() |
34 | 34 | { |
@@ -51,7 +51,7 @@ |
||
51 | 51 | $router->simpatize(); |
52 | 52 | Security::getInstance()->setFlash("callback_message", _("Rutas generadas correctamente")); |
53 | 53 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true)); |
54 | - } catch(\Exception $e) { |
|
54 | + }catch (\Exception $e) { |
|
55 | 55 | Logger::log($e->getMessage(), LOG_ERR); |
56 | 56 | Security::getInstance()->setFlash("callback_message", _("Algo no ha salido bien, revisa los logs")); |
57 | 57 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true)); |