@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | { |
21 | 21 | Inspector::stats('[RouterHelper] Getting class to call for executing the request action', Inspector::SCOPE_DEBUG); |
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 | $reflectionClass = new \ReflectionClass($actionClass); |
25 | - if($reflectionClass->hasMethod('getInstance')) { |
|
25 | + if ($reflectionClass->hasMethod('getInstance')) { |
|
26 | 26 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
27 | - } else { |
|
27 | + }else { |
|
28 | 28 | $class = new $actionClass; |
29 | 29 | } |
30 | 30 | return $class; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $expr = preg_quote($expr, '/'); |
114 | 114 | $expr = str_replace('###', '(.*)', $expr); |
115 | 115 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
116 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
116 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
117 | 117 | return $matched; |
118 | 118 | } |
119 | 119 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
126 | 126 | { |
127 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
127 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
128 | 128 | $templatesPath = 'templates'; |
129 | 129 | $publicPath = 'public'; |
130 | 130 | $modelsPath = 'models'; |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | $modelsPath = ucfirst($modelsPath); |
135 | 135 | } |
136 | 136 | if ($class->hasConstant('TPL')) { |
137 | - $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL'); |
|
137 | + $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL'); |
|
138 | 138 | } |
139 | 139 | return [ |
140 | 140 | 'base' => $path, |
141 | - 'template' => $path . $templatesPath, |
|
142 | - 'model' => $path . $modelsPath, |
|
143 | - 'public' => $path . $publicPath, |
|
141 | + 'template' => $path.$templatesPath, |
|
142 | + 'model' => $path.$modelsPath, |
|
143 | + 'public' => $path.$publicPath, |
|
144 | 144 | ]; |
145 | 145 | } |
146 | 146 | |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | foreach ($parameters as $param) { |
165 | 165 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
166 | 166 | $params[$param->getName()] = $param->getDefaultValue(); |
167 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
168 | - } elseif(!$param->isOptional()) { |
|
167 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
168 | + } elseif (!$param->isOptional()) { |
|
169 | 169 | $requirements[] = $param->getName(); |
170 | 170 | } |
171 | 171 | } |
172 | - } else { |
|
172 | + }else { |
|
173 | 173 | $default = $regex; |
174 | 174 | } |
175 | 175 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $httpMethod = self::extractReflectionHttpMethod($docComments); |
266 | 266 | $icon = self::extractDocIcon($docComments); |
267 | 267 | $label = self::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
268 | - $route = $httpMethod . "#|#" . $regex; |
|
268 | + $route = $httpMethod."#|#".$regex; |
|
269 | 269 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
270 | 270 | $info = [ |
271 | 271 | 'method' => $method->getName(), |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | GeneratorHelper::createDir(dirname($path)); |
57 | 57 | if (false === FileHelper::writeFile($path, $data)) { |
58 | - throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ') . $path); |
|
58 | + throw new ConfigException(t('No se tienen los permisos suficientes para escribir en el fichero ').$path); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | Inspector::stats('[Cache] Gathering data from cache', Inspector::SCOPE_DEBUG); |
71 | 71 | $data = null; |
72 | - $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
72 | + $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
73 | 73 | if (file_exists($absolutePath)) { |
74 | 74 | $data = FileHelper::readFile($absolutePath); |
75 | 75 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
86 | 86 | { |
87 | 87 | Inspector::stats('[Cache] Checking expiration', Inspector::SCOPE_DEBUG); |
88 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
88 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
89 | 89 | $lasModificationDate = filemtime($absolutePath); |
90 | 90 | return ($lasModificationDate + $expires <= time()); |
91 | 91 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | { |
153 | 153 | Inspector::stats('[Cache] Store data in cache', Inspector::SCOPE_DEBUG); |
154 | 154 | $data = self::transformData($data, $transform); |
155 | - $absolutePath = $absolute ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
155 | + $absolutePath = $absolute ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
156 | 156 | $this->saveTextToFile($data, $absolutePath); |
157 | 157 | } |
158 | 158 | |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | public function readFromCache($path, $expires = 300, $function = null, $transform = Cache::TEXT) |
169 | 169 | { |
170 | 170 | $data = null; |
171 | - Inspector::stats('[Cache] Reading data from cache: ' . json_encode(['path' => $path]), Inspector::SCOPE_DEBUG); |
|
172 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
171 | + Inspector::stats('[Cache] Reading data from cache: '.json_encode(['path' => $path]), Inspector::SCOPE_DEBUG); |
|
172 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
173 | 173 | if (is_callable($function) && $this->hasExpiredCache($path, $expires)) { |
174 | 174 | $data = $function(); |
175 | 175 | $this->storeData($path, $data, $transform, false, $expires); |
176 | - } else { |
|
176 | + }else { |
|
177 | 177 | $data = $this->getDataFromFile($path, $transform); |
178 | 178 | } |
179 | 179 | } |
@@ -219,20 +219,20 @@ discard block |
||
219 | 219 | $query[Api::HEADER_API_LANG] = Request::header(Api::HEADER_API_LANG, 'es'); |
220 | 220 | $filename = FileHelper::generateHashFilename($action['http'], $action['slug'], $query); |
221 | 221 | $hashPath = FileHelper::generateCachePath($action, $query); |
222 | - Inspector::stats('[Cache] Cache file calculated: ' . json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG); |
|
222 | + Inspector::stats('[Cache] Cache file calculated: '.json_encode(['file' => $filename, 'hash' => $hashPath]), Inspector::SCOPE_DEBUG); |
|
223 | 223 | Logger::log('Cache file calculated', LOG_DEBUG, ['file' => $filename, 'hash' => $hashPath]); |
224 | 224 | } |
225 | 225 | return [$hashPath, $filename]; |
226 | 226 | } |
227 | 227 | |
228 | 228 | public function flushCache() { |
229 | - if(Config::getParam('cache.data.enable', false)) { |
|
229 | + if (Config::getParam('cache.data.enable', false)) { |
|
230 | 230 | Inspector::stats('[Cache] Flushing cache', Inspector::SCOPE_DEBUG); |
231 | 231 | $action = Security::getInstance()->getSessionKey(self::CACHE_SESSION_VAR); |
232 | - if(is_array($action)) { |
|
233 | - $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
234 | - if(!file_exists($hashPath)) { |
|
235 | - $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath; |
|
232 | + if (is_array($action)) { |
|
233 | + $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
234 | + if (!file_exists($hashPath)) { |
|
235 | + $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath; |
|
236 | 236 | } |
237 | 237 | FileHelper::deleteDir($hashPath); |
238 | 238 | } |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function init() |
77 | 77 | { |
78 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
78 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
79 | 79 | if (empty($this->routing) || Config::getParam('debug', true)) { |
80 | 80 | $this->debugLoad(); |
81 | - } else { |
|
82 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
81 | + }else { |
|
82 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
83 | 83 | } |
84 | 84 | $this->checkExternalModules(false); |
85 | 85 | $this->setLoaded(); |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | $notFoundRoute = Config::getParam('route.404'); |
120 | - if(null !== $notFoundRoute) { |
|
120 | + if (null !== $notFoundRoute) { |
|
121 | 121 | Request::getInstance()->redirect($this->getRoute($notFoundRoute, true)); |
122 | - } else { |
|
122 | + }else { |
|
123 | 123 | return $template->render('error.html.twig', array( |
124 | 124 | 'exception' => $exception, |
125 | 125 | 'trace' => $exception->getTraceAsString(), |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | try { |
171 | 171 | //Search action and execute |
172 | 172 | return $this->searchAction($route); |
173 | - } catch (AccessDeniedException $e) { |
|
174 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
173 | + }catch (AccessDeniedException $e) { |
|
174 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
175 | 175 | return Admin::staticAdminLogon($route); |
176 | - } catch (RouterException $r) { |
|
176 | + }catch (RouterException $r) { |
|
177 | 177 | Logger::log($r->getMessage(), LOG_WARNING); |
178 | - } catch (\Exception $e) { |
|
178 | + }catch (\Exception $e) { |
|
179 | 179 | Logger::log($e->getMessage(), LOG_ERR); |
180 | 180 | throw $e; |
181 | 181 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function searchAction($route) |
195 | 195 | { |
196 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
196 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
197 | 197 | //Revisamos si tenemos la ruta registrada |
198 | 198 | $parts = parse_url($route); |
199 | 199 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | /** @var $class \PSFS\base\types\Controller */ |
209 | 209 | $class = RouterHelper::getClassToCall($action); |
210 | 210 | try { |
211 | - if($this->checkRequirements($action, $get)) { |
|
211 | + if ($this->checkRequirements($action, $get)) { |
|
212 | 212 | return $this->executeCachedRoute($route, $action, $class, $get); |
213 | - } else { |
|
213 | + }else { |
|
214 | 214 | throw new RouterException(t('La ruta no es válida'), 400); |
215 | 215 | } |
216 | - } catch (\Exception $e) { |
|
216 | + }catch (\Exception $e) { |
|
217 | 217 | Logger::log($e->getMessage(), LOG_ERR); |
218 | 218 | throw $e; |
219 | 219 | } |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | */ |
230 | 230 | private function checkRequirements(array $action, $params = []) { |
231 | 231 | Inspector::stats('[Router] Checking request requirements', Inspector::SCOPE_DEBUG); |
232 | - if(!empty($params) && !empty($action['requirements'])) { |
|
232 | + if (!empty($params) && !empty($action['requirements'])) { |
|
233 | 233 | $checked = 0; |
234 | - foreach(array_keys($params) as $key) { |
|
235 | - if(in_array($key, $action['requirements'], true)) { |
|
234 | + foreach (array_keys($params) as $key) { |
|
235 | + if (in_array($key, $action['requirements'], true)) { |
|
236 | 236 | $checked++; |
237 | 237 | } |
238 | 238 | } |
239 | 239 | $valid = count($action['requirements']) === $checked; |
240 | - } else { |
|
240 | + }else { |
|
241 | 241 | $valid = true; |
242 | 242 | } |
243 | 243 | return $valid; |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | $this->checkExternalModules(); |
288 | 288 | if (file_exists($modulesPath)) { |
289 | 289 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
290 | - if($modules->hasResults()) { |
|
290 | + if ($modules->hasResults()) { |
|
291 | 291 | foreach ($modules->getIterator() as $modulePath) { |
292 | 292 | $module = $modulePath->getBasename(); |
293 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
293 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | } |
297 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
297 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $home_params = NULL; |
311 | 311 | foreach ($this->routing as $pattern => $params) { |
312 | 312 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
313 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
313 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
314 | 314 | $home_params = $params; |
315 | 315 | } |
316 | 316 | unset($method); |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | private function inspectDir($origen, $namespace = 'PSFS', $routing = []) |
333 | 333 | { |
334 | 334 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name('*.php'); |
335 | - if($files->hasResults()) { |
|
335 | + if ($files->hasResults()) { |
|
336 | 336 | foreach ($files->getIterator() as $file) { |
337 | - if($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) { |
|
338 | - $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
339 | - } else { |
|
337 | + if ($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) { |
|
338 | + $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
339 | + }else { |
|
340 | 340 | $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname())); |
341 | 341 | } |
342 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
342 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | $this->finder = new Finder(); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | private function addRouting($namespace, &$routing, $module = 'PSFS') |
369 | 369 | { |
370 | 370 | if (self::exists($namespace)) { |
371 | - if(I18nHelper::checkI18Class($namespace)) { |
|
371 | + if (I18nHelper::checkI18Class($namespace)) { |
|
372 | 372 | return $routing; |
373 | 373 | } |
374 | 374 | $reflection = new \ReflectionClass($namespace); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | if (!$this->domains) { |
411 | 411 | $this->domains = []; |
412 | 412 | } |
413 | - $domain = '@' . $class->getConstant('DOMAIN') . '/'; |
|
413 | + $domain = '@'.$class->getConstant('DOMAIN').'/'; |
|
414 | 414 | if (!array_key_exists($domain, $this->domains)) { |
415 | 415 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
416 | 416 | } |
@@ -426,11 +426,11 @@ discard block |
||
426 | 426 | */ |
427 | 427 | public function simpatize() |
428 | 428 | { |
429 | - $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php'; |
|
430 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
429 | + $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php'; |
|
430 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
431 | 431 | $this->generateSlugs($absoluteTranslationFileName); |
432 | 432 | GeneratorHelper::createDir(CONFIG_DIR); |
433 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
433 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
434 | 434 | |
435 | 435 | return $this; |
436 | 436 | } |
@@ -446,18 +446,18 @@ discard block |
||
446 | 446 | public function getRoute($slug = '', $absolute = FALSE, array $params = []) |
447 | 447 | { |
448 | 448 | if ('' === $slug) { |
449 | - return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
449 | + return $absolute ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
450 | 450 | } |
451 | 451 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
452 | 452 | throw new RouterException(t('No existe la ruta especificada')); |
453 | 453 | } |
454 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
454 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
455 | 455 | if (!empty($params)) { |
456 | 456 | foreach ($params as $key => $value) { |
457 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
457 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
458 | 458 | } |
459 | 459 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
460 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
460 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -476,15 +476,15 @@ discard block |
||
476 | 476 | * @param string $method |
477 | 477 | */ |
478 | 478 | private function checkPreActions($class, $method) { |
479 | - $preAction = 'pre' . ucfirst($method); |
|
480 | - if(method_exists($class, $preAction)) { |
|
479 | + $preAction = 'pre'.ucfirst($method); |
|
480 | + if (method_exists($class, $preAction)) { |
|
481 | 481 | Inspector::stats('[Router] Pre action invoked', Inspector::SCOPE_DEBUG); |
482 | 482 | try { |
483 | - if(false === call_user_func_array([$class, $preAction])) { |
|
483 | + if (false === call_user_func_array([$class, $preAction])) { |
|
484 | 484 | Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]); |
485 | 485 | error_clear_last(); |
486 | 486 | } |
487 | - } catch (\Exception $e) { |
|
487 | + }catch (\Exception $e) { |
|
488 | 488 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
489 | 489 | } |
490 | 490 | } |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | */ |
502 | 502 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
503 | 503 | { |
504 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
504 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
505 | 505 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
506 | 506 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
507 | 507 | $cache = Cache::needCache(); |
@@ -509,15 +509,15 @@ discard block |
||
509 | 509 | $return = null; |
510 | 510 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
511 | 511 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
512 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
512 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
513 | 513 | if (NULL !== $cachedData) { |
514 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
514 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
515 | 515 | Template::getInstance()->renderCache($cachedData, $headers); |
516 | 516 | $execute = FALSE; |
517 | 517 | } |
518 | 518 | } |
519 | 519 | if ($execute) { |
520 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
520 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
521 | 521 | $this->checkPreActions($class, $action['method']); |
522 | 522 | $return = call_user_func_array([$class, $action['method']], $params); |
523 | 523 | if (false === $return) { |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath) |
557 | 557 | { |
558 | 558 | $extModule = $modulePath->getBasename(); |
559 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
560 | - if(file_exists($moduleAutoloader)) { |
|
559 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
560 | + if (file_exists($moduleAutoloader)) { |
|
561 | 561 | include_once $moduleAutoloader; |
562 | 562 | if ($hydrateRoute) { |
563 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
563 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | } |
@@ -574,16 +574,16 @@ discard block |
||
574 | 574 | { |
575 | 575 | try { |
576 | 576 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
577 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
578 | - if(file_exists($externalModulePath)) { |
|
577 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
578 | + if (file_exists($externalModulePath)) { |
|
579 | 579 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
580 | - if($externalModule->hasResults()) { |
|
580 | + if ($externalModule->hasResults()) { |
|
581 | 581 | foreach ($externalModule->getIterator() as $modulePath) { |
582 | 582 | $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath); |
583 | 583 | } |
584 | 584 | } |
585 | 585 | } |
586 | - } catch (\Exception $e) { |
|
586 | + }catch (\Exception $e) { |
|
587 | 587 | Logger::log($e->getMessage(), LOG_WARNING); |
588 | 588 | $module = null; |
589 | 589 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function init() |
87 | 87 | { |
88 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) { |
|
88 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) { |
|
89 | 89 | $this->loadConfigData(); |
90 | 90 | } |
91 | 91 | return $this; |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | $finalData = array_filter($finalData, function($key, $value) { |
202 | 202 | return in_array($key, self::$required, true) || !empty($value); |
203 | 203 | }, ARRAY_FILTER_USE_BOTH); |
204 | - $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT))); |
|
204 | + $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT))); |
|
205 | 205 | self::getInstance()->loadConfigData(); |
206 | 206 | $saved = true; |
207 | - } catch (ConfigException $e) { |
|
207 | + }catch (ConfigException $e) { |
|
208 | 208 | Logger::log($e->getMessage(), LOG_ERR); |
209 | 209 | } |
210 | 210 | return $saved; |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function loadConfigData() |
238 | 238 | { |
239 | - $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: []; |
|
239 | + $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: []; |
|
240 | 240 | $this->debug = array_key_exists('debug', $this->config) ? (bool)$this->config['debug'] : FALSE; |
241 | - if(array_key_exists('cache.var', $this->config)) { |
|
241 | + if (array_key_exists('cache.var', $this->config)) { |
|
242 | 242 | Security::getInstance()->setSessionKey('config.cache.var', $this->config['cache.var']); |
243 | 243 | } |
244 | 244 | } |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public static function getParam($key, $defaultValue = null, $module = null) |
262 | 262 | { |
263 | - if(null !== $module) { |
|
264 | - return self::getParam(strtolower($module) . '.' . $key, self::getParam($key, $defaultValue)); |
|
263 | + if (null !== $module) { |
|
264 | + return self::getParam(strtolower($module).'.'.$key, self::getParam($key, $defaultValue)); |
|
265 | 265 | } |
266 | 266 | $param = self::getInstance()->get($key); |
267 | 267 | return (null !== $param) ? $param : $defaultValue; |
@@ -50,34 +50,34 @@ discard block |
||
50 | 50 | $session = Security::getInstance(); |
51 | 51 | self::$locale = I18nHelper::extractLocale($session->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY)); |
52 | 52 | $version = $session->getSessionKey(self::LOCALE_CACHED_VERSION); |
53 | - $configVersion = self::$locale . '_' . Config::getParam('cache.var', 'v1'); |
|
53 | + $configVersion = self::$locale.'_'.Config::getParam('cache.var', 'v1'); |
|
54 | 54 | if ($forceReload) { |
55 | 55 | self::dropInstance(); |
56 | 56 | $version = null; |
57 | 57 | self::$translations = []; |
58 | 58 | } |
59 | - if(count(self::$translations) === 0) { |
|
59 | + if (count(self::$translations) === 0) { |
|
60 | 60 | self::$generate = (boolean)Config::getParam('i18n.autogenerate', false); |
61 | - if(null !== $version && $version === $configVersion) { |
|
61 | + if (null !== $version && $version === $configVersion) { |
|
62 | 62 | self::$translations = $session->getSessionKey(self::LOCALE_CACHED_TAG); |
63 | - } else { |
|
63 | + }else { |
|
64 | 64 | if (!$useBase) { |
65 | 65 | $customKey = $customKey ?: $session->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY); |
66 | 66 | } |
67 | 67 | // Gather always the base translations |
68 | 68 | $standardTranslations = []; |
69 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']); |
|
70 | - if(file_exists(self::$filename)) { |
|
69 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']); |
|
70 | + if (file_exists(self::$filename)) { |
|
71 | 71 | $standardTranslations = json_decode(file_get_contents(self::$filename), true); |
72 | 72 | } |
73 | 73 | // If the project has custom translations, gather them |
74 | 74 | if (null !== $customKey) { |
75 | - Logger::log('[' . self::class . '] Custom key detected: ' . $customKey, LOG_INFO); |
|
76 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale . '.json']); |
|
75 | + Logger::log('['.self::class.'] Custom key detected: '.$customKey, LOG_INFO); |
|
76 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale.'.json']); |
|
77 | 77 | } |
78 | 78 | // Finally we merge base and custom translations to complete all the i18n set |
79 | 79 | if (file_exists(self::$filename)) { |
80 | - Logger::log('[' . self::class . '] Custom locale detected: ' . $customKey . ' [' . self::$locale . ']', LOG_INFO); |
|
80 | + Logger::log('['.self::class.'] Custom locale detected: '.$customKey.' ['.self::$locale.']', LOG_INFO); |
|
81 | 81 | self::$translations = array_merge($standardTranslations, json_decode(file_get_contents(self::$filename), true)); |
82 | 82 | $session->setSessionKey(self::LOCALE_CACHED_TAG, self::$translations); |
83 | 83 | $session->setSessionKey(self::LOCALE_CACHED_VERSION, $configVersion); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public function getFilters() |
103 | 103 | { |
104 | 104 | return array( |
105 | - new TwigFilter('trans', function ($message) { |
|
105 | + new TwigFilter('trans', function($message) { |
|
106 | 106 | return self::_($message); |
107 | 107 | }), |
108 | 108 | ); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | self::checkLoad($customKey, $forceReload); |
128 | 128 | if (is_array(self::$translations) && array_key_exists($message, self::$translations)) { |
129 | 129 | $translation = self::$translations[$message]; |
130 | - } else { |
|
130 | + }else { |
|
131 | 131 | $translation = gettext($message); |
132 | 132 | } |
133 | 133 | if (self::$generate) { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $mappedColumn = $tableMap->getColumnByPhpName($field); |
36 | 36 | $required = $mappedColumn->isNotNull() && null === $mappedColumn->getDefaultValue(); |
37 | 37 | $fDto = self::parseFieldType($domain, $field, $behaviors, $mappedColumn, $required); |
38 | - if(null !== $fDto) { |
|
38 | + if (null !== $fDto) { |
|
39 | 39 | self::checkPrimaryKey($fDto, $mappedColumn); |
40 | 40 | self::applyCaseToNames($fDto, $mappedColumn); |
41 | 41 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | { |
152 | 152 | if ($mappedColumn->getSize() > 100) { |
153 | 153 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
154 | - } else { |
|
154 | + }else { |
|
155 | 155 | $fDto = self::generateStringField($field, $required); |
156 | 156 | } |
157 | 157 | return $fDto; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public static function header($name, $default = null) |
140 | 140 | { |
141 | - return self::getInstance()->getHeader($name, $default); |
|
141 | + return self::getInstance()->getHeader($name, $default); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | $header = null; |
152 | 152 | if ($this->hasHeader($name)) { |
153 | 153 | $header = $this->header[$name]; |
154 | - } else if(array_key_exists('h_' . strtolower($name), $this->query)) { |
|
155 | - $header = $this->query['h_' . strtolower($name)]; |
|
156 | - } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
157 | - $header = $this->server['HTTP_' . strtoupper(str_replace('-', '_', $name))]; |
|
154 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
155 | + $header = $this->query['h_'.strtolower($name)]; |
|
156 | + }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
157 | + $header = $this->server['HTTP_'.strtoupper(str_replace('-', '_', $name))]; |
|
158 | 158 | } |
159 | 159 | return $header ?: $default; |
160 | 160 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $url = $this->getServer('HTTP_ORIGIN'); |
254 | 254 | } |
255 | 255 | ob_start(); |
256 | - header('Location: ' . $url); |
|
256 | + header('Location: '.$url); |
|
257 | 257 | ob_end_clean(); |
258 | 258 | Security::getInstance()->updateSession(); |
259 | 259 | exit(t('Redireccionando...')); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $url = $this->getServerName(); |
300 | 300 | $protocol = $hasProtocol ? $this->getProtocol() : ''; |
301 | 301 | if (!empty($protocol)) { |
302 | - $url = $protocol . $url; |
|
302 | + $url = $protocol.$url; |
|
303 | 303 | } |
304 | 304 | $url = $this->checkServerPort($url); |
305 | 305 | return $url; |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | { |
346 | 346 | $port = (integer)$this->getServer('SERVER_PORT'); |
347 | 347 | $host = $this->getServer('HTTP_HOST'); |
348 | - if(!empty($host)) { |
|
348 | + if (!empty($host)) { |
|
349 | 349 | $parts = explode(':', $host); |
350 | 350 | $hostPort = (integer)end($parts); |
351 | - if(count($parts) > 1 && $hostPort !== $port) { |
|
351 | + if (count($parts) > 1 && $hostPort !== $port) { |
|
352 | 352 | $port = $hostPort; |
353 | 353 | } |
354 | 354 | } |
355 | 355 | if (!in_array($port, [80, 443], true)) { |
356 | - $url .= ':' . $port; |
|
356 | + $url .= ':'.$port; |
|
357 | 357 | } |
358 | 358 | return $url; |
359 | 359 | } |
@@ -39,24 +39,24 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function findTranslations($path, $locale) |
41 | 41 | { |
42 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
43 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
42 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
43 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
44 | 44 | |
45 | 45 | $translations = array(); |
46 | 46 | if (file_exists($path)) { |
47 | 47 | $d = dir($path); |
48 | 48 | while (false !== ($dir = $d->read())) { |
49 | 49 | GeneratorHelper::createDir($localePath); |
50 | - if (!file_exists($localePath . 'translations.po')) { |
|
51 | - file_put_contents($localePath . 'translations.po', ''); |
|
50 | + if (!file_exists($localePath.'translations.po')) { |
|
51 | + file_put_contents($localePath.'translations.po', ''); |
|
52 | 52 | } |
53 | - $inspect_path = realpath($path . DIRECTORY_SEPARATOR . $dir); |
|
54 | - $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext " . |
|
55 | - $inspect_path . DIRECTORY_SEPARATOR . |
|
53 | + $inspect_path = realpath($path.DIRECTORY_SEPARATOR.$dir); |
|
54 | + $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ". |
|
55 | + $inspect_path.DIRECTORY_SEPARATOR. |
|
56 | 56 | "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po"; |
57 | - if (is_dir($path . DIRECTORY_SEPARATOR . $dir) && preg_match('/^\./', $dir) == 0) { |
|
58 | - $res = t('Revisando directorio: ') . $inspect_path; |
|
59 | - $res .= t('Comando ejecutado: ') . $cmd_php; |
|
57 | + if (is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./', $dir) == 0) { |
|
58 | + $res = t('Revisando directorio: ').$inspect_path; |
|
59 | + $res .= t('Comando ejecutado: ').$cmd_php; |
|
60 | 60 | $res .= shell_exec($cmd_php); |
61 | 61 | usleep(10); |
62 | 62 | $translations[] = $res; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function createStructureModule($module, $force = false, $type = "", $apiClass = "") |
79 | 79 | { |
80 | - $mod_path = CORE_DIR . DIRECTORY_SEPARATOR; |
|
80 | + $mod_path = CORE_DIR.DIRECTORY_SEPARATOR; |
|
81 | 81 | $module = ucfirst($module); |
82 | 82 | $this->createModulePath($module, $mod_path); |
83 | 83 | $this->createModulePathTree($module, $mod_path); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // Creates the src folder |
99 | 99 | GeneratorHelper::createDir($mod_path); |
100 | 100 | // Create module path |
101 | - GeneratorHelper::createDir($mod_path . $module); |
|
101 | + GeneratorHelper::createDir($mod_path.$module); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | $this->log->addLog("Generamos la estructura"); |
114 | 114 | $paths = [ |
115 | 115 | "Api", "Config", "Controller", "Models", "Public", "Templates", "Services", "Test", "Doc", |
116 | - "Locale", "Locale/" . Config::getParam('default.locale', 'es_ES'), "Locale/" . Config::getParam('default.locale', 'es_ES') . "/LC_MESSAGES" |
|
116 | + "Locale", "Locale/".Config::getParam('default.locale', 'es_ES'), "Locale/".Config::getParam('default.locale', 'es_ES')."/LC_MESSAGES" |
|
117 | 117 | ]; |
118 | - $module_path = $mod_path . $module; |
|
118 | + $module_path = $mod_path.$module; |
|
119 | 119 | foreach ($paths as $path) { |
120 | - GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . $path); |
|
120 | + GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR.$path); |
|
121 | 121 | } |
122 | 122 | //Creamos las carpetas de los assets |
123 | 123 | $htmlPaths = array("css", "js", "img", "media", "font"); |
124 | 124 | foreach ($htmlPaths as $path) { |
125 | - GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path); |
|
125 | + GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | private function createModuleBaseFiles($module, $mod_path, $force = false, $controllerType = '') |
137 | 137 | { |
138 | - $module_path = $mod_path . $module; |
|
138 | + $module_path = $mod_path.$module; |
|
139 | 139 | $this->generateControllerTemplate($module, $module_path, $force, $controllerType); |
140 | 140 | $this->generateServiceTemplate($module, $module_path, $force); |
141 | 141 | $this->genereateAutoloaderTemplate($module, $module_path, $force); |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | private function createModuleModels($module, $path) |
155 | 155 | { |
156 | - $module_path = $path . $module; |
|
157 | - $module_path = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $module_path); |
|
156 | + $module_path = $path.$module; |
|
157 | + $module_path = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $module_path); |
|
158 | 158 | |
159 | 159 | $configGenerator = $this->getConfigGenerator($module_path); |
160 | 160 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | $configTemplate = $this->tpl->dump("generator/config.propel.template.twig", array( |
165 | 165 | "module" => $module, |
166 | 166 | )); |
167 | - $this->writeTemplateToFile($configTemplate, CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config" . |
|
168 | - DIRECTORY_SEPARATOR . "config.php", true); |
|
167 | + $this->writeTemplateToFile($configTemplate, CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config". |
|
168 | + DIRECTORY_SEPARATOR."config.php", true); |
|
169 | 169 | $this->log->addLog("Generado config genérico para propel"); |
170 | 170 | } |
171 | 171 | |
@@ -187,28 +187,28 @@ discard block |
||
187 | 187 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
188 | 188 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
189 | 189 | "class" => $class, |
190 | - "controllerType" => $class . "Base", |
|
190 | + "controllerType" => $class."Base", |
|
191 | 191 | "is_base" => false |
192 | 192 | )); |
193 | - $controller = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" . |
|
194 | - DIRECTORY_SEPARATOR . "{$class}Controller.php", $force); |
|
193 | + $controller = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller". |
|
194 | + DIRECTORY_SEPARATOR."{$class}Controller.php", $force); |
|
195 | 195 | |
196 | 196 | $controllerBody = $this->tpl->dump("generator/controller.template.twig", array( |
197 | 197 | "module" => $module, |
198 | 198 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
199 | 199 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
200 | - "class" => $class . "Base", |
|
200 | + "class" => $class."Base", |
|
201 | 201 | "service" => $class, |
202 | 202 | "controllerType" => $controllerType, |
203 | 203 | "is_base" => true, |
204 | 204 | "domain" => $class, |
205 | 205 | )); |
206 | - $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" . |
|
207 | - DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true); |
|
206 | + $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller". |
|
207 | + DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true); |
|
208 | 208 | |
209 | - $filename = $mod_path . DIRECTORY_SEPARATOR . "Test" . DIRECTORY_SEPARATOR . "{$class}Test.php"; |
|
209 | + $filename = $mod_path.DIRECTORY_SEPARATOR."Test".DIRECTORY_SEPARATOR."{$class}Test.php"; |
|
210 | 210 | $test = true; |
211 | - if(!file_exists($filename)) { |
|
211 | + if (!file_exists($filename)) { |
|
212 | 212 | $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array( |
213 | 213 | "module" => $module, |
214 | 214 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | private function generateBaseApiTemplate($module, $modPath, $force = false, $apiClass = "") |
230 | 230 | { |
231 | 231 | $created = true; |
232 | - $modelPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
233 | - $apiPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Api'; |
|
232 | + $modelPath = $modPath.$module.DIRECTORY_SEPARATOR.'Models'; |
|
233 | + $apiPath = $modPath.$module.DIRECTORY_SEPARATOR.'Api'; |
|
234 | 234 | if (file_exists($modelPath)) { |
235 | 235 | $dir = dir($modelPath); |
236 | 236 | $this->generateApiFiles($module, $force, $apiClass, $dir, $apiPath); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | //Generamos el fichero de configuración |
249 | 249 | $this->log->addLog("Generamos fichero vacío de configuración"); |
250 | 250 | return $this->writeTemplateToFile("<?php\n\t", |
251 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", |
|
251 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", |
|
252 | 252 | $force); |
253 | 253 | } |
254 | 254 | |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | //Generamos el fichero de configuración |
264 | 264 | $this->log->addLog("Generamos ficheros para assets base"); |
265 | 265 | $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", |
266 | - $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", |
|
266 | + $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", |
|
267 | 267 | $force); |
268 | 268 | $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", |
269 | - $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", |
|
269 | + $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", |
|
270 | 270 | $force); |
271 | 271 | return ($css && $js); |
272 | 272 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | "class" => $class, |
289 | 289 | )); |
290 | 290 | return $this->writeTemplateToFile($controller, |
291 | - $mod_path . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php", |
|
291 | + $mod_path.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php", |
|
292 | 292 | $force); |
293 | 293 | } |
294 | 294 | |
@@ -307,13 +307,13 @@ discard block |
||
307 | 307 | "autoloader" => preg_replace('/(\\\|\/)/', '_', $module), |
308 | 308 | "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module), |
309 | 309 | )); |
310 | - $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force); |
|
310 | + $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force); |
|
311 | 311 | |
312 | 312 | $this->log->addLog("Generamos el phpunit"); |
313 | 313 | $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array( |
314 | 314 | "module" => $module, |
315 | 315 | )); |
316 | - $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force); |
|
316 | + $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force); |
|
317 | 317 | return $autoload && $phpunit; |
318 | 318 | } |
319 | 319 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | "db" => $this->config->get("db_name"), |
335 | 335 | )); |
336 | 336 | return $this->writeTemplateToFile($schema, |
337 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", |
|
337 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", |
|
338 | 338 | $force); |
339 | 339 | } |
340 | 340 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | "namespace" => preg_replace('/(\\\|\/)/', '', $module), |
353 | 353 | )); |
354 | 354 | return $this->writeTemplateToFile($build_properties, |
355 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml", |
|
355 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml", |
|
356 | 356 | $force); |
357 | 357 | } |
358 | 358 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | "module" => $module, |
371 | 371 | )); |
372 | 372 | return $this->writeTemplateToFile($index, |
373 | - $mod_path . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", |
|
373 | + $mod_path.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", |
|
374 | 374 | $force); |
375 | 375 | } |
376 | 376 | |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | try { |
389 | 389 | $this->cache->storeData($filename, $fileContent, Cache::TEXT, true); |
390 | 390 | $created = true; |
391 | - } catch (\Exception $e) { |
|
391 | + }catch (\Exception $e) { |
|
392 | 392 | Logger::log($e->getMessage(), LOG_ERR); |
393 | 393 | } |
394 | - } else { |
|
395 | - Logger::log($filename . t(' not exists or cant write'), LOG_ERR); |
|
394 | + }else { |
|
395 | + Logger::log($filename.t(' not exists or cant write'), LOG_ERR); |
|
396 | 396 | } |
397 | 397 | return $created; |
398 | 398 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | )); |
424 | 424 | |
425 | 425 | return $this->writeTemplateToFile($controller, |
426 | - $mod_path . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
426 | + $mod_path.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | "package" => $package, |
449 | 449 | )); |
450 | 450 | |
451 | - return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
451 | + return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -462,12 +462,12 @@ discard block |
||
462 | 462 | { |
463 | 463 | if (file_exists($filename_path)) { |
464 | 464 | $destfolder = basename($filename_path); |
465 | - if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) { |
|
465 | + if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) { |
|
466 | 466 | if (is_dir($filename_path)) { |
467 | - self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
468 | - } else { |
|
469 | - if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) { |
|
470 | - throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
467 | + self::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
468 | + }else { |
|
469 | + if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) { |
|
470 | + throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | GeneratorHelper::createDir($dst); |
487 | 487 | while (false !== ($file = readdir($dir))) { |
488 | 488 | if (($file != '.') && ($file != '..')) { |
489 | - if (is_dir($src . '/' . $file)) { |
|
490 | - self::copyr($src . '/' . $file, $dst . '/' . $file); |
|
491 | - } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) { |
|
492 | - throw new ConfigException("Can't copy " . $src . " to " . $dst); |
|
489 | + if (is_dir($src.'/'.$file)) { |
|
490 | + self::copyr($src.'/'.$file, $dst.'/'.$file); |
|
491 | + } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) { |
|
492 | + throw new ConfigException("Can't copy ".$src." to ".$dst); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | */ |
503 | 503 | private function getPropelPaths($module_path) |
504 | 504 | { |
505 | - $moduleDir = CORE_DIR . DIRECTORY_SEPARATOR . $module_path; |
|
505 | + $moduleDir = CORE_DIR.DIRECTORY_SEPARATOR.$module_path; |
|
506 | 506 | GeneratorHelper::createDir($moduleDir); |
507 | 507 | $moduleDir = realpath($moduleDir); |
508 | - $configDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config'; |
|
509 | - $sqlDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Sql'; |
|
510 | - $migrationDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Migrations'; |
|
508 | + $configDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'; |
|
509 | + $sqlDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Sql'; |
|
510 | + $migrationDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Migrations'; |
|
511 | 511 | $paths = [ |
512 | 512 | 'projectDir' => $moduleDir, |
513 | 513 | 'outputDir' => $moduleDir, |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | private function setupManager(GeneratorConfig $configGenerator, AbstractManager &$manager, $workingDir = CORE_DIR) |
573 | 573 | { |
574 | 574 | $manager->setGeneratorConfig($configGenerator); |
575 | - $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'] . DIRECTORY_SEPARATOR . 'schema.xml'); |
|
575 | + $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'].DIRECTORY_SEPARATOR.'schema.xml'); |
|
576 | 576 | $manager->setSchemas([$schemaFile]); |
577 | - $manager->setLoggerClosure(function ($message) { |
|
577 | + $manager->setLoggerClosure(function($message) { |
|
578 | 578 | Logger::log($message, LOG_INFO); |
579 | 579 | }); |
580 | 580 | $manager->setWorkingDirectory($workingDir); |
@@ -593,9 +593,9 @@ discard block |
||
593 | 593 | $base = $dir->path; |
594 | 594 | while ($file = $dir->read()) { |
595 | 595 | if (!in_array(strtolower($file), ['.', '..', 'base', 'map'])) { |
596 | - if (is_dir($base . DIRECTORY_SEPARATOR . $file)) { |
|
597 | - $this->generateApiFiles($module, $force, $apiClass, dir($base . DIRECTORY_SEPARATOR . $file), $apiPath . DIRECTORY_SEPARATOR . $file, $file); |
|
598 | - } else if (!preg_match('/Query\.php$/i', $file) |
|
596 | + if (is_dir($base.DIRECTORY_SEPARATOR.$file)) { |
|
597 | + $this->generateApiFiles($module, $force, $apiClass, dir($base.DIRECTORY_SEPARATOR.$file), $apiPath.DIRECTORY_SEPARATOR.$file, $file); |
|
598 | + }else if (!preg_match('/Query\.php$/i', $file) |
|
599 | 599 | && preg_match('/\.php$/i', $file) |
600 | 600 | ) { |
601 | 601 | $filename = str_replace(".php", "", $file); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | const TYPE_HTTP = 2; |
12 | 12 | |
13 | 13 | public static function parseRawData($type, $params) { |
14 | - switch($type) { |
|
14 | + switch ($type) { |
|
15 | 15 | default: |
16 | 16 | case self::TYPE_HTTP: |
17 | 17 | $parsedParams = http_build_query($params); |