@@ -6,20 +6,20 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | defined('SOURCE_DIR') or define('SOURCE_DIR', __DIR__); |
| 8 | 8 | if (preg_match('/vendor/', SOURCE_DIR)) { |
| 9 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
| 10 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
| 11 | -} else { |
|
| 12 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
| 13 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
| 9 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
| 10 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
| 11 | +}else { |
|
| 12 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
| 13 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
| 14 | 14 | } |
| 15 | -defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
| 16 | -defined('LOG_DIR') or define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 17 | -defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
| 18 | -defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
| 19 | -defined('WEB_DIR') or define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
| 20 | -defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 15 | +defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor'); |
|
| 16 | +defined('LOG_DIR') or define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
| 17 | +defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
| 18 | +defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
| 19 | +defined('WEB_DIR') or define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
| 20 | +defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 21 | 21 | |
| 22 | -if(!class_exists(bootstrap::class)) { |
|
| 22 | +if (!class_exists(bootstrap::class)) { |
|
| 23 | 23 | /** |
| 24 | 24 | * Class Bootstrap |
| 25 | 25 | * @package PSFS |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | class bootstrap { |
| 28 | 28 | protected static $loaded = false; |
| 29 | 29 | public static function load() { |
| 30 | - if(!self::$loaded) { |
|
| 30 | + if (!self::$loaded) { |
|
| 31 | 31 | defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true); |
| 32 | - if(class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
| 32 | + if (class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
| 33 | 33 | self::$loaded = true; |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -29,7 +29,9 @@ |
||
| 29 | 29 | public static function load() { |
| 30 | 30 | if(!self::$loaded) { |
| 31 | 31 | defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true); |
| 32 | - if(class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
| 32 | + if(class_exists("\\PSFS\\base\\Logger")) { |
|
| 33 | + \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
| 34 | + } |
|
| 33 | 35 | self::$loaded = true; |
| 34 | 36 | } |
| 35 | 37 | } |
@@ -65,21 +65,21 @@ discard block |
||
| 65 | 65 | if (count($pks) == 1) { |
| 66 | 66 | $pks = array_keys($pks); |
| 67 | 67 | return [ |
| 68 | - $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD |
|
| 68 | + $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD |
|
| 69 | 69 | ]; |
| 70 | 70 | } elseif (count($pks) > 1) { |
| 71 | 71 | $apiPks = []; |
| 72 | 72 | $principal = ''; |
| 73 | 73 | $sep = 'CONCAT('; |
| 74 | 74 | foreach ($pks as $pk) { |
| 75 | - $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName(); |
|
| 76 | - $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName(); |
|
| 77 | - $sep = ', "' . Api::API_PK_SEPARATOR . '", '; |
|
| 75 | + $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName(); |
|
| 76 | + $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName(); |
|
| 77 | + $sep = ', "'.Api::API_PK_SEPARATOR.'", '; |
|
| 78 | 78 | } |
| 79 | 79 | $principal .= ')'; |
| 80 | 80 | $apiPks[$principal] = Api::API_MODEL_KEY_FIELD; |
| 81 | 81 | return $apiPks; |
| 82 | - } else { |
|
| 82 | + }else { |
|
| 83 | 83 | throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta')); |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | $pks = ''; |
| 103 | 103 | $sep = ''; |
| 104 | 104 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
| 105 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
| 105 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
| 106 | 106 | $sep = ', "|", '; |
| 107 | 107 | } |
| 108 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD; |
|
| 108 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | if (null !== $column) { |
| 129 | 129 | $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD; |
| 130 | - } else { |
|
| 130 | + }else { |
|
| 131 | 131 | $this->addClassListName($tableMap); |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -146,15 +146,15 @@ discard block |
||
| 146 | 146 | $this->addPkToList(); |
| 147 | 147 | } |
| 148 | 148 | if (!empty($this->extraColumns)) { |
| 149 | - if(Config::getParam('api.extrafields.compat', true)) { |
|
| 149 | + if (Config::getParam('api.extrafields.compat', true)) { |
|
| 150 | 150 | $fields = array_values($this->extraColumns); |
| 151 | - } else { |
|
| 151 | + }else { |
|
| 152 | 152 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
| 153 | 153 | $fields = explode(',', $returnFields ?: ''); |
| 154 | 154 | $fields[] = self::API_MODEL_KEY_FIELD; |
| 155 | 155 | } |
| 156 | 156 | foreach ($this->extraColumns as $expression => $columnName) { |
| 157 | - if(empty($fields) || in_array($columnName, $fields)) { |
|
| 157 | + if (empty($fields) || in_array($columnName, $fields)) { |
|
| 158 | 158 | $query->withColumn($expression, $columnName); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -186,17 +186,17 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | $this->extractApiLang(); |
| 188 | 188 | $model = $this->getModelNamespace(); |
| 189 | - $modelI18n = $model . 'I18n'; |
|
| 189 | + $modelI18n = $model.'I18n'; |
|
| 190 | 190 | if (method_exists($query, 'useI18nQuery')) { |
| 191 | 191 | $query->useI18nQuery($this->lang); |
| 192 | - $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n) . 'TableMap'; |
|
| 192 | + $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n).'TableMap'; |
|
| 193 | 193 | /** @var TableMap $modelI18nTableMap */ |
| 194 | 194 | $modelI18nTableMap = $modelI18nTableMapClass::getTableMap(); |
| 195 | - foreach($modelI18nTableMap->getColumns() as $columnMap) { |
|
| 196 | - if(!$columnMap->isPrimaryKey()) { |
|
| 197 | - $query->withColumn($modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName(), $columnMap->getPhpName()); |
|
| 198 | - } elseif(!$columnMap->isForeignKey()) { |
|
| 199 | - $query->withColumn('IFNULL(' . $modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName() . ', "'.$this->lang.'")', $columnMap->getPhpName()); |
|
| 195 | + foreach ($modelI18nTableMap->getColumns() as $columnMap) { |
|
| 196 | + if (!$columnMap->isPrimaryKey()) { |
|
| 197 | + $query->withColumn($modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName(), $columnMap->getPhpName()); |
|
| 198 | + } elseif (!$columnMap->isForeignKey()) { |
|
| 199 | + $query->withColumn('IFNULL('.$modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName().', "'.$this->lang.'")', $columnMap->getPhpName()); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -210,20 +210,20 @@ discard block |
||
| 210 | 210 | $model->fromArray($data); |
| 211 | 211 | $tableMap = $this->getTableMap(); |
| 212 | 212 | try { |
| 213 | - if($tableMap->hasRelation($tableMap->getPhpName() . 'I18n')) |
|
| 213 | + if ($tableMap->hasRelation($tableMap->getPhpName().'I18n')) |
|
| 214 | 214 | { |
| 215 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
| 215 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
| 216 | 216 | $i18NTableMap = $relateI18n->getLocalTable(); |
| 217 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
| 218 | - $method = 'set' . $columnMap->getPhpName(); |
|
| 219 | - if(!($columnMap->isPrimaryKey() && $columnMap->isForeignKey()) |
|
| 217 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
| 218 | + $method = 'set'.$columnMap->getPhpName(); |
|
| 219 | + if (!($columnMap->isPrimaryKey() && $columnMap->isForeignKey()) |
|
| 220 | 220 | &&array_key_exists($columnMap->getPhpName(), $data) |
| 221 | 221 | && method_exists($model, $method)) { |
| 222 | 222 | $model->$method($data[$columnMap->getPhpName()]); |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | - } catch(\Exception $e) { |
|
| 226 | + }catch (\Exception $e) { |
|
| 227 | 227 | Logger::log($e->getMessage(), LOG_DEBUG); |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -27,22 +27,22 @@ discard block |
||
| 27 | 27 | * @param bool $use_base |
| 28 | 28 | */ |
| 29 | 29 | protected static function checkLoad($custom_key = null, $force_reload = false, $use_base = false) { |
| 30 | - if($force_reload) self::dropInstance(); |
|
| 30 | + if ($force_reload) self::dropInstance(); |
|
| 31 | 31 | self::$locale = I18nHelper::extractLocale(Security::getInstance()->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY)); |
| 32 | 32 | self::$generate = (boolean)Config::getParam('i18n.autogenerate', false); |
| 33 | - if(!$use_base) { |
|
| 33 | + if (!$use_base) { |
|
| 34 | 34 | $custom_key = $custom_key ?: Security::getInstance()->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY); |
| 35 | 35 | } |
| 36 | - if(null !== $custom_key) { |
|
| 37 | - Logger::log('[' . self::class . '] Custom key detected: ' . $custom_key, LOG_INFO); |
|
| 38 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $custom_key, self::$locale . '.json']); |
|
| 39 | - } else { |
|
| 40 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']); |
|
| 36 | + if (null !== $custom_key) { |
|
| 37 | + Logger::log('['.self::class.'] Custom key detected: '.$custom_key, LOG_INFO); |
|
| 38 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $custom_key, self::$locale.'.json']); |
|
| 39 | + }else { |
|
| 40 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']); |
|
| 41 | 41 | } |
| 42 | - if(file_exists(self::$filename)) { |
|
| 43 | - Logger::log('[' . self::class . '] Custom locale detected: ' . $custom_key . ' [' . self::$locale . ']', LOG_INFO); |
|
| 42 | + if (file_exists(self::$filename)) { |
|
| 43 | + Logger::log('['.self::class.'] Custom locale detected: '.$custom_key.' ['.self::$locale.']', LOG_INFO); |
|
| 44 | 44 | self::$translations = json_decode(file_get_contents(self::$filename), true); |
| 45 | - } elseif(null !== $custom_key) { |
|
| 45 | + } elseif (null !== $custom_key) { |
|
| 46 | 46 | self::checkLoad(null, $force_reload, true); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public static function _($message, $custom_key = null, $force_reload = false) { |
| 85 | 85 | self::checkLoad($custom_key, $force_reload); |
| 86 | - if(array_key_exists($message, self::$translations)) { |
|
| 87 | - $translation = self::$translations[$message]; |
|
| 88 | - } else { |
|
| 86 | + if (array_key_exists($message, self::$translations)) { |
|
| 87 | + $translation = self::$translations[$message]; |
|
| 88 | + }else { |
|
| 89 | 89 | $translation = gettext($message); |
| 90 | 90 | } |
| 91 | - if(self::$generate) { |
|
| 91 | + if (self::$generate) { |
|
| 92 | 92 | self::generate($message, $translation); |
| 93 | 93 | } |
| 94 | 94 | return $translation; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param string $translation |
| 100 | 100 | */ |
| 101 | 101 | protected static function generate($message, $translation) { |
| 102 | - if(!array_key_exists($message, self::$translations)) { |
|
| 102 | + if (!array_key_exists($message, self::$translations)) { |
|
| 103 | 103 | self::$translations[$message] = $translation; |
| 104 | 104 | } |
| 105 | 105 | file_put_contents(self::$filename, json_encode(array_unique(self::$translations), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); |
@@ -27,7 +27,9 @@ |
||
| 27 | 27 | * @param bool $use_base |
| 28 | 28 | */ |
| 29 | 29 | protected static function checkLoad($custom_key = null, $force_reload = false, $use_base = false) { |
| 30 | - if($force_reload) self::dropInstance(); |
|
| 30 | + if($force_reload) { |
|
| 31 | + self::dropInstance(); |
|
| 32 | + } |
|
| 31 | 33 | self::$locale = I18nHelper::extractLocale(Security::getInstance()->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY)); |
| 32 | 34 | self::$generate = (boolean)Config::getParam('i18n.autogenerate', false); |
| 33 | 35 | if(!$use_base) { |
@@ -3,8 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use PSFS\base\config\Config; |
| 5 | 5 | use PSFS\base\Logger; |
| 6 | -use PSFS\base\Request; |
|
| 7 | -use PSFS\base\Router; |
|
| 8 | 6 | use PSFS\base\types\helpers\SlackHelper; |
| 9 | 7 | |
| 10 | 8 | /** |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $use /= 1024; |
| 39 | 39 | break; |
| 40 | 40 | case "MBytes": |
| 41 | - $use /= (1024 * 1024); |
|
| 41 | + $use /= (1024*1024); |
|
| 42 | 42 | break; |
| 43 | 43 | case "Bytes": |
| 44 | 44 | default: |
@@ -62,34 +62,34 @@ discard block |
||
| 62 | 62 | protected function bindWarningAsExceptions() |
| 63 | 63 | { |
| 64 | 64 | Logger::log('Added handlers for errors'); |
| 65 | - if(Config::getParam('debug')) { |
|
| 65 | + if (Config::getParam('debug')) { |
|
| 66 | 66 | Logger::log('Setting error_reporting as E_ALL'); |
| 67 | 67 | ini_set('error_reporting', E_ALL); |
| 68 | 68 | ini_set('display_errors', 1); |
| 69 | 69 | } |
| 70 | 70 | //Warning & Notice handler |
| 71 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
| 71 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
| 72 | 72 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]); |
| 73 | 73 | return true; |
| 74 | 74 | }, E_ALL | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); |
| 75 | 75 | |
| 76 | - register_shutdown_function(function () { |
|
| 76 | + register_shutdown_function(function() { |
|
| 77 | 77 | $error = error_get_last() or json_last_error() or preg_last_error() or \DateTime::getLastErrors(); |
| 78 | - if( $error !== NULL) { |
|
| 78 | + if ($error !== NULL) { |
|
| 79 | 79 | $errno = $error["type"]; |
| 80 | 80 | $errfile = $error["file"]; |
| 81 | 81 | $errline = $error["line"]; |
| 82 | 82 | $errstr = $error["message"]; |
| 83 | 83 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]); |
| 84 | - if(null !== Config::getParam('log.slack.hook')) { |
|
| 84 | + if (null !== Config::getParam('log.slack.hook')) { |
|
| 85 | 85 | SlackHelper::getInstance()->trace($errstr, $errfile, $errline, $error); |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if(self::getTs() > 10 && null !== Config::getParam('log.slack.hook')) { |
|
| 89 | + if (self::getTs() > 10 && null !== Config::getParam('log.slack.hook')) { |
|
| 90 | 90 | SlackHelper::getInstance()->trace('Slow service endpoint', '', '', [ |
| 91 | - 'time' => round(self::getTs(), 3) . ' secs', |
|
| 92 | - 'memory' => round(self::getMem('MBytes'), 3) . ' Mb', |
|
| 91 | + 'time' => round(self::getTs(), 3).' secs', |
|
| 92 | + 'memory' => round(self::getMem('MBytes'), 3).' Mb', |
|
| 93 | 93 | ]); |
| 94 | 94 | } |
| 95 | 95 | return false; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | Logger::log('Initializing stats (mem + ts)'); |
| 105 | 105 | if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) { |
| 106 | 106 | $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT']; |
| 107 | - } else { |
|
| 107 | + }else { |
|
| 108 | 108 | $this->ts = PSFS_START_TS; |
| 109 | 109 | } |
| 110 | 110 | $this->mem = PSFS_START_MEM; |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | $this->success = $result; |
| 44 | 44 | $this->total = $total ?: (is_array($data) ? count($data) : 0); |
| 45 | 45 | $this->pages = $pages; |
| 46 | - if(null !== $message) { |
|
| 46 | + if (null !== $message) { |
|
| 47 | 47 | $this->message = $message; |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | 'text' => 'PSFS Error notifier', |
| 29 | 29 | 'attachments' => [ |
| 30 | 30 | [ |
| 31 | - "text" => $file . (strlen($line) ? ' [' . $line . ']' : ''), |
|
| 31 | + "text" => $file.(strlen($line) ? ' ['.$line.']' : ''), |
|
| 32 | 32 | "color" => "danger", |
| 33 | 33 | "title" => $message, |
| 34 | 34 | 'fallback' => 'PSFS Error notifier', |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function __construct($type = 'js') |
| 36 | 36 | { |
| 37 | 37 | $this->type = $type; |
| 38 | - $this->path = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 38 | + $this->path = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 39 | 39 | $this->domains = Template::getDomains(true); |
| 40 | 40 | $this->debug = Config::getParam('debug'); |
| 41 | 41 | $this->cdnPath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $source_file = explode("?", $source_file); |
| 59 | 59 | $source_file = $source_file[0]; |
| 60 | 60 | } |
| 61 | - $orig = realpath(dirname($filename_path) . DIRECTORY_SEPARATOR . $source_file); |
|
| 61 | + $orig = realpath(dirname($filename_path).DIRECTORY_SEPARATOR.$source_file); |
|
| 62 | 62 | return $orig; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function addFile($filename) |
| 73 | 73 | { |
| 74 | - if (file_exists($this->path . $filename) && preg_match('/\.' . $this->type . '$/i', $filename)) { |
|
| 74 | + if (file_exists($this->path.$filename) && preg_match('/\.'.$this->type.'$/i', $filename)) { |
|
| 75 | 75 | $this->files[] = $filename; |
| 76 | 76 | } elseif (!empty($this->domains)) { |
| 77 | 77 | foreach ($this->domains as $domain => $paths) { |
| 78 | 78 | $domain_filename = str_replace($domain, $paths["public"], $filename); |
| 79 | - if (file_exists($domain_filename) && preg_match('/\.' . $this->type . '$/i', $domain_filename)) { |
|
| 79 | + if (file_exists($domain_filename) && preg_match('/\.'.$this->type.'$/i', $domain_filename)) { |
|
| 80 | 80 | $this->files[] = $domain_filename; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | public function setHash($hash) |
| 94 | 94 | { |
| 95 | 95 | $cache = Config::getParam('cache.var', ''); |
| 96 | - $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache; |
|
| 96 | + $this->hash = $hash.(strlen($cache) ? '.' : '').$cache; |
|
| 97 | 97 | return $this; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | protected function compileCss() |
| 129 | 129 | { |
| 130 | - $base = $this->path . "css" . DIRECTORY_SEPARATOR; |
|
| 131 | - if ($this->debug || !file_exists($base . $this->hash . ".css")) { |
|
| 130 | + $base = $this->path."css".DIRECTORY_SEPARATOR; |
|
| 131 | + if ($this->debug || !file_exists($base.$this->hash.".css")) { |
|
| 132 | 132 | $data = ''; |
| 133 | 133 | if (0 < count($this->files)) { |
| 134 | 134 | $minifier = new CSS(); |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | $data = $this->processCssLine($file, $base, $data); |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | - if($this->debug) { |
|
| 140 | - $this->storeContents($base . $this->hash . ".css", $data); |
|
| 141 | - } else { |
|
| 139 | + if ($this->debug) { |
|
| 140 | + $this->storeContents($base.$this->hash.".css", $data); |
|
| 141 | + }else { |
|
| 142 | 142 | $minifier = new CSS(); |
| 143 | 143 | $minifier->add($data); |
| 144 | 144 | ini_set('max_execution_time', -1); |
| 145 | 145 | ini_set('memory_limit', -1); |
| 146 | 146 | GeneratorHelper::createDir($base); |
| 147 | - $minifier->minify($base . $this->hash . ".css"); |
|
| 147 | + $minifier->minify($base.$this->hash.".css"); |
|
| 148 | 148 | unset($cssMinifier); |
| 149 | 149 | ini_restore('memory_limit'); |
| 150 | 150 | ini_restore('max_execution_time'); |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | protected function compileJs() |
| 162 | 162 | { |
| 163 | - $base = $this->path . "js" . DIRECTORY_SEPARATOR; |
|
| 164 | - if ($this->debug || !file_exists($base . $this->hash . ".js")) { |
|
| 163 | + $base = $this->path."js".DIRECTORY_SEPARATOR; |
|
| 164 | + if ($this->debug || !file_exists($base.$this->hash.".js")) { |
|
| 165 | 165 | $data = ''; |
| 166 | 166 | if (0 < count($this->files)) { |
| 167 | 167 | $minifier = new JS(); |
@@ -170,19 +170,19 @@ discard block |
||
| 170 | 170 | if (file_exists($file)) { |
| 171 | 171 | if ($this->debug) { |
| 172 | 172 | $data = $this->putDebugJs($path_parts, $base, $file); |
| 173 | - } elseif (!file_exists($base . $this->hash . ".js")) { |
|
| 173 | + } elseif (!file_exists($base.$this->hash.".js")) { |
|
| 174 | 174 | $minifier->add($file); |
| 175 | 175 | //$data = $this->putProductionJs($base, $file, $data); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | - if($this->debug) { |
|
| 180 | - $this->storeContents($base . $this->hash . ".js", $data); |
|
| 181 | - } else { |
|
| 179 | + if ($this->debug) { |
|
| 180 | + $this->storeContents($base.$this->hash.".js", $data); |
|
| 181 | + }else { |
|
| 182 | 182 | ini_set('max_execution_time', -1); |
| 183 | 183 | ini_set('memory_limit', -1); |
| 184 | 184 | GeneratorHelper::createDir($base); |
| 185 | - $minifier->minify($base . $this->hash . ".js"); |
|
| 185 | + $minifier->minify($base.$this->hash.".js"); |
|
| 186 | 186 | ini_restore('memory_limit'); |
| 187 | 187 | ini_restore('max_execution_time'); |
| 188 | 188 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | GeneratorHelper::createDir(dirname($path)); |
| 204 | 204 | if ("" !== $content && false === file_put_contents($path, $content)) { |
| 205 | - throw new ConfigException(_('No se tienen permisos para escribir en ' . $path)); |
|
| 205 | + throw new ConfigException(_('No se tienen permisos para escribir en '.$path)); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | foreach ($this->compiled_files as $file) { |
| 232 | 232 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
| 233 | 233 | } |
| 234 | - } else { |
|
| 234 | + }else { |
|
| 235 | 235 | $basePath = $this->cdnPath ?: ''; |
| 236 | - echo "\t\t<script type='text/javascript' src='" . $basePath . "/js/" . $this->hash . ".js'></script>\n"; |
|
| 236 | + echo "\t\t<script type='text/javascript' src='".$basePath."/js/".$this->hash.".js'></script>\n"; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | foreach ($this->compiled_files as $file) { |
| 247 | 247 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
| 248 | 248 | } |
| 249 | - } else { |
|
| 249 | + }else { |
|
| 250 | 250 | $basePath = $this->cdnPath ?: ''; |
| 251 | - echo "\t\t<link href='" . $basePath . "/css/" . $this->hash . ".css' rel='stylesheet'>"; |
|
| 251 | + echo "\t\t<link href='".$basePath."/css/".$this->hash.".css' rel='stylesheet'>"; |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
@@ -259,20 +259,20 @@ discard block |
||
| 259 | 259 | protected function extractCssResources($source, $file) |
| 260 | 260 | { |
| 261 | 261 | $source_file = $this->extractSourceFilename($source); |
| 262 | - $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $source_file); |
|
| 262 | + $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$source_file); |
|
| 263 | 263 | $orig_part = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig); |
| 264 | 264 | try { |
| 265 | 265 | if (count($source) > 1 && array_key_exists(1, $orig_part)) { |
| 266 | - $dest = $this->path . $orig_part[1]; |
|
| 266 | + $dest = $this->path.$orig_part[1]; |
|
| 267 | 267 | GeneratorHelper::createDir(dirname($dest)); |
| 268 | 268 | if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) { |
| 269 | 269 | if (@copy($orig, $dest) === FALSE) { |
| 270 | - throw new \RuntimeException('Can\' copy ' . $dest . ''); |
|
| 270 | + throw new \RuntimeException('Can\' copy '.$dest.''); |
|
| 271 | 271 | } |
| 272 | 272 | Logger::log("$orig copiado a $dest", LOG_INFO); |
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | - } catch (\Exception $e) { |
|
| 275 | + }catch (\Exception $e) { |
|
| 276 | 276 | Logger::log($e->getMessage(), LOG_ERR); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -289,21 +289,21 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | if (file_exists($file)) { |
| 291 | 291 | $path_parts = explode("/", $file); |
| 292 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
| 293 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file) || $this->debug) { |
|
| 292 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
| 293 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file) || $this->debug) { |
|
| 294 | 294 | //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados |
| 295 | - if (file_exists($base . $this->hash . ".css") && @unlink($base . $this->hash . ".css") === false) { |
|
| 296 | - throw new ConfigException("Can't unlink file " . $base . $this->hash . ".css"); |
|
| 295 | + if (file_exists($base.$this->hash.".css") && @unlink($base.$this->hash.".css") === false) { |
|
| 296 | + throw new ConfigException("Can't unlink file ".$base.$this->hash.".css"); |
|
| 297 | 297 | } |
| 298 | 298 | $this->loopCssLines($file); |
| 299 | 299 | } |
| 300 | 300 | if ($this->debug) { |
| 301 | 301 | $data = file_get_contents($file); |
| 302 | - $this->storeContents($base . $file_path, $data); |
|
| 303 | - } else { |
|
| 302 | + $this->storeContents($base.$file_path, $data); |
|
| 303 | + }else { |
|
| 304 | 304 | $data .= file_get_contents($file); |
| 305 | 305 | } |
| 306 | - $this->compiled_files[] = "/css/" . $file_path; |
|
| 306 | + $this->compiled_files[] = "/css/".$file_path; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | return $data; |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | protected function putDebugJs($path_parts, $base, $file) |
| 320 | 320 | { |
| 321 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
| 322 | - $this->compiled_files[] = "/js/" . $file_path; |
|
| 321 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
| 322 | + $this->compiled_files[] = "/js/".$file_path; |
|
| 323 | 323 | $data = ""; |
| 324 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file)) { |
|
| 324 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file)) { |
|
| 325 | 325 | $data = file_get_contents($file); |
| 326 | - $this->storeContents($base . $file_path, $data); |
|
| 326 | + $this->storeContents($base.$file_path, $data); |
|
| 327 | 327 | } |
| 328 | 328 | return $data; |
| 329 | 329 | } |
@@ -365,60 +365,60 @@ discard block |
||
| 365 | 365 | { |
| 366 | 366 | $ppath = explode("/", $string); |
| 367 | 367 | $original_filename = $ppath[count($ppath) - 1]; |
| 368 | - $base = WEB_DIR . DIRECTORY_SEPARATOR; |
|
| 368 | + $base = WEB_DIR.DIRECTORY_SEPARATOR; |
|
| 369 | 369 | $file = ""; |
| 370 | 370 | $html_base = ""; |
| 371 | 371 | $debug = Config::getInstance()->getDebugMode(); |
| 372 | 372 | $cache = Config::getInstance()->get('cache.var'); |
| 373 | - $cache = $cache ? '.' . $cache : ''; |
|
| 373 | + $cache = $cache ? '.'.$cache : ''; |
|
| 374 | 374 | $finfo = finfo_open(FILEINFO_MIME_TYPE); // devuelve el tipo mime de su extensión |
| 375 | 375 | $mime = finfo_file($finfo, $filename_path); |
| 376 | 376 | finfo_close($finfo); |
| 377 | 377 | if (preg_match('/\.css$/i', $string)) { |
| 378 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.css"; |
|
| 378 | + $file = "/".substr(md5($string), 0, 8)."$cache.css"; |
|
| 379 | 379 | $html_base = "css"; |
| 380 | 380 | if ($debug) { |
| 381 | - $file = str_replace(".css", "_" . $original_filename, $file); |
|
| 381 | + $file = str_replace(".css", "_".$original_filename, $file); |
|
| 382 | 382 | } |
| 383 | 383 | } elseif (preg_match('/\.js$/i', $string)) { |
| 384 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.js"; |
|
| 384 | + $file = "/".substr(md5($string), 0, 8)."$cache.js"; |
|
| 385 | 385 | $html_base = "js"; |
| 386 | 386 | if ($debug) { |
| 387 | - $file = str_replace(".js", "_" . $original_filename, $file); |
|
| 387 | + $file = str_replace(".js", "_".$original_filename, $file); |
|
| 388 | 388 | } |
| 389 | 389 | } elseif (preg_match("/image/i", $mime)) { |
| 390 | 390 | $ext = explode(".", $string); |
| 391 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 391 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 392 | 392 | $html_base = "img"; |
| 393 | 393 | if ($debug) { |
| 394 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 394 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 395 | 395 | } |
| 396 | 396 | } elseif (preg_match("/(doc|pdf)/i", $mime)) { |
| 397 | 397 | $ext = explode(".", $string); |
| 398 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 398 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 399 | 399 | $html_base = "docs"; |
| 400 | 400 | if ($debug) { |
| 401 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 401 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 402 | 402 | } |
| 403 | 403 | } elseif (preg_match("/(video|audio|ogg)/i", $mime)) { |
| 404 | 404 | $ext = explode(".", $string); |
| 405 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 405 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 406 | 406 | $html_base = "media"; |
| 407 | 407 | if ($debug) { |
| 408 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 408 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 409 | 409 | } |
| 410 | 410 | } elseif (preg_match("/(text|html)/i", $mime)) { |
| 411 | 411 | $ext = explode(".", $string); |
| 412 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
| 412 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
| 413 | 413 | $html_base = "templates"; |
| 414 | 414 | if ($debug) { |
| 415 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
| 415 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
| 416 | 416 | } |
| 417 | 417 | } elseif (!$return && !is_null($name)) { |
| 418 | 418 | $html_base = ''; |
| 419 | 419 | $file = $name; |
| 420 | 420 | } |
| 421 | - $file_path = $html_base . $file; |
|
| 421 | + $file_path = $html_base.$file; |
|
| 422 | 422 | |
| 423 | 423 | return array($base, $html_base, $file_path); |
| 424 | 424 | } |
@@ -436,15 +436,15 @@ discard block |
||
| 436 | 436 | if (preg_match_all('#url\((.*?)\)#', $line, $urls, PREG_SET_ORDER)) { |
| 437 | 437 | foreach ($urls as $source) { |
| 438 | 438 | $orig = self::calculateResourcePathname($filename_path, $source); |
| 439 | - if(!empty($orig)) { |
|
| 439 | + if (!empty($orig)) { |
|
| 440 | 440 | $orig_part = preg_split("/Public/i", $orig); |
| 441 | - $dest = WEB_DIR . $orig_part[1]; |
|
| 441 | + $dest = WEB_DIR.$orig_part[1]; |
|
| 442 | 442 | GeneratorHelper::createDir(dirname($dest)); |
| 443 | 443 | if (@copy($orig, $dest) === false) { |
| 444 | - throw new ConfigException("Can't copy " . $orig . " to " . $dest); |
|
| 444 | + throw new ConfigException("Can't copy ".$orig." to ".$dest); |
|
| 445 | 445 | } |
| 446 | - } else { |
|
| 447 | - Logger::log($filename_path . ' has an empty origin with the url ' . $source, LOG_WARNING); |
|
| 446 | + }else { |
|
| 447 | + Logger::log($filename_path.' has an empty origin with the url '.$source, LOG_WARNING); |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use PSFS\base\Request; |
| 15 | 15 | use PSFS\base\Singleton; |
| 16 | 16 | use PSFS\base\types\helpers\ApiHelper; |
| 17 | -use PSFS\base\types\helpers\Inspector; |
|
| 18 | 17 | use PSFS\base\types\traits\Api\ManagerTrait; |
| 19 | 18 | |
| 20 | 19 | /** |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | public function init() |
| 83 | 83 | { |
| 84 | 84 | parent::init(); |
| 85 | - Logger::log(static::class . ' init', LOG_DEBUG); |
|
| 85 | + Logger::log(static::class.' init', LOG_DEBUG); |
|
| 86 | 86 | $this->domain = $this->getDomain(); |
| 87 | 87 | $this->hydrateRequestData(); |
| 88 | 88 | $this->hydrateOrders(); |
| 89 | - if($this instanceof CustomApi === false) { |
|
| 89 | + if ($this instanceof CustomApi === false) { |
|
| 90 | 90 | $this->createConnection($this->getTableMap()); |
| 91 | 91 | } |
| 92 | 92 | $this->setLoaded(true); |
| 93 | - Logger::log(static::class . ' loaded', LOG_DEBUG); |
|
| 93 | + Logger::log(static::class.' loaded', LOG_DEBUG); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | private function checkActions($method) { |
| 97 | - switch($method) { |
|
| 97 | + switch ($method) { |
|
| 98 | 98 | default: |
| 99 | 99 | case 'modelList': $this->action = self::API_ACTION_LIST; break; |
| 100 | 100 | case 'get': $this->action = self::API_ACTION_GET; break; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | protected function hydrateOrders() |
| 112 | 112 | { |
| 113 | 113 | if (count($this->query)) { |
| 114 | - Logger::log(static::class . ' gathering query string', LOG_DEBUG); |
|
| 114 | + Logger::log(static::class.' gathering query string', LOG_DEBUG); |
|
| 115 | 115 | foreach ($this->query as $key => $value) { |
| 116 | 116 | if ($key === self::API_ORDER_FIELD && is_array($value)) { |
| 117 | 117 | foreach ($value as $field => $direction) { |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function extractPagination() |
| 130 | 130 | { |
| 131 | - Logger::log(static::class . ' extract pagination start', LOG_DEBUG); |
|
| 131 | + Logger::log(static::class.' extract pagination start', LOG_DEBUG); |
|
| 132 | 132 | $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1; |
| 133 | 133 | $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100; |
| 134 | - Logger::log(static::class . ' extract pagination end', LOG_DEBUG); |
|
| 134 | + Logger::log(static::class.' extract pagination end', LOG_DEBUG); |
|
| 135 | 135 | return array($page, $limit); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | private function addOrders(ModelCriteria &$query) |
| 144 | 144 | { |
| 145 | - Logger::log(static::class . ' extract orders start ', LOG_DEBUG); |
|
| 145 | + Logger::log(static::class.' extract orders start ', LOG_DEBUG); |
|
| 146 | 146 | $orderAdded = FALSE; |
| 147 | 147 | $tableMap = $this->getTableMap(); |
| 148 | 148 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -150,17 +150,17 @@ discard block |
||
| 150 | 150 | $orderAdded = TRUE; |
| 151 | 151 | if ($direction === Order::ASC) { |
| 152 | 152 | $query->addAscendingOrderByColumn($column->getPhpName()); |
| 153 | - } else { |
|
| 153 | + }else { |
|
| 154 | 154 | $query->addDescendingOrderByColumn($column->getPhpName()); |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | if (!$orderAdded) { |
| 159 | - foreach($this->getPkDbName() as $pk => $phpName) { |
|
| 159 | + foreach ($this->getPkDbName() as $pk => $phpName) { |
|
| 160 | 160 | $query->addAscendingOrderByColumn($pk); |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | - Logger::log(static::class . ' extract orders end', LOG_DEBUG); |
|
| 163 | + Logger::log(static::class.' extract orders end', LOG_DEBUG); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | foreach ($this->query as $field => $value) { |
| 176 | 176 | if (self::API_COMBO_FIELD === $field) { |
| 177 | 177 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
| 178 | - } elseif(!preg_match('/^__/', $field)) { |
|
| 178 | + } elseif (!preg_match('/^__/', $field)) { |
|
| 179 | 179 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -196,10 +196,10 @@ discard block |
||
| 196 | 196 | list($page, $limit) = $this->extractPagination(); |
| 197 | 197 | if ($limit == -1) { |
| 198 | 198 | $this->list = $query->find($this->con); |
| 199 | - } else { |
|
| 199 | + }else { |
|
| 200 | 200 | $this->list = $query->paginate($page, $limit, $this->con); |
| 201 | 201 | } |
| 202 | - } catch (\Exception $e) { |
|
| 202 | + }catch (\Exception $e) { |
|
| 203 | 203 | Logger::log($e->getMessage(), LOG_ERR); |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $code = 200; |
| 219 | 219 | list($return, $total, $pages) = $this->getList(); |
| 220 | 220 | $message = null; |
| 221 | - if(!$total) { |
|
| 221 | + if (!$total) { |
|
| 222 | 222 | $message = i18n::_('No se han encontrado elementos para la búsqueda'); |
| 223 | 223 | } |
| 224 | 224 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $pages = 1; |
| 245 | 245 | $message = null; |
| 246 | 246 | list($code, $return) = $this->getSingleResult($pk); |
| 247 | - if($code !== 200) { |
|
| 247 | + if ($code !== 200) { |
|
| 248 | 248 | $message = i18n::_('No se ha encontrado el elemento solicitado'); |
| 249 | 249 | } |
| 250 | 250 | |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | $status = 200; |
| 274 | 274 | $saved = TRUE; |
| 275 | 275 | $model = $this->model->toArray(); |
| 276 | - } else { |
|
| 276 | + }else { |
|
| 277 | 277 | $message = i18n::_('No se ha podido guardar el modelo seleccionado'); |
| 278 | 278 | } |
| 279 | - } catch (\Exception $e) { |
|
| 280 | - $message = i18n::_('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage(); |
|
| 279 | + }catch (\Exception $e) { |
|
| 280 | + $message = i18n::_('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
| 281 | 281 | $context = []; |
| 282 | - if(null !== $e->getPrevious()) { |
|
| 282 | + if (null !== $e->getPrevious()) { |
|
| 283 | 283 | $context[] = $e->getPrevious()->getMessage(); |
| 284 | 284 | } |
| 285 | 285 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -315,18 +315,18 @@ discard block |
||
| 315 | 315 | $updated = TRUE; |
| 316 | 316 | $status = 200; |
| 317 | 317 | $model = $this->model->toArray(); |
| 318 | - } else { |
|
| 318 | + }else { |
|
| 319 | 319 | $message = i18n::_('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 320 | 320 | } |
| 321 | - } catch (\Exception $e) { |
|
| 321 | + }catch (\Exception $e) { |
|
| 322 | 322 | $message = i18n::_('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 323 | 323 | $context = []; |
| 324 | - if(null !== $e->getPrevious()) { |
|
| 324 | + if (null !== $e->getPrevious()) { |
|
| 325 | 325 | $context[] = $e->getPrevious()->getMessage(); |
| 326 | 326 | } |
| 327 | 327 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
| 328 | 328 | } |
| 329 | - } else { |
|
| 329 | + }else { |
|
| 330 | 330 | $message = i18n::_('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
| 331 | 331 | } |
| 332 | 332 | |
@@ -354,15 +354,15 @@ discard block |
||
| 354 | 354 | $this->con->beginTransaction(); |
| 355 | 355 | $this->hydrateModel($pk); |
| 356 | 356 | if (NULL !== $this->model) { |
| 357 | - if(method_exists('clearAllReferences', $this->model)) { |
|
| 357 | + if (method_exists('clearAllReferences', $this->model)) { |
|
| 358 | 358 | $this->model->clearAllReferences(true); |
| 359 | 359 | } |
| 360 | 360 | $this->model->delete($this->con); |
| 361 | 361 | $deleted = TRUE; |
| 362 | 362 | } |
| 363 | - } catch (\Exception $e) { |
|
| 363 | + }catch (\Exception $e) { |
|
| 364 | 364 | $context = []; |
| 365 | - if(null !== $e->getPrevious()) { |
|
| 365 | + if (null !== $e->getPrevious()) { |
|
| 366 | 366 | $context[] = $e->getPrevious()->getMessage(); |
| 367 | 367 | } |
| 368 | 368 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $this->saveBulk(); |
| 393 | 393 | $saved = true; |
| 394 | 394 | $status = 200; |
| 395 | - } catch(\Exception $e) { |
|
| 395 | + }catch (\Exception $e) { |
|
| 396 | 396 | Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData()); |
| 397 | 397 | $message = i18n::_('Bulk insert rolled back'); |
| 398 | 398 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | /** @var CustomerTableMap $tableMap */ |
| 416 | 416 | $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap()); |
| 417 | - foreach($this->list->getData() as $data) { |
|
| 417 | + foreach ($this->list->getData() as $data) { |
|
| 418 | 418 | $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data); |
| 419 | 419 | } |
| 420 | 420 | return $return; |
@@ -431,23 +431,23 @@ discard block |
||
| 431 | 431 | try { |
| 432 | 432 | $this->paginate(); |
| 433 | 433 | if (null !== $this->list) { |
| 434 | - if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
| 434 | + if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
| 435 | 435 | $return = $this->extractDataWithFormat(); |
| 436 | - } else { |
|
| 436 | + }else { |
|
| 437 | 437 | $return = $this->list->toArray(null, false, TableMap::TYPE_PHPNAME, false); |
| 438 | 438 | } |
| 439 | 439 | $total = 0; |
| 440 | 440 | $pages = 0; |
| 441 | - if($this->list instanceof PropelModelPager) { |
|
| 441 | + if ($this->list instanceof PropelModelPager) { |
|
| 442 | 442 | $total = $this->list->getNbResults(); |
| 443 | 443 | $pages = $this->list->getLastPage(); |
| 444 | - } elseif($this->list instanceof ArrayCollection) { |
|
| 444 | + } elseif ($this->list instanceof ArrayCollection) { |
|
| 445 | 445 | $total = count($return); |
| 446 | 446 | $pages = 1; |
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | - } catch (\Exception $e) { |
|
| 450 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 449 | + }catch (\Exception $e) { |
|
| 450 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | return array($return, $total, $pages); |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | $return = array(); |
| 466 | 466 | if (NULL === $model || !method_exists($model, 'toArray')) { |
| 467 | 467 | $code = 404; |
| 468 | - } else { |
|
| 468 | + }else { |
|
| 469 | 469 | $return = $model->toArray(TableMap::TYPE_PHPNAME, true, [], true); |
| 470 | 470 | } |
| 471 | 471 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function __construct() |
| 24 | 24 | { |
| 25 | - Logger::log(static::class . ' constructor invoked'); |
|
| 25 | + Logger::log(static::class.' constructor invoked'); |
|
| 26 | 26 | $this->init(); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | $calledClass = static::class; |
| 82 | 82 | try { |
| 83 | 83 | $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
| 84 | - $setter = 'set' . ucfirst($variable); |
|
| 84 | + $setter = 'set'.ucfirst($variable); |
|
| 85 | 85 | if (method_exists($calledClass, $setter)) { |
| 86 | 86 | $this->$setter($instance); |
| 87 | - } else { |
|
| 87 | + }else { |
|
| 88 | 88 | $this->$variable = $instance; |
| 89 | 89 | } |
| 90 | - } catch (\Exception $e) { |
|
| 91 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
| 90 | + }catch (\Exception $e) { |
|
| 91 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
| 92 | 92 | throw $e; |
| 93 | 93 | } |
| 94 | 94 | return $this; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | { |
| 104 | 104 | if (!$this->isLoaded()) { |
| 105 | 105 | $filename = sha1(get_class($this)); |
| 106 | - $cacheFilename = 'reflections' . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . ".json"; |
|
| 106 | + $cacheFilename = 'reflections'.DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.".json"; |
|
| 107 | 107 | /** @var \PSFS\base\Cache $cacheService */ |
| 108 | 108 | $cacheService = Cache::getInstance(); |
| 109 | 109 | /** @var \PSFS\base\config\Config $configService */ |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | $this->setLoaded(); |
| 124 | - } else { |
|
| 125 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
| 124 | + }else { |
|
| 125 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | } |