@@ -54,10 +54,10 @@ |
||
| 54 | 54 | public function getServerName() |
| 55 | 55 | { |
| 56 | 56 | $serverName = $this->getServer('SERVER_NAME'); |
| 57 | - if(empty($serverName)) { |
|
| 57 | + if (empty($serverName)) { |
|
| 58 | 58 | $serverName = $this->getServer('HTTP_HOST'); |
| 59 | 59 | } |
| 60 | - if(str_contains($serverName ?? '', ':')) { |
|
| 60 | + if (str_contains($serverName ?? '', ':')) { |
|
| 61 | 61 | $pieces = explode(':', $serverName); |
| 62 | 62 | $serverName = $pieces[0]; |
| 63 | 63 | } |
@@ -33,10 +33,10 @@ |
||
| 33 | 33 | private function parseData($data) { |
| 34 | 34 | if ($data instanceof \Generator) { |
| 35 | 35 | $generatedData = []; |
| 36 | - foreach($data as $datum) { |
|
| 36 | + foreach ($data as $datum) { |
|
| 37 | 37 | $generatedData[] = $datum; |
| 38 | 38 | } |
| 39 | - } else { |
|
| 39 | + }else { |
|
| 40 | 40 | $generatedData = $data; |
| 41 | 41 | } |
| 42 | 42 | return $generatedData; |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | if (str_starts_with($class, 'PSFS\\')) { |
| 23 | 23 | $relativeClass = substr($class, strlen('PSFS\\')); |
| 24 | 24 | |
| 25 | - $file = SOURCE_DIR . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass) . '.php'; |
|
| 25 | + $file = SOURCE_DIR.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass).'.php'; |
|
| 26 | 26 | |
| 27 | 27 | if (file_exists($file)) { |
| 28 | 28 | require_once $file; |
| 29 | - } else if (class_exists('PSFS\\base\\Logger')) { |
|
| 29 | + }else if (class_exists('PSFS\\base\\Logger')) { |
|
| 30 | 30 | \PSFS\base\Logger::log("[Autoloader] Class $class not found at $file", LOG_WARNING); |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | // Registro automático del autoloader (puedes comentarlo si lo haces desde bootstrap) |
| 37 | 37 | if (!defined('SOURCE_DIR')) { |
| 38 | - define('SOURCE_DIR', dirname(__DIR__) . '/src'); |
|
| 38 | + define('SOURCE_DIR', dirname(__DIR__).'/src'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | Autoloader::register(); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | // Creates the src folder |
| 27 | 27 | GeneratorHelper::createDir($modPath); |
| 28 | 28 | // Create module path |
| 29 | - GeneratorHelper::createDir($modPath . $module); |
|
| 29 | + GeneratorHelper::createDir($modPath.$module); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -42,16 +42,16 @@ discard block |
||
| 42 | 42 | Logger::log("Generamos la estructura"); |
| 43 | 43 | $paths = [ |
| 44 | 44 | "Api", "Config", "Controller", "Models", "Public", "Templates", "Services", "Test", "Doc", |
| 45 | - "Locale", "Locale/" . Config::getParam('default.locale', 'es_ES'), "Locale/" . Config::getParam('default.locale', 'es_ES') . "/LC_MESSAGES" |
|
| 45 | + "Locale", "Locale/".Config::getParam('default.locale', 'es_ES'), "Locale/".Config::getParam('default.locale', 'es_ES')."/LC_MESSAGES" |
|
| 46 | 46 | ]; |
| 47 | - $modulePath = $modPath . $module; |
|
| 47 | + $modulePath = $modPath.$module; |
|
| 48 | 48 | foreach ($paths as $path) { |
| 49 | - GeneratorHelper::createDir($modulePath . DIRECTORY_SEPARATOR . $path); |
|
| 49 | + GeneratorHelper::createDir($modulePath.DIRECTORY_SEPARATOR.$path); |
|
| 50 | 50 | } |
| 51 | 51 | //Creamos las carpetas de los assets |
| 52 | 52 | $htmlPaths = array("css", "js", "img", "media", "font"); |
| 53 | 53 | foreach ($htmlPaths as $path) { |
| 54 | - GeneratorHelper::createDir($modulePath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path); |
|
| 54 | + GeneratorHelper::createDir($modulePath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | //Generamos el fichero de configuración |
| 67 | 67 | Logger::log("Generamos ficheros para assets base"); |
| 68 | 68 | $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", |
| 69 | - $modPath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", |
|
| 69 | + $modPath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", |
|
| 70 | 70 | $force); |
| 71 | 71 | $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", |
| 72 | - $modPath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", |
|
| 72 | + $modPath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", |
|
| 73 | 73 | $force); |
| 74 | 74 | return ($css && $js); |
| 75 | 75 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | "class" => $class, |
| 92 | 92 | )); |
| 93 | 93 | return $this->writeTemplateToFile($controller, |
| 94 | - $modPath . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php", |
|
| 94 | + $modPath.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php", |
|
| 95 | 95 | $force); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | "autoloader" => preg_replace('/(\\\|\/)/', '_', $module), |
| 111 | 111 | "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module), |
| 112 | 112 | )); |
| 113 | - $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", true); |
|
| 113 | + $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", true); |
|
| 114 | 114 | |
| 115 | 115 | Logger::log("Generamos el phpunit"); |
| 116 | 116 | $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array( |
| 117 | 117 | "module" => $module, |
| 118 | 118 | )); |
| 119 | - $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force); |
|
| 119 | + $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force); |
|
| 120 | 120 | return $autoload && $phpunit; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | if (str_contains($header, ':')) { |
| 25 | 25 | list($key, $value) = explode(':', $header); |
| 26 | - } else { |
|
| 26 | + }else { |
|
| 27 | 27 | $key = 'Http Status'; |
| 28 | 28 | $value = $header; |
| 29 | 29 | } |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | Logger::log('Adding debug headers to render response'); |
| 102 | 102 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
| 103 | 103 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
| 104 | - self::setHeader('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
| 105 | - self::setHeader('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
| 106 | - self::setHeader('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
| 104 | + self::setHeader('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
| 105 | + self::setHeader('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
| 106 | + self::setHeader('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | return $vars; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @return int|string |
| 116 | 116 | * @throws GeneratorException |
| 117 | 117 | */ |
| 118 | - public static function httpNotFound(\Throwable $exception = null, bool $isJson = false): int|string |
|
| 118 | + public static function httpNotFound(\Throwable $exception = null, bool $isJson = false): int | string |
|
| 119 | 119 | { |
| 120 | 120 | if (self::isTest()) { |
| 121 | 121 | return 404; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $notFoundRoute = Config::getParam('route.404'); |
| 135 | 135 | if (null !== $notFoundRoute) { |
| 136 | 136 | Request::getInstance()->redirect(Router::getInstance()->getRoute($notFoundRoute, true)); |
| 137 | - } else { |
|
| 137 | + }else { |
|
| 138 | 138 | return $template->render('error.html.twig', array( |
| 139 | 139 | 'exception' => $exception, |
| 140 | 140 | 'trace' => $exception->getTraceAsString(), |
@@ -32,13 +32,13 @@ |
||
| 32 | 32 | { |
| 33 | 33 | $namespace = explode('\\', $this->getModelTableMap()); |
| 34 | 34 | $module = strtolower($namespace[0]); |
| 35 | - $secret = Config::getInstance()->get($module . '.api.secret'); |
|
| 35 | + $secret = Config::getInstance()->get($module.'.api.secret'); |
|
| 36 | 36 | if (null === $secret) { |
| 37 | 37 | $secret = Config::getInstance()->get("api.secret"); |
| 38 | 38 | } |
| 39 | 39 | if (null === $secret) { |
| 40 | 40 | $auth = true; |
| 41 | - } else { |
|
| 41 | + }else { |
|
| 42 | 42 | $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN'); |
| 43 | 43 | if (array_key_exists('API_TOKEN', $this->query)) { |
| 44 | 44 | $token = $this->query['API_TOKEN']; |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function init() |
| 66 | 66 | { |
| 67 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, true); |
|
| 68 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, true); |
|
| 67 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, true); |
|
| 68 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, true); |
|
| 69 | 69 | if (empty($this->routing) || Config::getParam('debug', true)) { |
| 70 | 70 | $this->debugLoad(); |
| 71 | 71 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $this->hydrateRouting(); |
| 87 | 87 | $this->simpatize(); |
| 88 | 88 | Logger::log('End routes load'); |
| 89 | - } else { |
|
| 89 | + }else { |
|
| 90 | 90 | Logger::log('Routes generation skipped'); |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | try { |
| 104 | 104 | //Search action and execute |
| 105 | 105 | return $this->searchAction($route); |
| 106 | - } catch (AccessDeniedException $e) { |
|
| 107 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
| 106 | + }catch (AccessDeniedException $e) { |
|
| 107 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
| 108 | 108 | return Admin::staticAdminLogon(); |
| 109 | - } catch (RouterException $r) { |
|
| 109 | + }catch (RouterException $r) { |
|
| 110 | 110 | Logger::log($r->getMessage(), LOG_WARNING); |
| 111 | 111 | $code = $r->getCode(); |
| 112 | - } catch (Exception $e) { |
|
| 112 | + }catch (Exception $e) { |
|
| 113 | 113 | Logger::log($e->getMessage(), LOG_ERR); |
| 114 | 114 | throw $e; |
| 115 | 115 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | protected function searchAction($route) |
| 129 | 129 | { |
| 130 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
| 130 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
| 131 | 131 | //Revisamos si tenemos la ruta registrada |
| 132 | 132 | $parts = parse_url($route); |
| 133 | 133 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | throw new RouterException(t('Preconditions failed'), 412); |
| 151 | - } catch (Exception $e) { |
|
| 151 | + }catch (Exception $e) { |
|
| 152 | 152 | Logger::log($e->getMessage(), LOG_ERR); |
| 153 | 153 | throw $e; |
| 154 | 154 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | $valid = count($action['requirements']) === $checked; |
| 176 | - } else { |
|
| 176 | + }else { |
|
| 177 | 177 | $valid = true; |
| 178 | 178 | } |
| 179 | 179 | return $valid; |
@@ -196,11 +196,11 @@ discard block |
||
| 196 | 196 | if ($modules->hasResults()) { |
| 197 | 197 | foreach ($modules->getIterator() as $modulePath) { |
| 198 | 198 | $module = $modulePath->getBasename(); |
| 199 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
| 199 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, true); |
|
| 203 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, true); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $homeParams = null; |
| 218 | 218 | foreach ($this->routing as $pattern => $params) { |
| 219 | 219 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
| 220 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
| 220 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
| 221 | 221 | $homeParams = $params; |
| 222 | 222 | } |
| 223 | 223 | unset($method); |
@@ -249,18 +249,18 @@ discard block |
||
| 249 | 249 | { |
| 250 | 250 | $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : ''; |
| 251 | 251 | if ('' === $slug) { |
| 252 | - return $baseUrl . '/'; |
|
| 252 | + return $baseUrl.'/'; |
|
| 253 | 253 | } |
| 254 | 254 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
| 255 | 255 | throw new RouterException(t('No existe la ruta especificada')); |
| 256 | 256 | } |
| 257 | - $url = $baseUrl . $this->slugs[$slug]; |
|
| 257 | + $url = $baseUrl.$this->slugs[$slug]; |
|
| 258 | 258 | if (!empty($params)) { |
| 259 | 259 | foreach ($params as $key => $value) { |
| 260 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
| 260 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
| 261 | 261 | } |
| 262 | 262 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
| 263 | - $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default']; |
|
| 263 | + $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default']; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | if ($this->hasToRunPreChecks($class)) { |
| 276 | 276 | self::run($class, '__check', true); |
| 277 | 277 | } |
| 278 | - $preAction = 'pre' . ucfirst($method); |
|
| 278 | + $preAction = 'pre'.ucfirst($method); |
|
| 279 | 279 | if (method_exists($class, $preAction)) { |
| 280 | 280 | self::run($class, $preAction); |
| 281 | 281 | } |
@@ -290,13 +290,13 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | public static function run($class, $method, $throwExceptions = false): void |
| 292 | 292 | { |
| 293 | - Inspector::stats("[Router] Pre action invoked " . get_class($class) . "::{$method}", Inspector::SCOPE_DEBUG); |
|
| 293 | + Inspector::stats("[Router] Pre action invoked ".get_class($class)."::{$method}", Inspector::SCOPE_DEBUG); |
|
| 294 | 294 | try { |
| 295 | 295 | if (false === call_user_func_array([$class, $method], [])) { |
| 296 | - Logger::log(t("[Router] action " . get_class($class) . "::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
| 296 | + Logger::log(t("[Router] action ".get_class($class)."::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
| 297 | 297 | error_clear_last(); |
| 298 | 298 | } |
| 299 | - } catch (Exception $e) { |
|
| 299 | + }catch (Exception $e) { |
|
| 300 | 300 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
| 301 | 301 | if ($throwExceptions) { |
| 302 | 302 | throw $e; |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
| 327 | 327 | { |
| 328 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
| 328 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
| 329 | 329 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
| 330 | 330 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
| 331 | 331 | $cache = Cache::needCache(); |
@@ -333,15 +333,15 @@ discard block |
||
| 333 | 333 | $return = null; |
| 334 | 334 | if (false !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === false) { |
| 335 | 335 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
| 336 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
| 336 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
| 337 | 337 | if (NULL !== $cachedData) { |
| 338 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
| 338 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
| 339 | 339 | Template::getInstance()->renderCache($cachedData, $headers); |
| 340 | 340 | $execute = false; |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | if ($execute) { |
| 344 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
| 344 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
| 345 | 345 | $this->checkPreActions($class, $action['method']); |
| 346 | 346 | $return = call_user_func_array([$class, $action['method']], $params); |
| 347 | 347 | if (false === $return) { |
@@ -85,18 +85,18 @@ |
||
| 85 | 85 | if (!Request::getInstance()->isFile()) { |
| 86 | 86 | return $this->router->execute($uri ?? $this->actualUri); |
| 87 | 87 | } |
| 88 | - } else { |
|
| 88 | + }else { |
|
| 89 | 89 | return ConfigController::getInstance()->config(); |
| 90 | 90 | } |
| 91 | - } catch (AdminCredentialsException $a) { |
|
| 91 | + }catch (AdminCredentialsException $a) { |
|
| 92 | 92 | return UserController::showAdminManager(); |
| 93 | - } catch (SecurityException $s) { |
|
| 93 | + }catch (SecurityException $s) { |
|
| 94 | 94 | return $this->security->notAuthorized($this->actualUri); |
| 95 | - } catch (RouterException $r) { |
|
| 95 | + }catch (RouterException $r) { |
|
| 96 | 96 | return $this->router->httpNotFound($r); |
| 97 | - } catch (ApiException $a) { |
|
| 97 | + }catch (ApiException $a) { |
|
| 98 | 98 | return $this->router->httpNotFound($a, true); |
| 99 | - } catch (\Exception $e) { |
|
| 99 | + }catch (\Exception $e) { |
|
| 100 | 100 | return $this->handleException($e); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $fDto->entity = $relatedModel; |
| 34 | 34 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
| 35 | 35 | $fDto->relatedField = $relatedField->getPhpName(); |
| 36 | - $fDto->url = Router::getInstance()->getRoute(strtolower($domain) . '-api-' . $relatedModel); |
|
| 36 | + $fDto->url = Router::getInstance()->getRoute(strtolower($domain).'-api-'.$relatedModel); |
|
| 37 | 37 | return $fDto; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param ModelCriteria $query |
| 43 | 43 | * @param mixed $value |
| 44 | 44 | */ |
| 45 | - private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) |
|
| 45 | + private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null) |
|
| 46 | 46 | { |
| 47 | 47 | $tableField = $column->getFullyQualifiedName(); |
| 48 | 48 | if (is_array($value)) { |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
| 53 | 53 | $text = preg_replace('/(\'|\")/', '', $value); |
| 54 | 54 | $text = preg_replace('/\ /', '%', $text); |
| 55 | - $query->add($tableField, '%' . $text . '%', Criteria::LIKE); |
|
| 56 | - } else { |
|
| 55 | + $query->add($tableField, '%'.$text.'%', Criteria::LIKE); |
|
| 56 | + }else { |
|
| 57 | 57 | if (null !== $column->getValueSet()) { |
| 58 | 58 | $valueSet = $column->getValueSet(); |
| 59 | 59 | if (in_array($value, $valueSet)) { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param string $field |
| 72 | 72 | * @param mixed $value |
| 73 | 73 | */ |
| 74 | - public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null) |
|
| 74 | + public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null) |
|
| 75 | 75 | { |
| 76 | 76 | if ($column = self::checkFieldExists($tableMap, $field)) { |
| 77 | 77 | self::addQueryFilter($column, $query, $value); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public static function extractQuery($modelNameNamespace, ConnectionInterface $con = null) |
| 88 | 88 | { |
| 89 | - $queryReflector = new \ReflectionClass($modelNameNamespace . "Query"); |
|
| 89 | + $queryReflector = new \ReflectionClass($modelNameNamespace."Query"); |
|
| 90 | 90 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
| 91 | 91 | $query = $queryReflector->getMethod('create')->invoke($con); |
| 92 | 92 | |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | * @param array $extraColumns |
| 100 | 100 | * @param mixed $value |
| 101 | 101 | */ |
| 102 | - public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null) |
|
| 102 | + public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null) |
|
| 103 | 103 | { |
| 104 | 104 | $exp = 'CONCAT('; |
| 105 | 105 | $sep = ''; |
| 106 | 106 | foreach ($tableMap->getColumns() as $column) { |
| 107 | 107 | if ($column->isText()) { |
| 108 | - $exp .= $sep . 'COALESCE(' . $column->getFullyQualifiedName() . ',"")'; |
|
| 108 | + $exp .= $sep.'COALESCE('.$column->getFullyQualifiedName().',"")'; |
|
| 109 | 109 | $sep = ', " ", '; |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $localeTableMap = $relation->getLocalTable(); |
| 115 | 115 | foreach ($localeTableMap->getColumns() as $column) { |
| 116 | 116 | if ($column->isText()) { |
| 117 | - $exp .= $sep . 'COALESCE(' . $column->getFullyQualifiedName() . ',"")'; |
|
| 117 | + $exp .= $sep.'COALESCE('.$column->getFullyQualifiedName().',"")'; |
|
| 118 | 118 | $sep = ', " ", '; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -122,14 +122,14 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | foreach (array_keys($extraColumns) as $extra) { |
| 124 | 124 | if (!preg_match("/(COUNT|DISTINCT|SUM|MAX|MIN|GROUP)/i", $extra)) { |
| 125 | - $exp .= $sep . 'COALESCE(' . $extra . ', "")'; |
|
| 125 | + $exp .= $sep.'COALESCE('.$extra.', "")'; |
|
| 126 | 126 | $sep = ', " ", '; |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | $exp .= ")"; |
| 130 | 130 | $text = preg_replace('/(\'|\")/', '', $value); |
| 131 | 131 | $text = preg_replace('/\ /', '%', $text); |
| 132 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
| 132 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |