@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | if (!headers_sent()) { |
| 51 | 51 | // TODO include this headers in Template class output method |
| 52 | 52 | ResponseHelper::setHeader('Access-Control-Allow-Credentials: true'); |
| 53 | - ResponseHelper::setHeader('Access-Control-Allow-Origin: ' . Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
| 53 | + ResponseHelper::setHeader('Access-Control-Allow-Origin: '.Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
| 54 | 54 | ResponseHelper::setHeader('Vary: Origin'); |
| 55 | 55 | ResponseHelper::setHeader('Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS, HEAD'); |
| 56 | - ResponseHelper::setHeader('Access-Control-Allow-Headers: ' . implode(', ', self::getCorsHeaders())); |
|
| 56 | + ResponseHelper::setHeader('Access-Control-Allow-Headers: '.implode(', ', self::getCorsHeaders())); |
|
| 57 | 57 | } |
| 58 | 58 | if (Request::getInstance()->getMethod() === Request::VERB_OPTIONS) { |
| 59 | 59 | Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | return $ip; |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | - } else { |
|
| 89 | + }else { |
|
| 90 | 90 | if (self::validateIpAddress($xForwardedFor)) { |
| 91 | 91 | return $xForwardedFor; |
| 92 | 92 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | // Verifica si la IP está en el rango válido |
| 127 | 127 | if ($ipNum >= $rangoInicioNum && $ipNum <= $rangoFinNum) { |
| 128 | 128 | return true; // La IP está en el rango válido |
| 129 | - } else { |
|
| 129 | + }else { |
|
| 130 | 130 | return false; // La IP está fuera del rango válido |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | foreach ($data as $key => $value) { |
| 30 | 30 | try { |
| 31 | 31 | $realValue = $model->getByName($key); |
| 32 | - } catch (\Exception $e) { |
|
| 32 | + }catch (\Exception $e) { |
|
| 33 | 33 | $realValue = $value; |
| 34 | 34 | } |
| 35 | 35 | if (Api::API_MODEL_KEY_FIELD === $key) { |
| 36 | 36 | $result[$key] = (integer)$realValue; |
| 37 | - } else { |
|
| 37 | + }else { |
|
| 38 | 38 | $result[$key] = $realValue; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @return array |
| 50 | 50 | * @throws \Propel\Runtime\Exception\PropelException |
| 51 | 51 | */ |
| 52 | - public static function mapArrayObject($namespace, ColumnMap $modelPk, array $query, array|ActiveRecordInterface $data = []) |
|
| 52 | + public static function mapArrayObject($namespace, ColumnMap $modelPk, array $query, array | ActiveRecordInterface $data = []) |
|
| 53 | 53 | { |
| 54 | 54 | $formatter = new ObjectFormatter(); |
| 55 | 55 | $formatter->setClass($namespace); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** @var ActiveRecordInterface $obj */ |
| 68 | 68 | $obj = @$formatter->getAllObjectsFromRow($objData); |
| 69 | 69 | $result = self::mapResult($obj, $data); |
| 70 | - if (!preg_match('/' . $modelPk->getPhpName() . '/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
| 70 | + if (!preg_match('/'.$modelPk->getPhpName().'/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
| 71 | 71 | unset($result[$modelPk->getPhpName()]); |
| 72 | 72 | } |
| 73 | 73 | return $result; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | protected function hydrateOrders() |
| 40 | 40 | { |
| 41 | 41 | if (count($this->query)) { |
| 42 | - Logger::log(static::class . ' gathering query string', LOG_DEBUG); |
|
| 42 | + Logger::log(static::class.' gathering query string', LOG_DEBUG); |
|
| 43 | 43 | foreach ($this->query as $key => $value) { |
| 44 | 44 | if ($key === self::API_ORDER_FIELD) { |
| 45 | 45 | $orders = json_decode($value, true); |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | protected function extractPagination() |
| 59 | 59 | { |
| 60 | - Logger::log(static::class . ' extract pagination start', LOG_DEBUG); |
|
| 60 | + Logger::log(static::class.' extract pagination start', LOG_DEBUG); |
|
| 61 | 61 | $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1; |
| 62 | 62 | $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100; |
| 63 | - Logger::log(static::class . ' extract pagination end', LOG_DEBUG); |
|
| 63 | + Logger::log(static::class.' extract pagination end', LOG_DEBUG); |
|
| 64 | 64 | return array($page, (int)$limit); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | * @param ModelCriteria $query |
| 70 | 70 | * @throws \PSFS\base\exception\ApiException |
| 71 | 71 | */ |
| 72 | - protected function addOrders(ModelCriteria &$query) |
|
| 72 | + protected function addOrders(ModelCriteria & $query) |
|
| 73 | 73 | { |
| 74 | - Logger::log(static::class . ' extract orders start ', LOG_DEBUG); |
|
| 74 | + Logger::log(static::class.' extract orders start ', LOG_DEBUG); |
|
| 75 | 75 | $orderAdded = FALSE; |
| 76 | 76 | $tableMap = $this->getTableMap(); |
| 77 | 77 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $orderAdded = TRUE; |
| 80 | 80 | if ($direction === Order::ASC) { |
| 81 | 81 | $query->addAscendingOrderByColumn($column->getPhpName()); |
| 82 | - } else { |
|
| 82 | + }else { |
|
| 83 | 83 | $query->addDescendingOrderByColumn($column->getPhpName()); |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $query->addAscendingOrderByColumn($key); |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | - Logger::log(static::class . ' extract orders end', LOG_DEBUG); |
|
| 93 | + Logger::log(static::class.' extract orders end', LOG_DEBUG); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @param ModelCriteria $query |
| 100 | 100 | */ |
| 101 | - protected function addFilters(ModelCriteria &$query) |
|
| 101 | + protected function addFilters(ModelCriteria & $query) |
|
| 102 | 102 | { |
| 103 | 103 | if (count($this->query) > 0) { |
| 104 | 104 | $tableMap = $this->getTableMap(); |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | $this->checkReturnFields($query); |
| 127 | 127 | if ($limit === -1) { |
| 128 | 128 | $this->list = $query->find($this->con); |
| 129 | - } else { |
|
| 129 | + }else { |
|
| 130 | 130 | $this->list = $query->paginate($page, $limit, $this->con); |
| 131 | 131 | } |
| 132 | - } catch (\Exception $e) { |
|
| 132 | + }catch (\Exception $e) { |
|
| 133 | 133 | Logger::log($e->getMessage(), LOG_ERR); |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | $header = null; |
| 138 | 138 | if ($this->hasHeader($name)) { |
| 139 | 139 | $header = $this->header[$name]; |
| 140 | - } else if (array_key_exists('h_' . strtolower($name), $this->query)) { |
|
| 141 | - $header = $this->query['h_' . strtolower($name)]; |
|
| 142 | - } else if (array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
| 143 | - $header = $this->getServer('HTTP_' . strtoupper(str_replace('-', '_', $name))); |
|
| 140 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
| 141 | + $header = $this->query['h_'.strtolower($name)]; |
|
| 142 | + }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
| 143 | + $header = $this->getServer('HTTP_'.strtoupper(str_replace('-', '_', $name))); |
|
| 144 | 144 | } |
| 145 | 145 | return $header ?: $default; |
| 146 | 146 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $url = $this->getServer('HTTP_ORIGIN'); |
| 255 | 255 | } |
| 256 | 256 | ob_start(); |
| 257 | - header('Location: ' . $url); |
|
| 257 | + header('Location: '.$url); |
|
| 258 | 258 | ob_end_clean(); |
| 259 | 259 | Security::getInstance()->updateSession(); |
| 260 | 260 | exit(t('Redirect...')); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $url = $this->getServerName(); |
| 271 | 271 | $protocol = $hasProtocol ? $this->getProtocol() : '//'; |
| 272 | 272 | if (!empty($protocol)) { |
| 273 | - $url = $protocol . $url; |
|
| 273 | + $url = $protocol.$url; |
|
| 274 | 274 | } |
| 275 | 275 | return $this->checkServerPort($url); |
| 276 | 276 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | if (!in_array($port, [80, 443], true)) { |
| 294 | - $url .= ':' . $port; |
|
| 294 | + $url .= ':'.$port; |
|
| 295 | 295 | } |
| 296 | 296 | return $url; |
| 297 | 297 | } |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $filePath = $returnPath = ''; |
| 48 | 48 | if (!file_exists($filePath)) { |
| 49 | - $filePath = BASE_DIR . $string; |
|
| 49 | + $filePath = BASE_DIR.$string; |
|
| 50 | 50 | } |
| 51 | 51 | $filenamePath = AssetsHelper::findDomainPath($string, $filePath); |
| 52 | - if(!empty($filenamePath)){ |
|
| 52 | + if (!empty($filenamePath)) { |
|
| 53 | 53 | $filePath = self::processAsset($string, $name, $return, $filenamePath); |
| 54 | 54 | $basePath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl(false)); |
| 55 | - $returnPath = empty($name) ? $basePath . '/' . $filePath : $name; |
|
| 55 | + $returnPath = empty($name) ? $basePath.'/'.$filePath : $name; |
|
| 56 | 56 | } |
| 57 | 57 | return $return ? $returnPath : ''; |
| 58 | 58 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $router = Router::getInstance(); |
| 71 | 71 | try { |
| 72 | 72 | return $router->getRoute($path, $absolute, $params); |
| 73 | - } catch (\Exception $e) { |
|
| 73 | + }catch (\Exception $e) { |
|
| 74 | 74 | Logger::log($e->getMessage()); |
| 75 | 75 | return $router->getRoute('', $absolute, $params); |
| 76 | 76 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $filenamePath = self::extractPathname($path, $domains); |
| 167 | 167 | // Check if resources has been copied to public folders |
| 168 | 168 | if (!$debug) { |
| 169 | - $cacheFilename = Config::getParam('cache.var', '__initial__') . '.file.cache'; |
|
| 169 | + $cacheFilename = Config::getParam('cache.var', '__initial__').'.file.cache'; |
|
| 170 | 170 | $cachedFiles = Cache::getInstance()->readFromCache($cacheFilename, |
| 171 | 171 | 1, fn() => [], Cache::JSON, true) ?: []; |
| 172 | 172 | // Force the resource copy |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @return string|array |
| 189 | 189 | */ |
| 190 | - private static function extractPathname(string $path, $domains): string|array |
|
| 190 | + private static function extractPathname(string $path, $domains): string | array |
|
| 191 | 191 | { |
| 192 | 192 | $filenamePath = $path; |
| 193 | 193 | if (!empty($domains) && !file_exists($path)) { |
@@ -226,13 +226,13 @@ discard block |
||
| 226 | 226 | * @param string $base |
| 227 | 227 | * @param string $filePath |
| 228 | 228 | */ |
| 229 | - private static function putResourceContent(string|null $name, string $filenamePath, string $base, string $filePath): void |
|
| 229 | + private static function putResourceContent(string | null $name, string $filenamePath, string $base, string $filePath): void |
|
| 230 | 230 | { |
| 231 | 231 | $data = file_get_contents($filenamePath); |
| 232 | 232 | if (!empty($name)) { |
| 233 | - file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
| 234 | - } else { |
|
| 235 | - file_put_contents($base . $filePath, $data); |
|
| 233 | + file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
| 234 | + }else { |
|
| 235 | + file_put_contents($base.$filePath, $data); |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
@@ -245,15 +245,15 @@ discard block |
||
| 245 | 245 | * @return string |
| 246 | 246 | * @throws GeneratorException |
| 247 | 247 | */ |
| 248 | - private static function processAsset(string $string, string|null $name = null, bool $return = true, string $filenamePath = ''): string |
|
| 248 | + private static function processAsset(string $string, string | null $name = null, bool $return = true, string $filenamePath = ''): string |
|
| 249 | 249 | { |
| 250 | 250 | $filePath = $filenamePath; |
| 251 | 251 | if (file_exists($filenamePath)) { |
| 252 | 252 | list($base, $htmlBase, $filePath) = AssetsHelper::calculateAssetPath($string, $name, $return, $filenamePath); |
| 253 | 253 | //Creamos el directorio si no existe |
| 254 | - GeneratorHelper::createDir($base . $htmlBase); |
|
| 254 | + GeneratorHelper::createDir($base.$htmlBase); |
|
| 255 | 255 | //Si se ha modificado |
| 256 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($filenamePath)) { |
|
| 256 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($filenamePath)) { |
|
| 257 | 257 | if ($htmlBase === 'css') { |
| 258 | 258 | self::processCssLines($filenamePath); |
| 259 | 259 | } |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | public static array $headers_sent = []; |
| 21 | 21 | |
| 22 | 22 | public static function setHeader(string $header): void { |
| 23 | - if(str_contains($header, ':')) { |
|
| 23 | + if (str_contains($header, ':')) { |
|
| 24 | 24 | list($key, $value) = explode(':', $header); |
| 25 | - } else { |
|
| 25 | + }else { |
|
| 26 | 26 | $key = 'Http Status'; |
| 27 | 27 | $value = $header; |
| 28 | 28 | } |
| 29 | 29 | if (!in_array($key, self::$headers_sent)) { |
| 30 | - if(!self::isTest()) { |
|
| 30 | + if (!self::isTest()) { |
|
| 31 | 31 | header($header); |
| 32 | 32 | } |
| 33 | 33 | self::$headers_sent[$key] = $value; |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | Logger::log('Adding debug headers to render response'); |
| 100 | 100 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
| 101 | 101 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
| 102 | - self::setHeader('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
| 103 | - self::setHeader('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
| 104 | - self::setHeader('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
| 102 | + self::setHeader('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
| 103 | + self::setHeader('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
| 104 | + self::setHeader('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $vars; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @return int|string |
| 114 | 114 | * @throws GeneratorException |
| 115 | 115 | */ |
| 116 | - public static function httpNotFound(Exception $exception = NULL, bool $isJson = false): int|string |
|
| 116 | + public static function httpNotFound(Exception $exception = NULL, bool $isJson = false): int | string |
|
| 117 | 117 | { |
| 118 | 118 | if (self::isTest()) { |
| 119 | 119 | return 404; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $notFoundRoute = Config::getParam('route.404'); |
| 133 | 133 | if (null !== $notFoundRoute) { |
| 134 | 134 | Request::getInstance()->redirect(Router::getInstance()->getRoute($notFoundRoute, true)); |
| 135 | - } else { |
|
| 135 | + }else { |
|
| 136 | 136 | return $template->render('error.html.twig', array( |
| 137 | 137 | 'exception' => $exception, |
| 138 | 138 | 'trace' => $exception->getTraceAsString(), |
@@ -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 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 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); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | if ($this->hasToRunPreChecks($class)) { |
| 273 | 273 | self::run($class, '__check', true); |
| 274 | 274 | } |
| 275 | - $preAction = 'pre' . ucfirst($method); |
|
| 275 | + $preAction = 'pre'.ucfirst($method); |
|
| 276 | 276 | if (method_exists($class, $preAction)) { |
| 277 | 277 | self::run($class, $preAction); |
| 278 | 278 | } |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public static function run($class, $method, $throwExceptions = false): void |
| 289 | 289 | { |
| 290 | - Inspector::stats("[Router] Pre action invoked " . get_class($class) . "::{$method}", Inspector::SCOPE_DEBUG); |
|
| 290 | + Inspector::stats("[Router] Pre action invoked ".get_class($class)."::{$method}", Inspector::SCOPE_DEBUG); |
|
| 291 | 291 | try { |
| 292 | 292 | if (false === call_user_func_array([$class, $method], [])) { |
| 293 | - Logger::log(t("[Router] action " . get_class($class) . "::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
| 293 | + Logger::log(t("[Router] action ".get_class($class)."::{$method} failed"), LOG_ERR, [error_get_last()]); |
|
| 294 | 294 | error_clear_last(); |
| 295 | 295 | } |
| 296 | - } catch (Exception $e) { |
|
| 296 | + }catch (Exception $e) { |
|
| 297 | 297 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
| 298 | 298 | if ($throwExceptions) { |
| 299 | 299 | throw $e; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
| 324 | 324 | { |
| 325 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
| 325 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
| 326 | 326 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
| 327 | 327 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
| 328 | 328 | $cache = Cache::needCache(); |
@@ -330,15 +330,15 @@ discard block |
||
| 330 | 330 | $return = null; |
| 331 | 331 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
| 332 | 332 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
| 333 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
| 333 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
| 334 | 334 | if (NULL !== $cachedData) { |
| 335 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
| 335 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
| 336 | 336 | Template::getInstance()->renderCache($cachedData, $headers); |
| 337 | 337 | $execute = FALSE; |
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | if ($execute) { |
| 341 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
| 341 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
| 342 | 342 | $this->checkPreActions($class, $action['method']); |
| 343 | 343 | $return = call_user_func_array([$class, $action['method']], $params); |
| 344 | 344 | if (false === $return) { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function init() |
| 55 | 55 | { |
| 56 | 56 | parent::init(); |
| 57 | - Logger::log(static::class . ' init', LOG_DEBUG); |
|
| 57 | + Logger::log(static::class.' init', LOG_DEBUG); |
|
| 58 | 58 | $this->domain = $this->getDomain(); |
| 59 | 59 | $this->hydrateRequestData(); |
| 60 | 60 | $this->hydrateOrders(); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | $this->checkFieldType(); |
| 65 | 65 | $this->setLoaded(true); |
| 66 | - Logger::log(static::class . ' loaded', LOG_DEBUG); |
|
| 66 | + Logger::log(static::class.' loaded', LOG_DEBUG); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | private function checkActions($method) |
@@ -159,14 +159,14 @@ discard block |
||
| 159 | 159 | $status = 200; |
| 160 | 160 | $saved = TRUE; |
| 161 | 161 | $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
| 162 | - } else { |
|
| 162 | + }else { |
|
| 163 | 163 | $message = t('No se ha podido guardar el modelo seleccionado'); |
| 164 | 164 | } |
| 165 | - } catch (\Exception $e) { |
|
| 166 | - if(Config::getParam('debug')) { |
|
| 167 | - $message = t('Ha ocurrido un error intentando guardar el elemento: ') . '<br>' . $e->getMessage(); |
|
| 168 | - } else { |
|
| 169 | - $message = t('Ha ocurrido un error intentando guardar el elemento: ') . '<br>' . $e->getCode(); |
|
| 165 | + }catch (\Exception $e) { |
|
| 166 | + if (Config::getParam('debug')) { |
|
| 167 | + $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
| 168 | + }else { |
|
| 169 | + $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getCode(); |
|
| 170 | 170 | } |
| 171 | 171 | $context = []; |
| 172 | 172 | if (null !== $e->getPrevious()) { |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | $updated = TRUE; |
| 206 | 206 | $status = 200; |
| 207 | 207 | $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
| 208 | - } else { |
|
| 208 | + }else { |
|
| 209 | 209 | $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 210 | 210 | } |
| 211 | - } catch (\Exception $e) { |
|
| 212 | - if(Config::getParam('debug')) { |
|
| 213 | - $message = t('Ha ocurrido un error intentando actualizar el elemento: ') . '<br>' . $e->getMessage(); |
|
| 214 | - } else { |
|
| 215 | - $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs: ') . '<br>' . $e->getCode(); |
|
| 211 | + }catch (\Exception $e) { |
|
| 212 | + if (Config::getParam('debug')) { |
|
| 213 | + $message = t('Ha ocurrido un error intentando actualizar el elemento: ').'<br>'.$e->getMessage(); |
|
| 214 | + }else { |
|
| 215 | + $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs: ').'<br>'.$e->getCode(); |
|
| 216 | 216 | } |
| 217 | 217 | $context = []; |
| 218 | 218 | if (null !== $e->getPrevious()) { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
| 222 | 222 | } |
| 223 | - } else { |
|
| 223 | + }else { |
|
| 224 | 224 | $message = t('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $this->model->delete($this->con); |
| 255 | 255 | $deleted = TRUE; |
| 256 | 256 | } |
| 257 | - } catch (\Exception $e) { |
|
| 257 | + }catch (\Exception $e) { |
|
| 258 | 258 | $context = []; |
| 259 | 259 | if (null !== $e->getPrevious()) { |
| 260 | 260 | $context[] = $e->getPrevious()->getMessage(); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | $this->saveBulk(); |
| 287 | 287 | $saved = true; |
| 288 | 288 | $status = 200; |
| 289 | - } catch (\Exception $e) { |
|
| 289 | + }catch (\Exception $e) { |
|
| 290 | 290 | Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData()); |
| 291 | 291 | $message = t('Bulk insert rolled back'); |
| 292 | 292 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | if (null !== $this->list) { |
| 319 | 319 | if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
| 320 | 320 | $return = $this->extractDataWithFormat(); |
| 321 | - } else { |
|
| 321 | + }else { |
|
| 322 | 322 | $return = $this->list->toArray(null, false, $this->fieldType ?: TableMap::TYPE_PHPNAME, false); |
| 323 | 323 | } |
| 324 | 324 | $total = 0; |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | $pages = 1; |
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | - } catch (\Exception $e) { |
|
| 335 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 334 | + }catch (\Exception $e) { |
|
| 335 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | return array($return, $total, $pages); |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | $return = array(); |
| 351 | 351 | if (NULL === $model || !method_exists($model, 'toArray')) { |
| 352 | 352 | $code = 404; |
| 353 | - } else { |
|
| 353 | + }else { |
|
| 354 | 354 | $return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
| 355 | 355 | } |
| 356 | 356 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | if (count($pks) === 1) { |
| 101 | 101 | $pks = array_keys($pks); |
| 102 | 102 | return [ |
| 103 | - $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD |
|
| 103 | + $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD |
|
| 104 | 104 | ]; |
| 105 | 105 | } |
| 106 | 106 | if (count($pks) > 1) { |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | $principal = ''; |
| 109 | 109 | $sep = 'CONCAT('; |
| 110 | 110 | foreach ($pks as $pk) { |
| 111 | - $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName(); |
|
| 112 | - $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName(); |
|
| 113 | - $sep = ', "' . Api::API_PK_SEPARATOR . '", '; |
|
| 111 | + $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName(); |
|
| 112 | + $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName(); |
|
| 113 | + $sep = ', "'.Api::API_PK_SEPARATOR.'", '; |
|
| 114 | 114 | } |
| 115 | 115 | $principal .= ')'; |
| 116 | 116 | $apiPks[$principal] = Api::API_MODEL_KEY_FIELD; |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | $pks = ''; |
| 138 | 138 | $sep = ''; |
| 139 | 139 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
| 140 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
| 140 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
| 141 | 141 | $sep = ', "|", '; |
| 142 | 142 | } |
| 143 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD; |
|
| 143 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | if (null !== $column) { |
| 164 | 164 | $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD; |
| 165 | - } else { |
|
| 165 | + }else { |
|
| 166 | 166 | $this->addClassListName($tableMap); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @param $action |
| 174 | 174 | * @throws ApiException |
| 175 | 175 | */ |
| 176 | - private function addExtraColumns(ModelCriteria &$query, $action) |
|
| 176 | + private function addExtraColumns(ModelCriteria & $query, $action) |
|
| 177 | 177 | { |
| 178 | 178 | if (Api::API_ACTION_LIST === $action) { |
| 179 | 179 | $this->addDefaultListField(); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | if (!empty($this->extraColumns)) { |
| 183 | 183 | if (Config::getParam('api.extrafields.compat', true)) { |
| 184 | 184 | $fields = array_values($this->extraColumns); |
| 185 | - } else { |
|
| 185 | + }else { |
|
| 186 | 186 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
| 187 | 187 | $fields = explode(',', $returnFields ?: ''); |
| 188 | 188 | $fields[] = self::API_MODEL_KEY_FIELD; |
@@ -216,32 +216,32 @@ discard block |
||
| 216 | 216 | /** |
| 217 | 217 | * @param ModelCriteria $query |
| 218 | 218 | */ |
| 219 | - protected function checkI18n(ModelCriteria &$query) |
|
| 219 | + protected function checkI18n(ModelCriteria & $query) |
|
| 220 | 220 | { |
| 221 | 221 | $this->extractApiLang(); |
| 222 | 222 | $model = $this->getModelNamespace(); |
| 223 | - $modelI18n = $model . 'I18n'; |
|
| 223 | + $modelI18n = $model.'I18n'; |
|
| 224 | 224 | if (method_exists($query, 'useI18nQuery')) { |
| 225 | 225 | $query->useI18nQuery($this->lang); |
| 226 | 226 | $modelParts = explode('\\', $modelI18n); |
| 227 | - $i18nMapClass = str_replace(end($modelParts), 'Map\\' . end($modelParts), $modelI18n) . 'TableMap'; |
|
| 227 | + $i18nMapClass = str_replace(end($modelParts), 'Map\\'.end($modelParts), $modelI18n).'TableMap'; |
|
| 228 | 228 | /** @var TableMap $modelI18nTableMap */ |
| 229 | 229 | $modelI18nTableMap = $i18nMapClass::getTableMap(); |
| 230 | 230 | foreach ($modelI18nTableMap->getColumns() as $columnMap) { |
| 231 | 231 | if (!$columnMap->isPrimaryKey()) { |
| 232 | 232 | $query->withColumn($columnMap->getFullyQualifiedName(), ApiHelper::getColumnMapName($columnMap)); |
| 233 | 233 | } elseif (!$columnMap->isForeignKey()) { |
| 234 | - $query->withColumn('IFNULL(' . $columnMap->getFullyQualifiedName() . ', "' . $this->lang . '")', ApiHelper::getColumnMapName($columnMap)); |
|
| 234 | + $query->withColumn('IFNULL('.$columnMap->getFullyQualifiedName().', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap)); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | protected function cleanData(array &$data) { |
| 241 | - foreach($data as $key => &$value) { |
|
| 242 | - if(is_array($value)) { |
|
| 241 | + foreach ($data as $key => &$value) { |
|
| 242 | + if (is_array($value)) { |
|
| 243 | 243 | $this->cleanData($value); |
| 244 | - } else if(is_string($value)) { |
|
| 244 | + }else if (is_string($value)) { |
|
| 245 | 245 | $value = I18nHelper::cleanHtmlAttacks($value); |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | $model->fromArray($data, ApiHelper::getFieldTypes()); |
| 258 | 258 | $tableMap = $this->getTableMap(); |
| 259 | 259 | try { |
| 260 | - if ($tableMap->hasRelation($tableMap->getPhpName() . 'I18n')) { |
|
| 261 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
| 260 | + if ($tableMap->hasRelation($tableMap->getPhpName().'I18n')) { |
|
| 261 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
| 262 | 262 | $i18NTableMap = $relateI18n->getLocalTable(); |
| 263 | 263 | $model->setLocale(array_key_exists('Locale', $data) ? $data['Locale'] : (array_key_exists('locale', $data) ? $data['locale'] : Request::header(Api::HEADER_API_LANG, 'es_ES'))); |
| 264 | 264 | foreach ($i18NTableMap->getColumns() as $columnMap) { |
| 265 | - $method = 'set' . $columnMap->getPhpName(); |
|
| 265 | + $method = 'set'.$columnMap->getPhpName(); |
|
| 266 | 266 | $dtoColumnName = ApiHelper::getColumnMapName($columnMap); |
| 267 | 267 | if (array_key_exists($dtoColumnName, $data) |
| 268 | 268 | && method_exists($model, $method) |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | - } catch (Exception $e) { |
|
| 274 | + }catch (Exception $e) { |
|
| 275 | 275 | Logger::log($e->getMessage(), LOG_DEBUG); |
| 276 | 276 | } |
| 277 | 277 | } |