@@ -57,7 +57,7 @@ |
||
| 57 | 57 | $router->simpatize(); |
| 58 | 58 | Security::getInstance()->setFlash("callback_message", t("Rutas generadas correctamente")); |
| 59 | 59 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true)); |
| 60 | - } catch (Exception $e) { |
|
| 60 | + }catch (Exception $e) { |
|
| 61 | 61 | Logger::log($e->getMessage(), LOG_ERR); |
| 62 | 62 | Security::getInstance()->setFlash("callback_message", t("Algo no ha salido bien, revisa los logs")); |
| 63 | 63 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true)); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | foreach ($domains as $domain => $routes) { |
| 34 | 34 | $pDomain = str_replace('@', '', $domain); |
| 35 | 35 | $pDomain = str_replace('/', '', $pDomain); |
| 36 | - $response[] = strtolower($pDomain) . '.api.secret'; |
|
| 36 | + $response[] = strtolower($pDomain).'.api.secret'; |
|
| 37 | 37 | } |
| 38 | 38 | return $this->json($response); |
| 39 | 39 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function config() |
| 51 | 51 | { |
| 52 | - Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri()); |
|
| 52 | + Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri()); |
|
| 53 | 53 | /* @var $form ConfigForm */ |
| 54 | 54 | $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig()); |
| 55 | 55 | $form->build(); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | Security::getInstance()->setFlash("callback_message", t("Configuración actualizada correctamente")); |
| 88 | 88 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true)); |
| 89 | - } else { |
|
| 89 | + }else { |
|
| 90 | 90 | throw new HttpException(t('Error al guardar la configuración, prueba a cambiar los permisos'), 403); |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function generateModule() |
| 36 | 36 | { |
| 37 | - Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri()); |
|
| 37 | + Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri()); |
|
| 38 | 38 | /* @var $form ConfigForm */ |
| 39 | 39 | $form = new ModuleForm(); |
| 40 | 40 | $form->build(); |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | $this->gen->createStructureModule($module, false, $type, $apiClass); |
| 67 | 67 | Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente"))); |
| 68 | 68 | // Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true)); |
| 69 | - } catch (Exception $e) { |
|
| 70 | - Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]"); |
|
| 69 | + }catch (Exception $e) { |
|
| 70 | + Logger::log($e->getMessage()." [".$e->getFile().":".$e->getLine()."]"); |
|
| 71 | 71 | Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage())); |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function __construct() |
| 28 | 28 | { |
| 29 | - Logger::log(static::class . ' constructor invoked'); |
|
| 29 | + Logger::log(static::class.' constructor invoked'); |
|
| 30 | 30 | $this->init(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | $calledClass = static::class; |
| 86 | 86 | try { |
| 87 | 87 | $instance = InjectorHelper::constructInjectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
| 88 | - $setter = 'set' . ucfirst($variable); |
|
| 88 | + $setter = 'set'.ucfirst($variable); |
|
| 89 | 89 | if (method_exists($calledClass, $setter)) { |
| 90 | 90 | $this->$setter($instance); |
| 91 | - } else { |
|
| 91 | + }else { |
|
| 92 | 92 | $this->$variable = $instance; |
| 93 | 93 | } |
| 94 | - } catch (Exception $e) { |
|
| 95 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
| 94 | + }catch (Exception $e) { |
|
| 95 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
| 96 | 96 | throw $e; |
| 97 | 97 | } |
| 98 | 98 | return $this; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | if (!$this->isLoaded()) { |
| 109 | 109 | $filename = sha1(get_class($this)); |
| 110 | - $cacheFilename = 'reflections' . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . '.json'; |
|
| 110 | + $cacheFilename = 'reflections'.DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.'.json'; |
|
| 111 | 111 | /** @var Cache $cacheService */ |
| 112 | 112 | $cacheService = Cache::getInstance(); |
| 113 | 113 | /** @var Config $configService */ |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | $this->setLoaded(); |
| 128 | - } else { |
|
| 129 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
| 128 | + }else { |
|
| 129 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | public function getServer($key, $default = null) |
| 22 | 22 | { |
| 23 | 23 | $value = null; |
| 24 | - if(array_key_exists($key, $this->server)) { |
|
| 24 | + if (array_key_exists($key, $this->server)) { |
|
| 25 | 25 | $value = $this->server[$key]; |
| 26 | 26 | } |
| 27 | 27 | return $value ?: $default; |
@@ -19,11 +19,11 @@ |
||
| 19 | 19 | public static function checkApiActions($namespace, $domain, $api) { |
| 20 | 20 | $actions = []; |
| 21 | 21 | $reflector = new ReflectionClass($namespace); |
| 22 | - if(null !== $reflector) { |
|
| 23 | - foreach($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
| 22 | + if (null !== $reflector) { |
|
| 23 | + foreach ($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
| 24 | 24 | $docComments = $apiAction->getDocComment(); |
| 25 | 25 | $action = AnnotationHelper::extractAction($docComments); |
| 26 | - if(null !== $action) { |
|
| 26 | + if (null !== $action) { |
|
| 27 | 27 | list($route, $info) = RouterHelper::extractRouteInfo($apiAction, $api, $domain); |
| 28 | 28 | list($method, $cleanRoute) = RouterHelper::extractHttpRoute($route); |
| 29 | 29 | $formAction = new FormAction(); |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | $label = self::getLabel($property->getDocComment()); |
| 32 | 32 | $values = self::getValues($property->getDocComment()); |
| 33 | 33 | $isArray = (bool)preg_match('/\[\]$/', $instanceType); |
| 34 | - if($isArray) { |
|
| 34 | + if ($isArray) { |
|
| 35 | 35 | $instanceType = str_replace('[]', '', $instanceType); |
| 36 | 36 | } |
| 37 | - if($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
| 37 | + if ($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
| 38 | 38 | list($type, $format) = DocumentorHelper::translateSwaggerFormats($instanceType); |
| 39 | 39 | $variables[$property->getName()] = [ |
| 40 | 40 | 'type' => $type, |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | 'required' => $isRequired, |
| 43 | 43 | 'description' => $label, |
| 44 | 44 | ]; |
| 45 | - } else { |
|
| 45 | + }else { |
|
| 46 | 46 | $instance = new ReflectionClass($instanceType); |
| 47 | 47 | $variables[$property->getName()] = [ |
| 48 | 48 | 'is_array' => $isArray, |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | 'properties' => self::extractVariables($instance), |
| 52 | 52 | ]; |
| 53 | 53 | } |
| 54 | - if(!empty($values)){ |
|
| 54 | + if (!empty($values)) { |
|
| 55 | 55 | $variables[$property->getName()]['enum'] = $values; |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public static function constructInjectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
| 157 | 157 | { |
| 158 | - Logger::log('Create inyectable instance for ' . $classNameSpace); |
|
| 158 | + Logger::log('Create inyectable instance for '.$classNameSpace); |
|
| 159 | 159 | $reflector = new ReflectionClass($calledClass); |
| 160 | 160 | $property = $reflector->getProperty($variable); |
| 161 | 161 | $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace; |
| 162 | 162 | if (true === $singleton && method_exists($varInstanceType, 'getInstance')) { |
| 163 | 163 | $instance = $varInstanceType::getInstance(); |
| 164 | - } else { |
|
| 164 | + }else { |
|
| 165 | 165 | $instance = new $varInstanceType(); |
| 166 | 166 | } |
| 167 | 167 | return $instance; |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | public static function getClassProperties($class) |
| 176 | 176 | { |
| 177 | 177 | $properties = []; |
| 178 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
| 178 | + Logger::log('Extracting annotations properties from class '.$class); |
|
| 179 | 179 | $selfReflector = new ReflectionClass($class); |
| 180 | 180 | if (false !== $selfReflector->getParentClass()) { |
| 181 | 181 | $properties = self::getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | * @return string|null |
| 93 | 93 | */ |
| 94 | 94 | public static function extractFromDoc($needle, $comments, $default = null) { |
| 95 | - preg_match('/@' . $needle . '\ (.*)(\n|\r)/im', $comments, $matches); |
|
| 95 | + preg_match('/@'.$needle.'\ (.*)(\n|\r)/im', $comments, $matches); |
|
| 96 | 96 | return (count($matches) > 0) ? $matches[1] : $default; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | if (count($pks) === 1) { |
| 82 | 82 | $pks = array_keys($pks); |
| 83 | 83 | return [ |
| 84 | - $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD |
|
| 84 | + $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD |
|
| 85 | 85 | ]; |
| 86 | 86 | } |
| 87 | 87 | if (count($pks) > 1) { |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | $principal = ''; |
| 90 | 90 | $sep = 'CONCAT('; |
| 91 | 91 | foreach ($pks as $pk) { |
| 92 | - $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName(); |
|
| 93 | - $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName(); |
|
| 94 | - $sep = ', "' . Api::API_PK_SEPARATOR . '", '; |
|
| 92 | + $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName(); |
|
| 93 | + $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName(); |
|
| 94 | + $sep = ', "'.Api::API_PK_SEPARATOR.'", '; |
|
| 95 | 95 | } |
| 96 | 96 | $principal .= ')'; |
| 97 | 97 | $apiPks[$principal] = Api::API_MODEL_KEY_FIELD; |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | $pks = ''; |
| 119 | 119 | $sep = ''; |
| 120 | 120 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
| 121 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
| 121 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
| 122 | 122 | $sep = ', "|", '; |
| 123 | 123 | } |
| 124 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD; |
|
| 124 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | if (null !== $column) { |
| 145 | 145 | $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD; |
| 146 | - } else { |
|
| 146 | + }else { |
|
| 147 | 147 | $this->addClassListName($tableMap); |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | $this->addPkToList(); |
| 162 | 162 | } |
| 163 | 163 | if (!empty($this->extraColumns)) { |
| 164 | - if(Config::getParam('api.extrafields.compat', true)) { |
|
| 164 | + if (Config::getParam('api.extrafields.compat', true)) { |
|
| 165 | 165 | $fields = array_values($this->extraColumns); |
| 166 | - } else { |
|
| 166 | + }else { |
|
| 167 | 167 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
| 168 | 168 | $fields = explode(',', $returnFields ?: ''); |
| 169 | 169 | $fields[] = self::API_MODEL_KEY_FIELD; |
| 170 | 170 | } |
| 171 | 171 | foreach ($this->extraColumns as $expression => $columnName) { |
| 172 | - if(empty($fields) || in_array($columnName, $fields)) { |
|
| 172 | + if (empty($fields) || in_array($columnName, $fields)) { |
|
| 173 | 173 | $query->withColumn($expression, $columnName); |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -200,18 +200,18 @@ discard block |
||
| 200 | 200 | { |
| 201 | 201 | $this->extractApiLang(); |
| 202 | 202 | $model = $this->getModelNamespace(); |
| 203 | - $modelI18n = $model . 'I18n'; |
|
| 203 | + $modelI18n = $model.'I18n'; |
|
| 204 | 204 | if (method_exists($query, 'useI18nQuery')) { |
| 205 | 205 | $query->useI18nQuery($this->lang); |
| 206 | 206 | $modelParts = explode('\\', $modelI18n); |
| 207 | - $i18nMapClass = str_replace(end($modelParts), 'Map\\' . end($modelParts), $modelI18n) . 'TableMap'; |
|
| 207 | + $i18nMapClass = str_replace(end($modelParts), 'Map\\'.end($modelParts), $modelI18n).'TableMap'; |
|
| 208 | 208 | /** @var TableMap $modelI18nTableMap */ |
| 209 | 209 | $modelI18nTableMap = $i18nMapClass::getTableMap(); |
| 210 | - foreach($modelI18nTableMap->getColumns() as $columnMap) { |
|
| 211 | - if(!$columnMap->isPrimaryKey()) { |
|
| 210 | + foreach ($modelI18nTableMap->getColumns() as $columnMap) { |
|
| 211 | + if (!$columnMap->isPrimaryKey()) { |
|
| 212 | 212 | $query->withColumn($columnMap->getFullyQualifiedName(), ApiHelper::getColumnMapName($columnMap)); |
| 213 | - } elseif(!$columnMap->isForeignKey()) { |
|
| 214 | - $query->withColumn('IFNULL(' . $columnMap->getFullyQualifiedName() . ', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap)); |
|
| 213 | + } elseif (!$columnMap->isForeignKey()) { |
|
| 214 | + $query->withColumn('IFNULL('.$columnMap->getFullyQualifiedName().', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap)); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -225,22 +225,22 @@ discard block |
||
| 225 | 225 | $model->fromArray($data, ApiHelper::getFieldTypes()); |
| 226 | 226 | $tableMap = $this->getTableMap(); |
| 227 | 227 | try { |
| 228 | - if($tableMap->hasRelation($tableMap->getPhpName() . 'I18n')) |
|
| 228 | + if ($tableMap->hasRelation($tableMap->getPhpName().'I18n')) |
|
| 229 | 229 | { |
| 230 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
| 230 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
| 231 | 231 | $i18NTableMap = $relateI18n->getLocalTable(); |
| 232 | 232 | $model->setLocale(array_key_exists('Locale', $data) ? $data['Locale'] : (array_key_exists('locale', $data) ? $data['locale'] : Request::header(Api::HEADER_API_LANG, 'es_ES'))); |
| 233 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
| 234 | - $method = 'set' . $columnMap->getPhpName(); |
|
| 233 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
| 234 | + $method = 'set'.$columnMap->getPhpName(); |
|
| 235 | 235 | $dtoColumnName = ApiHelper::getColumnMapName($columnMap); |
| 236 | - if(array_key_exists($dtoColumnName, $data) |
|
| 236 | + if (array_key_exists($dtoColumnName, $data) |
|
| 237 | 237 | && method_exists($model, $method) |
| 238 | 238 | && !($columnMap->isPrimaryKey() && $columnMap->isForeignKey())) { |
| 239 | 239 | $model->$method($data[$dtoColumnName]); |
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | - } catch(Exception $e) { |
|
| 243 | + }catch (Exception $e) { |
|
| 244 | 244 | Logger::log($e->getMessage(), LOG_DEBUG); |
| 245 | 245 | } |
| 246 | 246 | } |