@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function init() |
64 | 64 | { |
65 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
66 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
65 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
66 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
67 | 67 | if (empty($this->routing) || Config::getParam('debug', true)) { |
68 | 68 | $this->debugLoad(); |
69 | 69 | } |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function debugLoad() |
81 | 81 | { |
82 | - if(!Config::getParam('skip.route_generation', false)) { |
|
82 | + if (!Config::getParam('skip.route_generation', false)) { |
|
83 | 83 | Logger::log('Begin routes load'); |
84 | 84 | $this->hydrateRouting(); |
85 | 85 | $this->simpatize(); |
86 | 86 | Logger::log('End routes load'); |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | Logger::log('Routes generation skipped'); |
89 | 89 | } |
90 | 90 | } |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | try { |
102 | 102 | //Search action and execute |
103 | 103 | return $this->searchAction($route); |
104 | - } catch (AccessDeniedException $e) { |
|
105 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
104 | + }catch (AccessDeniedException $e) { |
|
105 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
106 | 106 | return Admin::staticAdminLogon(); |
107 | - } catch (RouterException $r) { |
|
107 | + }catch (RouterException $r) { |
|
108 | 108 | Logger::log($r->getMessage(), LOG_WARNING); |
109 | 109 | $code = $r->getCode(); |
110 | - } catch (Exception $e) { |
|
110 | + }catch (Exception $e) { |
|
111 | 111 | Logger::log($e->getMessage(), LOG_ERR); |
112 | 112 | throw $e; |
113 | 113 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function searchAction($route) |
127 | 127 | { |
128 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
128 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
129 | 129 | //Revisamos si tenemos la ruta registrada |
130 | 130 | $parts = parse_url($route); |
131 | 131 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | throw new RouterException(t('Preconditions failed'), 412); |
148 | - } catch (Exception $e) { |
|
148 | + }catch (Exception $e) { |
|
149 | 149 | Logger::log($e->getMessage(), LOG_ERR); |
150 | 150 | throw $e; |
151 | 151 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | } |
172 | 172 | $valid = count($action['requirements']) === $checked; |
173 | - } else { |
|
173 | + }else { |
|
174 | 174 | $valid = true; |
175 | 175 | } |
176 | 176 | return $valid; |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | if ($modules->hasResults()) { |
194 | 194 | foreach ($modules->getIterator() as $modulePath) { |
195 | 195 | $module = $modulePath->getBasename(); |
196 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
196 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |
200 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
200 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $homeParams = NULL; |
215 | 215 | foreach ($this->routing as $pattern => $params) { |
216 | 216 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
217 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
217 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
218 | 218 | $homeParams = $params; |
219 | 219 | } |
220 | 220 | unset($method); |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | { |
247 | 247 | $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : ''; |
248 | 248 | if ('' === $slug) { |
249 | - return $baseUrl . '/'; |
|
249 | + return $baseUrl.'/'; |
|
250 | 250 | } |
251 | 251 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
252 | 252 | throw new RouterException(t('No existe la ruta especificada')); |
253 | 253 | } |
254 | - $url = $baseUrl . $this->slugs[$slug]; |
|
254 | + $url = $baseUrl.$this->slugs[$slug]; |
|
255 | 255 | if (!empty($params)) { |
256 | 256 | foreach ($params as $key => $value) { |
257 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
257 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
258 | 258 | } |
259 | 259 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
260 | - $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default']; |
|
260 | + $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default']; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | private function checkPreActions($class, $method) |
271 | 271 | { |
272 | - $preAction = 'pre' . ucfirst($method); |
|
272 | + $preAction = 'pre'.ucfirst($method); |
|
273 | 273 | if (method_exists($class, $preAction)) { |
274 | 274 | Inspector::stats('[Router] Pre action invoked', Inspector::SCOPE_DEBUG); |
275 | 275 | try { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]); |
278 | 278 | error_clear_last(); |
279 | 279 | } |
280 | - } catch (Exception $e) { |
|
280 | + }catch (Exception $e) { |
|
281 | 281 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
282 | 282 | } |
283 | 283 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
296 | 296 | { |
297 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
297 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
298 | 298 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
299 | 299 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
300 | 300 | $cache = Cache::needCache(); |
@@ -302,15 +302,15 @@ discard block |
||
302 | 302 | $return = null; |
303 | 303 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
304 | 304 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
305 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
305 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
306 | 306 | if (NULL !== $cachedData) { |
307 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
307 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
308 | 308 | Template::getInstance()->renderCache($cachedData, $headers); |
309 | 309 | $execute = FALSE; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | if ($execute) { |
313 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
313 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
314 | 314 | $this->checkPreActions($class, $action['method']); |
315 | 315 | $return = call_user_func_array([$class, $action['method']], $params); |
316 | 316 | if (false === $return) { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param true $isArray |
30 | 30 | * @return array |
31 | 31 | */ |
32 | - public function processPayload(array|string $namespace, bool $isArray): array |
|
32 | + public function processPayload(array | string $namespace, bool $isArray): array |
|
33 | 33 | { |
34 | 34 | if (false !== strpos($namespace, '[') && false !== strpos($namespace, ']')) { |
35 | 35 | $namespace = str_replace(']', '', str_replace('[', '', $namespace)); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | list($isArray, $payload) = $this->processPayload($namespace, $isArray); |
103 | 103 | $reflector = new ReflectionClass($namespace); |
104 | 104 | $shortName = $reflector->getShortName(); |
105 | - } else { |
|
105 | + }else { |
|
106 | 106 | $namespace = $model; |
107 | 107 | $shortName = $model; |
108 | 108 | } |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | if ($module === $requestModule && !preg_match('/^ROOT/i', $module)) { |
178 | 178 | $modules = [ |
179 | 179 | 'name' => $module, |
180 | - 'path' => realpath(dirname($info['base'] . DIRECTORY_SEPARATOR . '..')), |
|
180 | + 'path' => realpath(dirname($info['base'].DIRECTORY_SEPARATOR.'..')), |
|
181 | 181 | ]; |
182 | 182 | } |
183 | - } catch (Exception $e) { |
|
183 | + }catch (Exception $e) { |
|
184 | 184 | $modules[] = $e->getMessage(); |
185 | 185 | } |
186 | 186 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
224 | 224 | $payload = $this->extractDtoProperties($namespace); |
225 | 225 | } |
226 | - } catch (Exception $e) { |
|
226 | + }catch (Exception $e) { |
|
227 | 227 | Logger::log($e->getMessage(), LOG_ERR); |
228 | 228 | } |
229 | 229 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | // Gather always the base translations |
50 | 50 | $standardTranslations = []; |
51 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']); |
|
51 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']); |
|
52 | 52 | if (file_exists(self::$filename)) { |
53 | 53 | $standardTranslations = json_decode(file_get_contents(self::$filename), true); |
54 | 54 | } |
@@ -67,32 +67,32 @@ discard block |
||
67 | 67 | $session_locale = $session->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY); |
68 | 68 | self::$locale = $forceReload ? $session_locale : I18nHelper::extractLocale($session_locale); |
69 | 69 | $version = $session->getSessionKey(self::LOCALE_CACHED_VERSION); |
70 | - $configVersion = self::$locale . '_' . Config::getParam('cache.var', 'v1'); |
|
70 | + $configVersion = self::$locale.'_'.Config::getParam('cache.var', 'v1'); |
|
71 | 71 | if ($forceReload) { |
72 | 72 | Inspector::stats('[translationsCheckLoad] Force translations reload', Inspector::SCOPE_DEBUG); |
73 | 73 | self::dropInstance(); |
74 | 74 | $version = null; |
75 | 75 | self::$translations = []; |
76 | 76 | } |
77 | - if(count(self::$translations) === 0) { |
|
77 | + if (count(self::$translations) === 0) { |
|
78 | 78 | Inspector::stats('[translationsCheckLoad] Extracting translations', Inspector::SCOPE_DEBUG); |
79 | 79 | self::$generate = (boolean)Config::getParam('i18n.autogenerate', false); |
80 | - if(null !== $version && $version === $configVersion) { |
|
80 | + if (null !== $version && $version === $configVersion) { |
|
81 | 81 | Inspector::stats('[translationsCheckLoad] Translations loaded from session', Inspector::SCOPE_DEBUG); |
82 | 82 | self::$translations = $session->getSessionKey(self::LOCALE_CACHED_TAG); |
83 | - } else { |
|
83 | + }else { |
|
84 | 84 | if (!$useBase) { |
85 | 85 | $customKey = $customKey ?: $session->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY); |
86 | 86 | } |
87 | 87 | $standardTranslations = self::extractBaseTranslations(); |
88 | 88 | // If the project has custom translations, gather them |
89 | 89 | if (null !== $customKey) { |
90 | - Logger::log('[' . self::class . '] Custom key detected: ' . $customKey, LOG_INFO); |
|
91 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale . '.json']); |
|
90 | + Logger::log('['.self::class.'] Custom key detected: '.$customKey, LOG_INFO); |
|
91 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale.'.json']); |
|
92 | 92 | } |
93 | 93 | // Finally we merge base and custom translations to complete all the i18n set |
94 | 94 | if (file_exists(self::$filename)) { |
95 | - Logger::log('[' . self::class . '] Custom locale detected: ' . $customKey . ' [' . self::$locale . ']', LOG_INFO); |
|
95 | + Logger::log('['.self::class.'] Custom locale detected: '.$customKey.' ['.self::$locale.']', LOG_INFO); |
|
96 | 96 | self::$translations = array_merge($standardTranslations, json_decode(file_get_contents(self::$filename), true)); |
97 | 97 | $session->setSessionKey(self::LOCALE_CACHED_TAG, self::$translations); |
98 | 98 | $session->setSessionKey(self::LOCALE_CACHED_VERSION, $configVersion); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function getFilters() |
119 | 119 | { |
120 | 120 | return array( |
121 | - new TwigFilter('trans', function ($message) { |
|
121 | + new TwigFilter('trans', function($message) { |
|
122 | 122 | return self::_($message); |
123 | 123 | }), |
124 | 124 | ); |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public static function _($message, $customKey = null, $forceReload = false) |
142 | 142 | { |
143 | - if(0 === count(self::$translations) || $forceReload) { |
|
143 | + if (0 === count(self::$translations) || $forceReload) { |
|
144 | 144 | self::translationsCheckLoad($customKey, $forceReload); |
145 | 145 | } |
146 | 146 | if (is_array(self::$translations) && array_key_exists($message, self::$translations)) { |
147 | 147 | $translation = self::$translations[$message]; |
148 | - } else { |
|
148 | + }else { |
|
149 | 149 | $translation = gettext($message); |
150 | 150 | } |
151 | 151 | if (self::$generate) { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | foreach ($domains as $domain => $routes) { |
38 | 38 | $pDomain = str_replace('@', '', $domain); |
39 | 39 | $pDomain = str_replace('/', '', $pDomain); |
40 | - $response[] = strtolower($pDomain) . '.api.secret'; |
|
40 | + $response[] = strtolower($pDomain).'.api.secret'; |
|
41 | 41 | } |
42 | 42 | return $this->json($response); |
43 | 43 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function config() |
55 | 55 | { |
56 | - Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri()); |
|
56 | + Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri()); |
|
57 | 57 | if (defined('PSFS_UNIT_TESTING_EXECUTION')) { |
58 | 58 | throw new ConfigException('CONFIG'); |
59 | 59 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | Security::getInstance()->setFlash("callback_message", t("Configuración actualizada correctamente")); |
94 | 94 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true)); |
95 | - } else { |
|
95 | + }else { |
|
96 | 96 | throw new HttpException(t('Error al guardar la configuración, prueba a cambiar los permisos'), 403); |
97 | 97 | } |
98 | 98 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | { |
57 | 57 | GeneratorHelper::createDir(dirname($path)); |
58 | 58 | if (false === FileHelper::writeFile($path, $data)) { |
59 | - throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ') . $path); |
|
59 | + throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ').$path); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | Inspector::stats('[Cache] Gathering data from cache', Inspector::SCOPE_DEBUG); |
72 | 72 | $data = null; |
73 | - $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
73 | + $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
74 | 74 | if (file_exists($absolutePath)) { |
75 | 75 | $data = FileHelper::readFile($absolutePath); |
76 | 76 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
87 | 87 | { |
88 | 88 | Inspector::stats('[Cache] Checking expiration', Inspector::SCOPE_DEBUG); |
89 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
89 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
90 | 90 | $lasModificationDate = filemtime($absolutePath); |
91 | 91 | return ($lasModificationDate + $expires <= time()); |
92 | 92 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | { |
154 | 154 | Inspector::stats('[Cache] Store data in cache', Inspector::SCOPE_DEBUG); |
155 | 155 | $data = self::transformData($data, $transform); |
156 | - $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
156 | + $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
157 | 157 | $this->saveTextToFile($data, $absolutePath); |
158 | 158 | } |
159 | 159 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | public function readFromCache($path, $expires = 300, $function = null, $transform = Cache::TEXT, $ignoreExpiration = false) |
171 | 171 | { |
172 | 172 | $data = null; |
173 | - Inspector::stats('[Cache] Reading data from cache: ' . json_encode(['path' => $path]), Inspector::SCOPE_DEBUG); |
|
174 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
173 | + Inspector::stats('[Cache] Reading data from cache: '.json_encode(['path' => $path]), Inspector::SCOPE_DEBUG); |
|
174 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
175 | 175 | if (is_callable($function) && $this->hasExpiredCache($path, $expires) && !$ignoreExpiration) { |
176 | 176 | $data = $function(); |
177 | 177 | $this->storeData($path, $data, $transform); |
178 | - } else { |
|
178 | + }else { |
|
179 | 179 | $data = $this->getDataFromFile($path, $transform); |
180 | 180 | } |
181 | 181 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $query[Api::HEADER_API_LANG] = Request::header(Api::HEADER_API_LANG, 'es'); |
222 | 222 | $filename = FileHelper::generateHashFilename($action['http'], $action['slug'], $query); |
223 | 223 | $hashPath = FileHelper::generateCachePath($action, $query); |
224 | - Inspector::stats('[Cache] Cache file calculated: ' . json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG); |
|
224 | + Inspector::stats('[Cache] Cache file calculated: '.json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG); |
|
225 | 225 | Logger::log('Cache file calculated', LOG_DEBUG, ['file' => $filename, 'hash' => $hashPath]); |
226 | 226 | } |
227 | 227 | return [$hashPath, $filename]; |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | Inspector::stats('[Cache] Flushing cache', Inspector::SCOPE_DEBUG); |
234 | 234 | $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR); |
235 | 235 | if (is_array($action)) { |
236 | - $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
236 | + $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
237 | 237 | if (!file_exists($hashPath)) { |
238 | - $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath; |
|
238 | + $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath; |
|
239 | 239 | } |
240 | 240 | FileHelper::deleteDir($hashPath); |
241 | 241 | } |
@@ -8,24 +8,24 @@ |
||
8 | 8 | defined('JSON_THROW_ON_ERROR') or define('JSON_THROW_ON_ERROR', 4194304); |
9 | 9 | defined('JSON_INVALID_UTF8_SUBSTITUTE') or define('JSON_INVALID_UTF8_SUBSTITUTE', 2097152); |
10 | 10 | |
11 | -if (defined('PSFS_PHAR_DIR') && file_exists(PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php')) { |
|
12 | - @require_once PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php'; |
|
11 | +if (defined('PSFS_PHAR_DIR') && file_exists(PSFS_PHAR_DIR.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'environment.php')) { |
|
12 | + @require_once PSFS_PHAR_DIR.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'environment.php'; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | defined('SOURCE_DIR') or define('SOURCE_DIR', __DIR__); |
16 | 16 | if (str_contains(SOURCE_DIR, 'vendor')) { |
17 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
18 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
19 | -} else { |
|
20 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
21 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
17 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
18 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
19 | +}else { |
|
20 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
21 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
22 | 22 | } |
23 | -defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
24 | -defined('LOG_DIR') or define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
25 | -defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
26 | -defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
27 | -defined('WEB_DIR') or define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
28 | -defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
23 | +defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor'); |
|
24 | +defined('LOG_DIR') or define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
25 | +defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
26 | +defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
27 | +defined('WEB_DIR') or define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
28 | +defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
29 | 29 | |
30 | 30 | if (!class_exists(bootstrap::class)) { |
31 | 31 | /** |
@@ -40,7 +40,9 @@ |
||
40 | 40 | { |
41 | 41 | if (!self::$loaded) { |
42 | 42 | defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true); |
43 | - if (class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
43 | + if (class_exists("\\PSFS\\base\\Logger")) { |
|
44 | + \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
45 | + } |
|
44 | 46 | self::$loaded = true; |
45 | 47 | } |
46 | 48 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | // autoloader |
15 | 15 | function PSFSAutoloader($class): false |
16 | 16 | { |
17 | - Logger::log("Trying to load class {$class} with " . __FILE__); |
|
17 | + Logger::log("Trying to load class {$class} with ".__FILE__); |
|
18 | 18 | // it only autoload class into the Rain scope |
19 | 19 | if (str_contains($class, 'PSFS')) { |
20 | 20 | // Change order src |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
24 | 24 | |
25 | 25 | // filepath |
26 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
26 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
27 | 27 | |
28 | 28 | // require the file |
29 | 29 | if (file_exists($abs_path)) { |
30 | 30 | require_once $abs_path; |
31 | - } else { |
|
32 | - Logger::log("{$class} not loaded with " . __FILE__); |
|
31 | + }else { |
|
32 | + Logger::log("{$class} not loaded with ".__FILE__); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | return false; |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * @throws \PSFS\base\exception\GeneratorException |
17 | 17 | */ |
18 | 18 | public function getConnectionManager(string $module, string $path): array { |
19 | - $modulePath = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $path . $module); |
|
19 | + $modulePath = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $path.$module); |
|
20 | 20 | $generatorConfig = $this->getConfigGenerator($modulePath); |
21 | 21 | |
22 | 22 | $manager = new MigrationManager(); |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function createStructureModule(string $module, bool $force = false, string $type = "", string $apiClass = "", bool $skipMigration = false): void |
51 | 51 | { |
52 | - $modPath = CORE_DIR . DIRECTORY_SEPARATOR; |
|
52 | + $modPath = CORE_DIR.DIRECTORY_SEPARATOR; |
|
53 | 53 | $module = ucfirst($module); |
54 | 54 | $this->createModulePath($module, $modPath); |
55 | 55 | $this->createModulePathTree($module, $modPath); |
56 | 56 | $this->createModuleBaseFiles($module, $modPath, $force, $type); |
57 | 57 | $this->createModuleModels($module, $modPath); |
58 | 58 | $this->generateBaseApiTemplate($module, $modPath, $force, $apiClass); |
59 | - if(!$skipMigration) { |
|
59 | + if (!$skipMigration) { |
|
60 | 60 | $this->createModuleMigrations($module, $modPath); |
61 | 61 | } |
62 | 62 | //Redireccionamos al home definido |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | private function createModuleBaseFiles($module, $modPath, $force = false, $controllerType = '') |
75 | 75 | { |
76 | - $modulePath = $modPath . $module; |
|
76 | + $modulePath = $modPath.$module; |
|
77 | 77 | $this->generateControllerTemplate($module, $modulePath, $force, $controllerType); |
78 | 78 | $this->generateServiceTemplate($module, $modulePath, $force); |
79 | 79 | $this->generateSchemaTemplate($module, $modulePath, $force); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $this->genereateAutoloaderTemplate($module, $modulePath, $force); |
95 | 95 | $this->generatePropertiesTemplate($module, $modulePath, $force); |
96 | 96 | $this->generateConfigTemplate($modulePath, $force); |
97 | - $this->createModuleModels($module, CORE_DIR . DIRECTORY_SEPARATOR); |
|
97 | + $this->createModuleModels($module, CORE_DIR.DIRECTORY_SEPARATOR); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -114,26 +114,26 @@ discard block |
||
114 | 114 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
115 | 115 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
116 | 116 | "class" => $class, |
117 | - "controllerType" => $class . "Base", |
|
117 | + "controllerType" => $class."Base", |
|
118 | 118 | "is_base" => false |
119 | 119 | )); |
120 | - $controller = $this->writeTemplateToFile($controllerBody, $modPath . DIRECTORY_SEPARATOR . "Controller" . |
|
121 | - DIRECTORY_SEPARATOR . "{$class}Controller.php", $force); |
|
120 | + $controller = $this->writeTemplateToFile($controllerBody, $modPath.DIRECTORY_SEPARATOR."Controller". |
|
121 | + DIRECTORY_SEPARATOR."{$class}Controller.php", $force); |
|
122 | 122 | |
123 | 123 | $controllerBody = $this->tpl->dump("generator/controller.template.twig", array( |
124 | 124 | "module" => $module, |
125 | 125 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
126 | 126 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
127 | - "class" => $class . "Base", |
|
127 | + "class" => $class."Base", |
|
128 | 128 | "service" => $class, |
129 | 129 | "controllerType" => $controllerType, |
130 | 130 | "is_base" => true, |
131 | 131 | "domain" => $class, |
132 | 132 | )); |
133 | - $controllerBase = $this->writeTemplateToFile($controllerBody, $modPath . DIRECTORY_SEPARATOR . "Controller" . |
|
134 | - DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true); |
|
133 | + $controllerBase = $this->writeTemplateToFile($controllerBody, $modPath.DIRECTORY_SEPARATOR."Controller". |
|
134 | + DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true); |
|
135 | 135 | |
136 | - $filename = $modPath . DIRECTORY_SEPARATOR . "Test" . DIRECTORY_SEPARATOR . "{$class}Test.php"; |
|
136 | + $filename = $modPath.DIRECTORY_SEPARATOR."Test".DIRECTORY_SEPARATOR."{$class}Test.php"; |
|
137 | 137 | $test = true; |
138 | 138 | if (!file_exists($filename)) { |
139 | 139 | $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | private function createModuleModels($module, $path) |
156 | 156 | { |
157 | - $modulePath = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $path . $module); |
|
157 | + $modulePath = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $path.$module); |
|
158 | 158 | $configGenerator = $this->getConfigGenerator($modulePath); |
159 | 159 | |
160 | 160 | $this->buildModels($configGenerator); |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | $configTemplate = $this->tpl->dump("generator/config.propel.template.twig", array( |
164 | 164 | "module" => $module, |
165 | 165 | )); |
166 | - $this->writeTemplateToFile($configTemplate, CORE_DIR . DIRECTORY_SEPARATOR . $modulePath . DIRECTORY_SEPARATOR . "Config" . |
|
167 | - DIRECTORY_SEPARATOR . "config.php", true); |
|
166 | + $this->writeTemplateToFile($configTemplate, CORE_DIR.DIRECTORY_SEPARATOR.$modulePath.DIRECTORY_SEPARATOR."Config". |
|
167 | + DIRECTORY_SEPARATOR."config.php", true); |
|
168 | 168 | Logger::log("Generado config genérico para propel"); |
169 | 169 | } |
170 | 170 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | if ($totalNbTables) { |
232 | 232 | Logger::log(sprintf('%d tables found in all databases.', $totalNbTables)); |
233 | - } else { |
|
233 | + }else { |
|
234 | 234 | Logger::log('No table found in all databases'); |
235 | 235 | } |
236 | 236 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $migrationFileName = $manager->getMigrationFileName($timestamp); |
289 | 289 | $migrationClassBody = $manager->getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp); |
290 | 290 | |
291 | - $file = $generatorConfig->getSection('paths')['migrationDir'] . DIRECTORY_SEPARATOR . $migrationFileName; |
|
291 | + $file = $generatorConfig->getSection('paths')['migrationDir'].DIRECTORY_SEPARATOR.$migrationFileName; |
|
292 | 292 | file_put_contents($file, $migrationClassBody); |
293 | 293 | |
294 | 294 | Logger::log(sprintf('"%s" file successfully created.', $file)); |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | private function generateBaseApiTemplate($module, $modPath, $force = false, $apiClass = "") |
307 | 307 | { |
308 | 308 | $created = true; |
309 | - $modelPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
310 | - $apiPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Api'; |
|
309 | + $modelPath = $modPath.$module.DIRECTORY_SEPARATOR.'Models'; |
|
310 | + $apiPath = $modPath.$module.DIRECTORY_SEPARATOR.'Api'; |
|
311 | 311 | if (file_exists($modelPath)) { |
312 | 312 | $dir = dir($modelPath); |
313 | 313 | $this->generateApiFiles($module, $force, $apiClass, $dir, $apiPath); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | //Generamos el fichero de configuración |
326 | 326 | Logger::log("Generamos fichero vacío de configuración"); |
327 | 327 | return $this->writeTemplateToFile("<?php\n\t", |
328 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", |
|
328 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", |
|
329 | 329 | $force); |
330 | 330 | } |
331 | 331 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | "db" => $this->config->get("db_name"), |
347 | 347 | )); |
348 | 348 | return $this->writeTemplateToFile($schema, |
349 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", |
|
349 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", |
|
350 | 350 | $force); |
351 | 351 | } |
352 | 352 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | "namespace" => preg_replace('/(\\\|\/)/', '', $module), |
365 | 365 | )); |
366 | 366 | return $this->writeTemplateToFile($buildProperties, |
367 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.php", |
|
367 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.php", |
|
368 | 368 | $force); |
369 | 369 | } |
370 | 370 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | "module" => $module, |
383 | 383 | )); |
384 | 384 | return $this->writeTemplateToFile($index, |
385 | - $modPath . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", |
|
385 | + $modPath.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", |
|
386 | 386 | $force); |
387 | 387 | } |
388 | 388 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | )); |
413 | 413 | |
414 | 414 | return $this->writeTemplateToFile($controller, |
415 | - $modPath . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
415 | + $modPath.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | "package" => $package, |
438 | 438 | )); |
439 | 439 | |
440 | - return $this->writeTemplateToFile($controller, $modPath . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
440 | + return $this->writeTemplateToFile($controller, $modPath.DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | $base = $dir->path; |
455 | 455 | while ($file = $dir->read()) { |
456 | 456 | if (!in_array(strtolower($file), ['.', '..', 'base', 'map'])) { |
457 | - if (is_dir($base . DIRECTORY_SEPARATOR . $file)) { |
|
458 | - $this->generateApiFiles($module, $force, $apiClass, dir($base . DIRECTORY_SEPARATOR . $file), $apiPath . DIRECTORY_SEPARATOR . $file, $file); |
|
459 | - } else if (!preg_match('/Query\.php$/i', $file) |
|
457 | + if (is_dir($base.DIRECTORY_SEPARATOR.$file)) { |
|
458 | + $this->generateApiFiles($module, $force, $apiClass, dir($base.DIRECTORY_SEPARATOR.$file), $apiPath.DIRECTORY_SEPARATOR.$file, $file); |
|
459 | + }else if (!preg_match('/Query\.php$/i', $file) |
|
460 | 460 | && !preg_match('/I18n\.php$/i', $file) |
461 | 461 | && preg_match('/\.php$/i', $file) |
462 | 462 | ) { |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | $parts[] = $package; |
486 | 486 | } |
487 | 487 | $parts[] = $filename; |
488 | - $namespace = '\\' . implode('\\', $parts); |
|
488 | + $namespace = '\\'.implode('\\', $parts); |
|
489 | 489 | $reflectorClass = new \ReflectionClass($namespace); |
490 | 490 | $isModel = $reflectorClass->isInstantiable(); |
491 | 491 | return $isModel; |