@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace PSFS\base\config; |
| 4 | 4 | |
| 5 | 5 | |
| 6 | -use PSFS\base\Cache; |
|
| 7 | 6 | use PSFS\base\exception\ConfigException; |
| 8 | 7 | use PSFS\base\Logger; |
| 9 | 8 | use PSFS\base\Request; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | protected function init() |
| 76 | 76 | { |
| 77 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) { |
|
| 77 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) { |
|
| 78 | 78 | $this->loadConfigData(); |
| 79 | 79 | } |
| 80 | 80 | return $this; |
@@ -182,10 +182,10 @@ discard block |
||
| 182 | 182 | $final_data = array_filter($final_data, function($key, $value) { |
| 183 | 183 | return in_array($key, Config::$required) || !empty($value); |
| 184 | 184 | }, ARRAY_FILTER_USE_BOTH); |
| 185 | - $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT))); |
|
| 185 | + $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT))); |
|
| 186 | 186 | Config::getInstance()->loadConfigData(); |
| 187 | 187 | $saved = true; |
| 188 | - } catch (ConfigException $e) { |
|
| 188 | + }catch (ConfigException $e) { |
|
| 189 | 189 | Logger::log($e->getMessage(), LOG_ERR); |
| 190 | 190 | } |
| 191 | 191 | return $saved; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function loadConfigData() |
| 219 | 219 | { |
| 220 | - $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: []; |
|
| 220 | + $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: []; |
|
| 221 | 221 | $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE; |
| 222 | 222 | } |
| 223 | 223 | |
@@ -232,7 +232,7 @@ |
||
| 232 | 232 | /** |
| 233 | 233 | * Static wrapper for extracting params |
| 234 | 234 | * @param string $key |
| 235 | - * @param mixed|null $defaultValue |
|
| 235 | + * @param string|boolean $defaultValue |
|
| 236 | 236 | * @return mixed|null |
| 237 | 237 | */ |
| 238 | 238 | public static function getParam($key, $defaultValue = null) |
@@ -78,16 +78,16 @@ discard block |
||
| 78 | 78 | if (!$this->parser->isFile()) { |
| 79 | 79 | return $this->router->execute($this->actualUri); |
| 80 | 80 | } |
| 81 | - } else { |
|
| 81 | + }else { |
|
| 82 | 82 | return ConfigController::getInstance()->config(); |
| 83 | 83 | } |
| 84 | - } catch (AdminCredentialsException $a) { |
|
| 84 | + }catch (AdminCredentialsException $a) { |
|
| 85 | 85 | return UserController::showAdminManager(); |
| 86 | - } catch (SecurityException $s) { |
|
| 86 | + }catch (SecurityException $s) { |
|
| 87 | 87 | return $this->security->notAuthorized($this->actualUri); |
| 88 | - } catch (RouterException $r) { |
|
| 88 | + }catch (RouterException $r) { |
|
| 89 | 89 | return $this->router->httpNotFound($r); |
| 90 | - } catch (\Exception $e) { |
|
| 90 | + }catch (\Exception $e) { |
|
| 91 | 91 | return $this->dumpException($e); |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $use /= 1024; |
| 130 | 130 | break; |
| 131 | 131 | case "MBytes": |
| 132 | - $use /= (1024 * 1024); |
|
| 132 | + $use /= (1024*1024); |
|
| 133 | 133 | break; |
| 134 | 134 | case "Bytes": |
| 135 | 135 | default: |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | { |
| 155 | 155 | Logger::log('Added handlers for errors'); |
| 156 | 156 | //Warning & Notice handler |
| 157 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
| 157 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
| 158 | 158 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]); |
| 159 | 159 | return true; |
| 160 | 160 | }, E_ALL | E_STRICT); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | Logger::log('Initializing stats (mem + ts)'); |
| 169 | 169 | if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) { |
| 170 | 170 | $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT']; |
| 171 | - } else { |
|
| 171 | + }else { |
|
| 172 | 172 | $this->ts = $this->parser->getTs(); |
| 173 | 173 | } |
| 174 | 174 | $this->mem = memory_get_usage(); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $translations = array(); |
| 25 | 25 | if (file_exists($absoluteTranslationFileName)) { |
| 26 | 26 | @include($absoluteTranslationFileName); |
| 27 | - } else { |
|
| 27 | + }else { |
|
| 28 | 28 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public static function setLocale() { |
| 38 | 38 | $locale = Config::getParam("default_language", 'es_ES'); |
| 39 | - Logger::log('Set locale to project [' . $locale . ']'); |
|
| 39 | + Logger::log('Set locale to project ['.$locale.']'); |
|
| 40 | 40 | // Load translations |
| 41 | - putenv("LC_ALL=" . $locale); |
|
| 41 | + putenv("LC_ALL=".$locale); |
|
| 42 | 42 | setlocale(LC_ALL, $locale); |
| 43 | 43 | // Load the locale path |
| 44 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
| 45 | - Logger::log('Set locale dir ' . $locale_path); |
|
| 44 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
| 45 | + Logger::log('Set locale dir '.$locale_path); |
|
| 46 | 46 | GeneratorHelper::createDir($locale_path); |
| 47 | 47 | bindtextdomain('translations', $locale_path); |
| 48 | 48 | textdomain('translations'); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } elseif ($mappedColumn->isText()) { |
| 41 | 41 | if ($mappedColumn->getSize() > 100) { |
| 42 | 42 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
| 43 | - } else { |
|
| 43 | + }else { |
|
| 44 | 44 | $fDto = self::generateStringField($field, $required); |
| 45 | 45 | } |
| 46 | 46 | } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $fDto->entity = $relatedModel; |
| 84 | 84 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
| 85 | 85 | $fDto->relatedField = $relatedField->getPhpName(); |
| 86 | - $fDto->url = Router::getInstance()->getRoute('api-' . $relatedModel); |
|
| 86 | + $fDto->url = Router::getInstance()->getRoute('api-'.$relatedModel); |
|
| 87 | 87 | return $fDto; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | try { |
| 192 | 192 | $column = $tableMap->getColumnByPhpName($field); |
| 193 | - } catch (\Exception $e) { |
|
| 193 | + }catch (\Exception $e) { |
|
| 194 | 194 | Logger::log($e->getMessage(), LOG_ERR); |
| 195 | 195 | $column = null; |
| 196 | 196 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @param ModelCriteria $query |
| 203 | 203 | * @param mixed $value |
| 204 | 204 | */ |
| 205 | - private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) |
|
| 205 | + private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null) |
|
| 206 | 206 | { |
| 207 | 207 | $tableField = $column->getPhpName(); |
| 208 | 208 | if (preg_match('/^<=/', $value)) { |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
| 217 | 217 | $text = preg_replace('/(\'|\")/', '', $value); |
| 218 | 218 | $text = preg_replace('/\ /', '%', $text); |
| 219 | - $query->filterBy($tableField, '%' . $text . '%', Criteria::LIKE); |
|
| 220 | - } else { |
|
| 219 | + $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE); |
|
| 220 | + }else { |
|
| 221 | 221 | $query->filterBy($tableField, $value, Criteria::EQUAL); |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -228,24 +228,24 @@ discard block |
||
| 228 | 228 | * @param array $extraColumns |
| 229 | 229 | * @param mixed $value |
| 230 | 230 | */ |
| 231 | - public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null) |
|
| 231 | + public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null) |
|
| 232 | 232 | { |
| 233 | 233 | $exp = 'CONCAT('; |
| 234 | 234 | $sep = ''; |
| 235 | 235 | foreach ($tableMap->getColumns() as $column) { |
| 236 | 236 | if ($column->isText()) { |
| 237 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
| 237 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
| 238 | 238 | $sep = ', " ", '; |
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | foreach ($extraColumns as $extra => $name) { |
| 242 | - $exp .= $sep . $extra; |
|
| 242 | + $exp .= $sep.$extra; |
|
| 243 | 243 | $sep = ', " ", '; |
| 244 | 244 | } |
| 245 | 245 | $exp .= ")"; |
| 246 | 246 | $text = preg_replace('/(\'|\")/', '', $value); |
| 247 | 247 | $text = preg_replace('/\ /', '%', $text); |
| 248 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
| 248 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @param string $field |
| 256 | 256 | * @param mixed $value |
| 257 | 257 | */ |
| 258 | - public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null) |
|
| 258 | + public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null) |
|
| 259 | 259 | { |
| 260 | 260 | if ($column = self::checkFieldExists($tableMap, $field)) { |
| 261 | 261 | self::addQueryFilter($column, $query, $value); |
@@ -17,11 +17,11 @@ |
||
| 17 | 17 | public static function checkApiActions($namespace, $domain, $api) { |
| 18 | 18 | $actions = []; |
| 19 | 19 | $reflector = new \ReflectionClass($namespace); |
| 20 | - if(null !== $reflector) { |
|
| 21 | - foreach($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
| 20 | + if (null !== $reflector) { |
|
| 21 | + foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
| 22 | 22 | $docComments = $apiAction->getDocComment(); |
| 23 | 23 | $action = self::extractAction($docComments); |
| 24 | - if(null !== $action) { |
|
| 24 | + if (null !== $action) { |
|
| 25 | 25 | list($route, $info) = RouterHelper::extractRouteInfo($apiAction, $api, $domain); |
| 26 | 26 | list($method, $cleanRoute) = RouterHelper::extractHttpRoute($route); |
| 27 | 27 | $formAction = new FormAction(); |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | $array['fields'][] = $field->__toArray(); |
| 27 | 27 | } |
| 28 | 28 | $array['actions'] = []; |
| 29 | - foreach($this->actions as $action) { |
|
| 29 | + foreach ($this->actions as $action) { |
|
| 30 | 30 | $array['actions'][] = $action->__toArray(); |
| 31 | 31 | } |
| 32 | 32 | return $array; |