@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $this->setStatusCode("HTTP/1.0 400 Bad Request"); |
118 | 118 | break; |
119 | 119 | default: |
120 | - $this->setStatusCode('HTTP/1.0 ' . $status ?: 200); |
|
120 | + $this->setStatusCode('HTTP/1.0 '.$status ?: 200); |
|
121 | 121 | break; |
122 | 122 | } |
123 | 123 | return $this; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
136 | 136 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
137 | 137 | ResponseHelper::setCookieHeaders($cookies); |
138 | - header('Content-type: ' . $contentType); |
|
138 | + header('Content-type: '.$contentType); |
|
139 | 139 | |
140 | 140 | } |
141 | 141 | |
@@ -151,15 +151,15 @@ discard block |
||
151 | 151 | Logger::log('Start output response'); |
152 | 152 | ob_start(); |
153 | 153 | $this->setReponseHeaders($contentType, $cookies); |
154 | - header('Content-length: ' . strlen($output)); |
|
154 | + header('Content-length: '.strlen($output)); |
|
155 | 155 | |
156 | 156 | $needCache = Cache::needCache(); |
157 | 157 | if (false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) { |
158 | 158 | $cache = Cache::getInstance(); |
159 | 159 | Logger::log('Saving output response into cache'); |
160 | 160 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
161 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
162 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON); |
|
161 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
162 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON); |
|
163 | 163 | } |
164 | 164 | echo $output; |
165 | 165 | |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | Logger::log('Close template render'); |
178 | 178 | $uri = Request::requestUri(); |
179 | 179 | Security::getInstance()->setSessionKey("lastRequest", array( |
180 | - "url" => Request::getInstance()->getRootUrl() . $uri, |
|
180 | + "url" => Request::getInstance()->getRootUrl().$uri, |
|
181 | 181 | "ts" => microtime(true), |
182 | 182 | )); |
183 | 183 | Security::getInstance()->updateSession(); |
184 | - Logger::log('End request: ' . $uri, LOG_INFO); |
|
184 | + Logger::log('End request: '.$uri, LOG_INFO); |
|
185 | 185 | exit; |
186 | 186 | } |
187 | 187 | |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | ///////////////////////////////////////////////////////////// |
220 | 220 | // Date in the past sets the value to already have been expired. |
221 | 221 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
222 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
222 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
223 | 223 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
224 | 224 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
225 | 225 | header("Pragma: no-cache"); |
226 | 226 | header("Expires: 0"); |
227 | 227 | header('Content-Transfer-Encoding: none'); |
228 | - header("Content-type: " . $content); |
|
229 | - header("Content-length: " . strlen($data)); |
|
230 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
228 | + header("Content-type: ".$content); |
|
229 | + header("Content-length: ".strlen($data)); |
|
230 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
231 | 231 | echo $data; |
232 | 232 | ob_flush(); |
233 | 233 | ob_end_clean(); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @param ModelCriteria $query |
188 | 188 | */ |
189 | - private function addOrders(ModelCriteria &$query) |
|
189 | + private function addOrders(ModelCriteria & $query) |
|
190 | 190 | { |
191 | 191 | $orderAdded = FALSE; |
192 | 192 | $tableMap = $this->getTableMap(); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $orderAdded = TRUE; |
196 | 196 | if ($direction === Order::ASC) { |
197 | 197 | $query->addAscendingOrderByColumn($column->getPhpName()); |
198 | - } else { |
|
198 | + }else { |
|
199 | 199 | $query->addDescendingOrderByColumn($column->getPhpName()); |
200 | 200 | } |
201 | 201 | } |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | $pks = $tableMap->getPrimaryKeys(); |
211 | 211 | if (count($pks) == 1) { |
212 | 212 | $pks = array_keys($pks); |
213 | - return $tableMap::TABLE_NAME . '.' . $pks[0]; |
|
214 | - } else { |
|
213 | + return $tableMap::TABLE_NAME.'.'.$pks[0]; |
|
214 | + }else { |
|
215 | 215 | throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta')); |
216 | 216 | } |
217 | 217 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | if (null !== $column) { |
244 | 244 | $this->extraColumns[$column->getFullyQualifiedName()] = self::API_LIST_NAME_FIELD; |
245 | - } else { |
|
245 | + }else { |
|
246 | 246 | $this->addClassListName($tableMap); |
247 | 247 | } |
248 | 248 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param ModelCriteria $query |
255 | 255 | */ |
256 | - private function addExtraColumns(ModelCriteria &$query) |
|
256 | + private function addExtraColumns(ModelCriteria & $query) |
|
257 | 257 | { |
258 | 258 | if (self::API_ACTION_LIST === $this->action) { |
259 | 259 | $this->addDefaultListField(); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @param ModelCriteria $query |
273 | 273 | */ |
274 | - protected function joinTables(ModelCriteria &$query) |
|
274 | + protected function joinTables(ModelCriteria & $query) |
|
275 | 275 | { |
276 | 276 | //TODO for specific implementations |
277 | 277 | } |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param ModelCriteria $query |
295 | 295 | */ |
296 | - private function addFilters(ModelCriteria &$query) |
|
296 | + private function addFilters(ModelCriteria & $query) |
|
297 | 297 | { |
298 | 298 | if (count($this->query) > 0) { |
299 | 299 | $tableMap = $this->getTableMap(); |
300 | 300 | foreach ($this->query as $field => $value) { |
301 | 301 | if (self::API_COMBO_FIELD === $field) { |
302 | 302 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
303 | - } else { |
|
303 | + }else { |
|
304 | 304 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
305 | 305 | } |
306 | 306 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | /** |
311 | 311 | * @param ModelCriteria $query |
312 | 312 | */ |
313 | - private function checkReturnFields(ModelCriteria &$query) |
|
313 | + private function checkReturnFields(ModelCriteria & $query) |
|
314 | 314 | { |
315 | 315 | $returnFields = $this->getRequest()->getQuery('__fields'); |
316 | 316 | if (null !== $returnFields) { |
@@ -346,10 +346,10 @@ discard block |
||
346 | 346 | list($page, $limit) = $this->extractPagination(); |
347 | 347 | if ($limit == -1) { |
348 | 348 | $this->list = $query->find($this->con); |
349 | - } else { |
|
349 | + }else { |
|
350 | 350 | $this->list = $query->paginate($page, $limit, $this->con); |
351 | 351 | } |
352 | - } catch (\Exception $e) { |
|
352 | + }catch (\Exception $e) { |
|
353 | 353 | Logger::log($e->getMessage(), LOG_ERR); |
354 | 354 | } |
355 | 355 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | $this->joinTables($query); |
367 | 367 | $this->addExtraColumns($query); |
368 | 368 | $this->model = $query->findPk($pk); |
369 | - } catch (\Exception $e) { |
|
369 | + }catch (\Exception $e) { |
|
370 | 370 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
371 | 371 | } |
372 | 372 | } |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | $saved = TRUE; |
458 | 458 | $model = $this->model->toArray(); |
459 | 459 | } |
460 | - } catch (\Exception $e) { |
|
461 | - $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage(); |
|
460 | + }catch (\Exception $e) { |
|
461 | + $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage(); |
|
462 | 462 | Logger::log($e->getMessage(), LOG_ERR); |
463 | 463 | } |
464 | 464 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | $this->model->delete($this->con); |
489 | 489 | $deleted = TRUE; |
490 | 490 | } |
491 | - } catch (\Exception $e) { |
|
491 | + }catch (\Exception $e) { |
|
492 | 492 | $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados'); |
493 | 493 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
494 | 494 | } |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | $updated = TRUE; |
524 | 524 | $status = 200; |
525 | 525 | $model = $this->model->toArray(); |
526 | - } else { |
|
526 | + }else { |
|
527 | 527 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
528 | 528 | } |
529 | - } catch (\Exception $e) { |
|
529 | + }catch (\Exception $e) { |
|
530 | 530 | $model = $e->getMessage(); |
531 | 531 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
532 | 532 | } |
533 | - } else { |
|
533 | + }else { |
|
534 | 534 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
535 | 535 | } |
536 | 536 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | */ |
543 | 543 | private function extractQuery() |
544 | 544 | { |
545 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
545 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
546 | 546 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
547 | 547 | $query = $queryReflector->getMethod('create')->invoke($this->con); |
548 | 548 | |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | if (null !== $this->con && $this->con->inTransaction()) { |
587 | 587 | if ($status === 200) { |
588 | 588 | $this->con->commit(); |
589 | - } else { |
|
589 | + }else { |
|
590 | 590 | $this->con->rollBack(); |
591 | 591 | } |
592 | 592 | } |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | "domain" => $this->getDomain(), |
639 | 639 | "listLabel" => self::API_LIST_NAME_FIELD, |
640 | 640 | 'modelId' => self::API_MODEL_KEY_FIELD, |
641 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
642 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
641 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
642 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
643 | 643 | ), [], ''); |
644 | 644 | } |
645 | 645 | |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | $total = $this->list->getNbResults(); |
680 | 680 | $pages = $this->list->getLastPage(); |
681 | 681 | } |
682 | - } catch (\Exception $e) { |
|
682 | + }catch (\Exception $e) { |
|
683 | 683 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
684 | 684 | } |
685 | 685 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | $return = array(); |
699 | 699 | if (NULL === $model || !method_exists($model, 'toArray')) { |
700 | 700 | $code = 404; |
701 | - } else { |
|
701 | + }else { |
|
702 | 702 | $return = $model->toArray(); |
703 | 703 | } |
704 | 704 | |
@@ -713,9 +713,9 @@ discard block |
||
713 | 713 | $pks = ''; |
714 | 714 | $sep = ''; |
715 | 715 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
716 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
716 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
717 | 717 | $sep = ', "|", '; |
718 | 718 | } |
719 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = self::API_LIST_NAME_FIELD; |
|
719 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = self::API_LIST_NAME_FIELD; |
|
720 | 720 | } |
721 | 721 | } |