@@ -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,7 +180,7 @@ 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 | 185 | //foreach($tableMap->getRelations() as $relation) { |
186 | 186 | // $column = self::checkFieldExists($relation->getLocalTable(), $field); |
@@ -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); |
@@ -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 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @param ModelCriteria $query |
116 | 116 | */ |
117 | - private function addOrders(ModelCriteria &$query) |
|
117 | + private function addOrders(ModelCriteria & $query) |
|
118 | 118 | { |
119 | 119 | $orderAdded = FALSE; |
120 | 120 | $tableMap = $this->getTableMap(); |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | $orderAdded = TRUE; |
124 | 124 | if ($direction === Order::ASC) { |
125 | 125 | $query->addAscendingOrderByColumn($column->getPhpName()); |
126 | - } else { |
|
126 | + }else { |
|
127 | 127 | $query->addDescendingOrderByColumn($column->getPhpName()); |
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |
131 | 131 | if (!$orderAdded) { |
132 | - foreach($this->getPkDbName() as $pk => $phpName) { |
|
132 | + foreach ($this->getPkDbName() as $pk => $phpName) { |
|
133 | 133 | $query->addAscendingOrderByColumn($pk); |
134 | 134 | } |
135 | 135 | } |
@@ -140,14 +140,14 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @param ModelCriteria $query |
142 | 142 | */ |
143 | - private function addFilters(ModelCriteria &$query) |
|
143 | + private function addFilters(ModelCriteria & $query) |
|
144 | 144 | { |
145 | 145 | if (count($this->query) > 0) { |
146 | 146 | $tableMap = $this->getTableMap(); |
147 | 147 | foreach ($this->query as $field => $value) { |
148 | 148 | if (self::API_COMBO_FIELD === $field) { |
149 | 149 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
150 | - } elseif(!preg_match('/^__/', $field)) { |
|
150 | + } elseif (!preg_match('/^__/', $field)) { |
|
151 | 151 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
152 | 152 | } |
153 | 153 | } |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | list($page, $limit) = $this->extractPagination(); |
169 | 169 | if ($limit == -1) { |
170 | 170 | $this->list = $query->find($this->con); |
171 | - } else { |
|
171 | + }else { |
|
172 | 172 | $this->list = $query->paginate($page, $limit, $this->con); |
173 | 173 | } |
174 | - } catch (\Exception $e) { |
|
174 | + }catch (\Exception $e) { |
|
175 | 175 | Logger::log($e->getMessage(), LOG_ERR); |
176 | 176 | } |
177 | 177 | } |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | $saved = TRUE; |
238 | 238 | $model = $this->model->toArray(); |
239 | 239 | } |
240 | - } catch (\Exception $e) { |
|
241 | - $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage(); |
|
240 | + }catch (\Exception $e) { |
|
241 | + $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage(); |
|
242 | 242 | Logger::log($e->getMessage(), LOG_ERR); |
243 | 243 | } |
244 | 244 | |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | $updated = TRUE; |
272 | 272 | $status = 200; |
273 | 273 | $model = $this->model->toArray(); |
274 | - } else { |
|
274 | + }else { |
|
275 | 275 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
276 | 276 | } |
277 | - } catch (\Exception $e) { |
|
277 | + }catch (\Exception $e) { |
|
278 | 278 | $model = $e->getMessage(); |
279 | 279 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
280 | 280 | } |
281 | - } else { |
|
281 | + }else { |
|
282 | 282 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
283 | 283 | } |
284 | 284 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $this->model->delete($this->con); |
309 | 309 | $deleted = TRUE; |
310 | 310 | } |
311 | - } catch (\Exception $e) { |
|
311 | + }catch (\Exception $e) { |
|
312 | 312 | $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados'); |
313 | 313 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
314 | 314 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $total = $this->list->getNbResults(); |
343 | 343 | $pages = $this->list->getLastPage(); |
344 | 344 | } |
345 | - } catch (\Exception $e) { |
|
345 | + }catch (\Exception $e) { |
|
346 | 346 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
347 | 347 | } |
348 | 348 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | $return = array(); |
362 | 362 | if (NULL === $model || !method_exists($model, 'toArray')) { |
363 | 363 | $code = 404; |
364 | - } else { |
|
364 | + }else { |
|
365 | 365 | $return = $model->toArray(); |
366 | 366 | } |
367 | 367 |
@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Propel\Runtime\ActiveQuery\ModelCriteria; |
5 | 5 | use Propel\Runtime\Map\TableMap; |
6 | -use PSFS\base\config\Config; |
|
7 | 6 | use PSFS\base\dto\JsonResponse; |
8 | 7 | use PSFS\base\dto\Order; |
9 | 8 | use PSFS\base\Logger; |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use Propel\Runtime\Propel; |
7 | 7 | use PSFS\base\config\Config; |
8 | 8 | use PSFS\base\Logger; |
9 | -use PSFS\base\types\traits\DebugTrait; |
|
10 | 9 | |
11 | 10 | /** |
12 | 11 | * Trait ConnectionTrait |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | protected function createConnection(TableMap $tableMap) |
27 | 27 | { |
28 | 28 | $this->con = Propel::getConnection($tableMap::DATABASE_NAME); |
29 | - if(method_exists($this->con, 'useDebug')) { |
|
29 | + if (method_exists($this->con, 'useDebug')) { |
|
30 | 30 | Logger::log('Enabling debug queries mode', LOG_INFO); |
31 | 31 | $this->con->useDebug(Config::getParam('debug')); |
32 | 32 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | if (null !== $this->con && $this->con->inTransaction()) { |
44 | 44 | if ($status === 200) { |
45 | 45 | $this->con->commit(); |
46 | - } else { |
|
46 | + }else { |
|
47 | 47 | $this->con->rollBack(); |
48 | 48 | } |
49 | 49 | } |