@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Método que verifica si existe una cabecera concreta |
57 | - * @param $header |
|
57 | + * @param string $header |
|
58 | 58 | * |
59 | 59 | * @return boolean |
60 | 60 | */ |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @param string $queryParams |
177 | 177 | * |
178 | - * @return mixed |
|
178 | + * @return string |
|
179 | 179 | */ |
180 | 180 | public function getQuery($queryParams) |
181 | 181 | { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $this->data = $_REQUEST or []; |
28 | 28 | $this->query = $_GET or []; |
29 | 29 | $contentType = $this->getHeader('Accept'); |
30 | - if(null === $contentType) { |
|
30 | + if (null === $contentType) { |
|
31 | 31 | $contentType = $this->getServer('Accept') ?: 'text/html'; |
32 | 32 | } |
33 | 33 | if (preg_match('/application\/json/i', $contentType)) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public static function header($name, $default = null) |
119 | 119 | { |
120 | - return self::getInstance()->getHeader($name, $default); |
|
120 | + return self::getInstance()->getHeader($name, $default); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | { |
221 | 221 | if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
222 | 222 | ob_start(); |
223 | - header('Location: ' . $url); |
|
223 | + header('Location: '.$url); |
|
224 | 224 | ob_end_clean(); |
225 | 225 | Security::getInstance()->updateSession(); |
226 | 226 | exit(_("Redireccionando...")); |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | $host = $this->getServerName(); |
266 | 266 | $protocol = $protocol ? $this->getProtocol() : ''; |
267 | 267 | $url = ''; |
268 | - if (!empty($host) && !empty($protocol)) $url = $protocol . $host; |
|
268 | + if (!empty($host) && !empty($protocol)) $url = $protocol.$host; |
|
269 | 269 | if (!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
270 | - $url .= ':' . $this->getServer('SERVER_PORT'); |
|
270 | + $url .= ':'.$this->getServer('SERVER_PORT'); |
|
271 | 271 | } |
272 | 272 | return $url; |
273 | 273 | } |
@@ -160,7 +160,7 @@ |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | - * @param $field |
|
163 | + * @param string $field |
|
164 | 164 | * @param bool $required |
165 | 165 | * @return Field |
166 | 166 | */ |
@@ -31,19 +31,19 @@ discard block |
||
31 | 31 | $behaviors = $tableMap->getBehaviors(); |
32 | 32 | foreach ($map::getFieldNames() as $field) { |
33 | 33 | $fDto = self::parseFormField($domain, $tableMap, $field, $behaviors); |
34 | - if(null !== $fDto) { |
|
34 | + if (null !== $fDto) { |
|
35 | 35 | $form->addField($fDto); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | - if(array_key_exists('i18n', $behaviors)) { |
|
40 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
41 | - if(null !== $relateI18n) { |
|
39 | + if (array_key_exists('i18n', $behaviors)) { |
|
40 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
41 | + if (null !== $relateI18n) { |
|
42 | 42 | $i18NTableMap = $relateI18n->getLocalTable(); |
43 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
44 | - if(!$form->fieldExists($columnMap->getPhpName())) { |
|
43 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
44 | + if (!$form->fieldExists($columnMap->getPhpName())) { |
|
45 | 45 | $fDto = self::parseFormField($domain, $i18NTableMap, $columnMap->getPhpName(), $i18NTableMap->getBehaviors()); |
46 | - if(null !== $fDto) { |
|
46 | + if (null !== $fDto) { |
|
47 | 47 | $fDto->pk = false; |
48 | 48 | $form->addField($fDto); |
49 | 49 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $fDto->entity = $relatedModel; |
73 | 73 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
74 | 74 | $fDto->relatedField = $relatedField->getPhpName(); |
75 | - $fDto->url = Router::getInstance()->getRoute(strtolower($domain) . '-api-' . $relatedModel); |
|
75 | + $fDto->url = Router::getInstance()->getRoute(strtolower($domain).'-api-'.$relatedModel); |
|
76 | 76 | return $fDto; |
77 | 77 | } |
78 | 78 | |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | $column = null; |
181 | 181 | try { |
182 | 182 | $column = $tableMap->getColumnByPhpName($field); |
183 | - } catch (\Exception $e) { |
|
183 | + }catch (\Exception $e) { |
|
184 | 184 | Logger::log($e->getMessage(), LOG_WARNING); |
185 | - foreach($tableMap->getRelations() as $relation) { |
|
185 | + foreach ($tableMap->getRelations() as $relation) { |
|
186 | 186 | $column = self::checkFieldExists($relation->getLocalTable(), $field); |
187 | 187 | } |
188 | 188 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param ModelCriteria $query |
195 | 195 | * @param mixed $value |
196 | 196 | */ |
197 | - private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) |
|
197 | + private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null) |
|
198 | 198 | { |
199 | 199 | $tableField = $column->getFullyQualifiedName(); |
200 | 200 | if (preg_match('/^<=/', $value)) { |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
211 | 211 | $text = preg_replace('/(\'|\")/', '', $value); |
212 | 212 | $text = preg_replace('/\ /', '%', $text); |
213 | - $query->add($tableField, '%' . $text . '%', Criteria::LIKE); |
|
214 | - } else { |
|
213 | + $query->add($tableField, '%'.$text.'%', Criteria::LIKE); |
|
214 | + }else { |
|
215 | 215 | $query->add($tableField, $value, Criteria::EQUAL); |
216 | 216 | } |
217 | 217 | } |
@@ -222,24 +222,24 @@ discard block |
||
222 | 222 | * @param array $extraColumns |
223 | 223 | * @param mixed $value |
224 | 224 | */ |
225 | - public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null) |
|
225 | + public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null) |
|
226 | 226 | { |
227 | 227 | $exp = 'CONCAT('; |
228 | 228 | $sep = ''; |
229 | 229 | foreach ($tableMap->getColumns() as $column) { |
230 | 230 | if ($column->isText()) { |
231 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
231 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
232 | 232 | $sep = ', " ", '; |
233 | 233 | } |
234 | 234 | } |
235 | 235 | foreach ($extraColumns as $extra => $name) { |
236 | - $exp .= $sep . $extra; |
|
236 | + $exp .= $sep.$extra; |
|
237 | 237 | $sep = ', " ", '; |
238 | 238 | } |
239 | 239 | $exp .= ")"; |
240 | 240 | $text = preg_replace('/(\'|\")/', '', $value); |
241 | 241 | $text = preg_replace('/\ /', '%', $text); |
242 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
242 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param string $field |
250 | 250 | * @param mixed $value |
251 | 251 | */ |
252 | - public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null) |
|
252 | + public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null) |
|
253 | 253 | { |
254 | 254 | if ($column = self::checkFieldExists($tableMap, $field)) { |
255 | 255 | self::addQueryFilter($column, $query, $value); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public static function extractQuery($modelNameNamespace, ConnectionInterface $con = null) |
266 | 266 | { |
267 | - $queryReflector = new \ReflectionClass($modelNameNamespace . "Query"); |
|
267 | + $queryReflector = new \ReflectionClass($modelNameNamespace."Query"); |
|
268 | 268 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
269 | 269 | $query = $queryReflector->getMethod('create')->invoke($con); |
270 | 270 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | } elseif ($mappedColumn->isText()) { |
294 | 294 | if ($mappedColumn->getSize() > 100) { |
295 | 295 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
296 | - } else { |
|
296 | + }else { |
|
297 | 297 | $fDto = self::generateStringField($field, $required); |
298 | 298 | } |
299 | 299 | } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Method that extract the Api name |
42 | - * @return mixed |
|
42 | + * @return string |
|
43 | 43 | */ |
44 | 44 | public function getApi() |
45 | 45 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Method that extract the Domain name |
53 | - * @return mixed |
|
53 | + * @return string |
|
54 | 54 | */ |
55 | 55 | public function getDomain() |
56 | 56 | { |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param ModelCriteria $query |
95 | 95 | */ |
96 | - protected function joinTables(ModelCriteria &$query) |
|
96 | + protected function joinTables(ModelCriteria & $query) |
|
97 | 97 | { |
98 | 98 | //TODO for specific implementations |
99 | 99 | } |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | */ |
107 | 107 | private function findPk(ModelCriteria $query, $pk) { |
108 | 108 | $pks = explode(Api::API_PK_SEPARATOR, urldecode($pk)); |
109 | - if(count($pks) == 1) { |
|
109 | + if (count($pks) == 1) { |
|
110 | 110 | return $query->findPk($pks[0]); |
111 | - } else { |
|
111 | + }else { |
|
112 | 112 | $i = 0; |
113 | - foreach($this->getPkDbName() as $key => $phpName) { |
|
113 | + foreach ($this->getPkDbName() as $key => $phpName) { |
|
114 | 114 | $query->filterBy($phpName, $pks[$i]); |
115 | 115 | $i++; |
116 | - if($i >= count($pks)) break; |
|
116 | + if ($i >= count($pks)) break; |
|
117 | 117 | } |
118 | 118 | return $query->findOne(); |
119 | 119 | } |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | try { |
141 | 141 | $query = $this->prepareQuery(); |
142 | 142 | $this->model = $this->findPk($query, $pk); |
143 | - } catch (\Exception $e) { |
|
144 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
143 | + }catch (\Exception $e) { |
|
144 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * @param ModelCriteria $query |
164 | 164 | */ |
165 | - private function checkReturnFields(ModelCriteria &$query) |
|
165 | + private function checkReturnFields(ModelCriteria & $query) |
|
166 | 166 | { |
167 | 167 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
168 | 168 | if (null !== $returnFields) { |
@@ -113,7 +113,9 @@ |
||
113 | 113 | foreach($this->getPkDbName() as $key => $phpName) { |
114 | 114 | $query->filterBy($phpName, $pks[$i]); |
115 | 115 | $i++; |
116 | - if($i >= count($pks)) break; |
|
116 | + if($i >= count($pks)) { |
|
117 | + break; |
|
118 | + } |
|
117 | 119 | } |
118 | 120 | return $query->findOne(); |
119 | 121 | } |
@@ -48,7 +48,7 @@ |
||
48 | 48 | return ($aOrder < $bOrder) ? -1 : 1; |
49 | 49 | }); |
50 | 50 | $array['actions'] = []; |
51 | - foreach($this->actions as $action) { |
|
51 | + foreach ($this->actions as $action) { |
|
52 | 52 | $array['actions'][] = $action->__toArray(); |
53 | 53 | } |
54 | 54 | return $array; |
@@ -44,7 +44,7 @@ |
||
44 | 44 | header("Access-Control-Allow-Credentials: true"); |
45 | 45 | header("Access-Control-Allow-Origin: *"); |
46 | 46 | header("Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS"); |
47 | - header("Access-Control-Allow-Headers: " . implode(', ', self::getCorsHeaders())); |
|
47 | + header("Access-Control-Allow-Headers: ".implode(', ', self::getCorsHeaders())); |
|
48 | 48 | } |
49 | 49 | if (Request::getInstance()->getMethod() == 'OPTIONS') { |
50 | 50 | Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->setStatusCode(Template::STATUS_OK); |
121 | 121 | break; |
122 | 122 | default: |
123 | - $this->setStatusCode('HTTP/1.0 ' . $status ?: 200); |
|
123 | + $this->setStatusCode('HTTP/1.0 '.$status ?: 200); |
|
124 | 124 | break; |
125 | 125 | } |
126 | 126 | return $this; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
139 | 139 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
140 | 140 | ResponseHelper::setCookieHeaders($cookies); |
141 | - header('Content-type: ' . $contentType); |
|
141 | + header('Content-type: '.$contentType); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | |
@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | Logger::log('Start output response'); |
155 | 155 | ob_start(); |
156 | 156 | $this->setReponseHeaders($contentType, $cookies); |
157 | - header('Content-length: ' . strlen($output)); |
|
157 | + header('Content-length: '.strlen($output)); |
|
158 | 158 | |
159 | 159 | $needCache = Cache::needCache(); |
160 | 160 | if (false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) { |
161 | 161 | $cache = Cache::getInstance(); |
162 | 162 | Logger::log('Saving output response into cache'); |
163 | 163 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
164 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
165 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON); |
|
164 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
165 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON); |
|
166 | 166 | } |
167 | 167 | echo $output; |
168 | 168 | |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | Logger::log('Close template render'); |
181 | 181 | $uri = Request::requestUri(); |
182 | 182 | Security::getInstance()->setSessionKey("lastRequest", array( |
183 | - "url" => Request::getInstance()->getRootUrl() . $uri, |
|
183 | + "url" => Request::getInstance()->getRootUrl().$uri, |
|
184 | 184 | "ts" => microtime(true), |
185 | 185 | )); |
186 | 186 | Security::getInstance()->updateSession(); |
187 | - Logger::log('End request: ' . $uri, LOG_INFO); |
|
187 | + Logger::log('End request: '.$uri, LOG_INFO); |
|
188 | 188 | exit; |
189 | 189 | } |
190 | 190 | |
@@ -222,17 +222,17 @@ discard block |
||
222 | 222 | ///////////////////////////////////////////////////////////// |
223 | 223 | // Date in the past sets the value to already have been expired. |
224 | 224 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
225 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
225 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
226 | 226 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
227 | 227 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
228 | 228 | header("Pragma: no-cache"); |
229 | 229 | header("Expires: 0"); |
230 | 230 | header('Content-Transfer-Encoding: binary'); |
231 | - header("Content-type: " . $content); |
|
232 | - header("Content-length: " . strlen($data)); |
|
233 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
231 | + header("Content-type: ".$content); |
|
232 | + header("Content-length: ".strlen($data)); |
|
233 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
234 | 234 | header("Access-Control-Expose-Headers: Filename"); |
235 | - header("Filename: " . $filename); |
|
235 | + header("Filename: ".$filename); |
|
236 | 236 | echo $data; |
237 | 237 | ob_flush(); |
238 | 238 | ob_end_clean(); |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | if (count($pks) == 1) { |
58 | 58 | $pks = array_keys($pks); |
59 | 59 | return [ |
60 | - $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD |
|
60 | + $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD |
|
61 | 61 | ]; |
62 | 62 | } elseif (count($pks) > 1) { |
63 | 63 | $apiPks = []; |
64 | 64 | $principal = ''; |
65 | 65 | $sep = 'CONCAT('; |
66 | 66 | foreach ($pks as $pk) { |
67 | - $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName(); |
|
68 | - $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName(); |
|
69 | - $sep = ', "' . Api::API_PK_SEPARATOR . '", '; |
|
67 | + $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName(); |
|
68 | + $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName(); |
|
69 | + $sep = ', "'.Api::API_PK_SEPARATOR.'", '; |
|
70 | 70 | } |
71 | 71 | $principal .= ')'; |
72 | 72 | $apiPks[$principal] = Api::API_MODEL_KEY_FIELD; |
73 | 73 | return $apiPks; |
74 | - } else { |
|
74 | + }else { |
|
75 | 75 | throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta')); |
76 | 76 | } |
77 | 77 | } |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | $pks = ''; |
95 | 95 | $sep = ''; |
96 | 96 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
97 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
97 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
98 | 98 | $sep = ', "|", '; |
99 | 99 | } |
100 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD; |
|
100 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | if (null !== $column) { |
121 | 121 | $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD; |
122 | - } else { |
|
122 | + }else { |
|
123 | 123 | $this->addClassListName($tableMap); |
124 | 124 | } |
125 | 125 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param ModelCriteria $query |
132 | 132 | * @param string $action |
133 | 133 | */ |
134 | - private function addExtraColumns(ModelCriteria &$query, $action) |
|
134 | + private function addExtraColumns(ModelCriteria & $query, $action) |
|
135 | 135 | { |
136 | 136 | if (Api::API_ACTION_LIST === $action) { |
137 | 137 | $this->addDefaultListField(); |
@@ -159,21 +159,21 @@ discard block |
||
159 | 159 | /** |
160 | 160 | * @param ModelCriteria $query |
161 | 161 | */ |
162 | - protected function checkI18n(ModelCriteria &$query) |
|
162 | + protected function checkI18n(ModelCriteria & $query) |
|
163 | 163 | { |
164 | 164 | $model = $this->getModelNamespace(); |
165 | - $modelI18n = $model . 'I18n'; |
|
165 | + $modelI18n = $model.'I18n'; |
|
166 | 166 | if (method_exists($query, 'useI18nQuery')) { |
167 | 167 | $default_language = explode('_', Config::getParam('default.language', 'es_ES')); |
168 | 168 | $query->useI18nQuery(Request::header('X-API-LANG', $default_language[0])); |
169 | - $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n) . 'TableMap'; |
|
169 | + $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n).'TableMap'; |
|
170 | 170 | /** @var TableMap $modelI18nTableMap */ |
171 | 171 | $modelI18nTableMap = $modelI18nTableMapClass::getTableMap(); |
172 | - foreach($modelI18nTableMap->getColumns() as $columnMap) { |
|
173 | - if(!$columnMap->isPrimaryKey()) { |
|
174 | - $query->withColumn($modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName(), $columnMap->getPhpName()); |
|
175 | - } elseif(!$columnMap->isForeignKey()) { |
|
176 | - $query->withColumn('IFNULL(' . $modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName() . ', "'.Request::header('X-API-LANG', 'es').'")', $columnMap->getPhpName()); |
|
172 | + foreach ($modelI18nTableMap->getColumns() as $columnMap) { |
|
173 | + if (!$columnMap->isPrimaryKey()) { |
|
174 | + $query->withColumn($modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName(), $columnMap->getPhpName()); |
|
175 | + } elseif (!$columnMap->isForeignKey()) { |
|
176 | + $query->withColumn('IFNULL('.$modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName().', "'.Request::header('X-API-LANG', 'es').'")', $columnMap->getPhpName()); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | } |
@@ -183,15 +183,15 @@ discard block |
||
183 | 183 | * @param ActiveRecordInterface $model |
184 | 184 | * @param array $data |
185 | 185 | */ |
186 | - protected function hydrateModelFromRequest(ActiveRecordInterface &$model, array $data = []) { |
|
186 | + protected function hydrateModelFromRequest(ActiveRecordInterface & $model, array $data = []) { |
|
187 | 187 | $model->fromArray($data); |
188 | 188 | $tableMap = $this->getTableMap(); |
189 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
190 | - if(null !== $relateI18n) { |
|
189 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
190 | + if (null !== $relateI18n) { |
|
191 | 191 | $i18NTableMap = $relateI18n->getLocalTable(); |
192 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
193 | - $method = 'set' . $columnMap->getPhpName(); |
|
194 | - if(!($columnMap->isPrimaryKey() && $columnMap->isForeignKey()) |
|
192 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
193 | + $method = 'set'.$columnMap->getPhpName(); |
|
194 | + if (!($columnMap->isPrimaryKey() && $columnMap->isForeignKey()) |
|
195 | 195 | &&array_key_exists($columnMap->getPhpName(), $data) |
196 | 196 | && method_exists($model, $method)) { |
197 | 197 | $model->$method($data[$columnMap->getPhpName()]); |
@@ -39,8 +39,8 @@ |
||
39 | 39 | "domain" => $this->getDomain(), |
40 | 40 | "listLabel" => Api::API_LIST_NAME_FIELD, |
41 | 41 | 'modelId' => Api::API_MODEL_KEY_FIELD, |
42 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
43 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
42 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
43 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
44 | 44 | ), [], ''); |
45 | 45 | } |
46 | 46 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | protected function createConnection(TableMap $tableMap) |
30 | 30 | { |
31 | 31 | $this->con = Propel::getConnection($tableMap::DATABASE_NAME); |
32 | - if(method_exists($this->con, 'useDebug')) { |
|
32 | + if (method_exists($this->con, 'useDebug')) { |
|
33 | 33 | Logger::log('Enabling debug queries mode', LOG_INFO); |
34 | 34 | $this->con->useDebug($this->debug); |
35 | 35 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | if (null !== $this->con && $this->con->inTransaction()) { |
47 | 47 | if ($status === 200) { |
48 | 48 | $this->con->commit(); |
49 | - } else { |
|
49 | + }else { |
|
50 | 50 | $this->con->rollBack(); |
51 | 51 | } |
52 | 52 | } |