@@ -360,7 +360,7 @@ |
||
360 | 360 | * Translator from php types to swagger types |
361 | 361 | * @param string $format |
362 | 362 | * |
363 | - * @return array |
|
363 | + * @return string[] |
|
364 | 364 | */ |
365 | 365 | public static function translateSwaggerFormats($format) |
366 | 366 | { |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | if (!preg_match('/^ROOT/i', $module)) { |
40 | 40 | $modules[] = [ |
41 | 41 | 'name' => $module, |
42 | - 'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'), |
|
42 | + 'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'), |
|
43 | 43 | ]; |
44 | 44 | } |
45 | - } catch (\Exception $e) { |
|
45 | + }catch (\Exception $e) { |
|
46 | 46 | $modules[] = $e->getMessage(); |
47 | 47 | } |
48 | 48 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function extractApiEndpoints(array $module) |
62 | 62 | { |
63 | - $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
63 | + $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
64 | 64 | $module_name = $module['name']; |
65 | 65 | $endpoints = []; |
66 | 66 | if (file_exists($module_path)) { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | if (count($finder)) { |
70 | 70 | /** @var \SplFileInfo $file */ |
71 | 71 | foreach ($finder as $file) { |
72 | - $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
72 | + $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
73 | 73 | $info = $this->extractApiInfo($namespace, $module_name); |
74 | 74 | if (!empty($info)) { |
75 | 75 | $endpoints[$namespace] = $info; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | if (NULL !== $mInfo) { |
99 | 99 | $info[] = $mInfo; |
100 | 100 | } |
101 | - } catch (\Exception $e) { |
|
101 | + }catch (\Exception $e) { |
|
102 | 102 | Logger::getInstance()->errorLog($e->getMessage()); |
103 | 103 | } |
104 | 104 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
310 | 310 | $payload = $this->extractDtoProperties($namespace); |
311 | 311 | } |
312 | - } catch (\Exception $e) { |
|
312 | + }catch (\Exception $e) { |
|
313 | 313 | Logger::getInstance()->errorLog($e->getMessage()); |
314 | 314 | } |
315 | 315 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | if (in_array($methodInfo['method'], ['POST', 'PUT'])) { |
347 | 347 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); |
348 | 348 | } |
349 | - } catch (\Exception $e) { |
|
349 | + }catch (\Exception $e) { |
|
350 | 350 | jpre($e->getMessage()); |
351 | 351 | Logger::getInstance()->errorLog($e->getMessage()); |
352 | 352 | } |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | ]]); |
426 | 426 | if (array_key_exists($subDtoName, $subDto)) { |
427 | 427 | $definitions = $subDto; |
428 | - } else { |
|
428 | + }else { |
|
429 | 429 | $definitions[$subDtoName] = $subDto; |
430 | 430 | } |
431 | 431 | $dto['properties'][$field] = [ |
432 | - '$ref' => "#/definitions/" . $subDtoName, |
|
432 | + '$ref' => "#/definitions/".$subDtoName, |
|
433 | 433 | ]; |
434 | - } else { |
|
434 | + }else { |
|
435 | 435 | list($type, $format) = self::translateSwaggerFormats($format); |
436 | 436 | $dto['properties'][$field] = [ |
437 | 437 | "type" => $type, |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | protected function extractDtoName($dto, $isArray = false) |
490 | 490 | { |
491 | 491 | $dto = explode('\\', $dto); |
492 | - $modelDto = array_pop($dto) . "Dto"; |
|
492 | + $modelDto = array_pop($dto)."Dto"; |
|
493 | 493 | if ($isArray) { |
494 | 494 | $modelDto .= "List"; |
495 | 495 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | )) |
38 | 38 | ->addButton('submit', _("Acceder como {{username}}")) |
39 | 39 | ->addButton("cancel", _("Cancelar"), "button", array( |
40 | - "onclick" => "javacript:location.href = \"" . Router::getInstance()->getRoute('') . "\";", |
|
40 | + "onclick" => "javacript:location.href = \"".Router::getInstance()->getRoute('')."\";", |
|
41 | 41 | "class" => "btn-link", |
42 | 42 | )); |
43 | 43 | } |
@@ -78,7 +78,7 @@ |
||
78 | 78 | "class" => "btn-success col-md-offset-2" |
79 | 79 | )) |
80 | 80 | ->addButton('add_field', _('Añadir nuevo parámetro'), 'button', array( |
81 | - "onclick" => "javascript:addNewField(document.getElementById('" . $this->getName() . "'));", |
|
81 | + "onclick" => "javascript:addNewField(document.getElementById('".$this->getName()."'));", |
|
82 | 82 | "class" => "btn-warning", |
83 | 83 | )); |
84 | 84 | } |
@@ -36,8 +36,8 @@ |
||
36 | 36 | $dto[$property->getName()] = $property->getValue($this); |
37 | 37 | } |
38 | 38 | } |
39 | - } catch (\Exception $e) { |
|
40 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
39 | + }catch (\Exception $e) { |
|
40 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
41 | 41 | } |
42 | 42 | return $dto; |
43 | 43 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | { |
63 | 63 | if (preg_match('/^asc$/i', $direction)) { |
64 | 64 | return Order::ASC; |
65 | - } else { |
|
65 | + }else { |
|
66 | 66 | return Order::DESC; |
67 | 67 | } |
68 | 68 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $vars['__menu__'] = $this->getMenu(); |
38 | 38 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
39 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
39 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $vars['__menu__'] = $this->getMenu(); |
69 | 69 | $domain = $domain ?: $this->getDomain(); |
70 | - return $this->tpl->dump($domain . $template, $vars); |
|
70 | + return $this->tpl->dump($domain.$template, $vars); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | ///////////////////////////////////////////////////////////// |
97 | 97 | // Date in the past sets the value to already have been expired. |
98 | 98 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
99 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
99 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
100 | 100 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
101 | 101 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
102 | 102 | header("Pragma: no-cache"); |
103 | 103 | header("Expires: 0"); |
104 | 104 | header('Content-Transfer-Encoding: none'); |
105 | - header("Content-type: " . $content); |
|
106 | - header("Content-length: " . strlen($data)); |
|
107 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
105 | + header("Content-type: ".$content); |
|
106 | + header("Content-length: ".strlen($data)); |
|
107 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
108 | 108 | echo $data; |
109 | 109 | ob_flush(); |
110 | 110 | ob_end_clean(); |
@@ -26,13 +26,13 @@ |
||
26 | 26 | { |
27 | 27 | $namespace = explode('\\', $this->getModelTableMap()); |
28 | 28 | $module = strtolower($namespace[0]); |
29 | - $secret = Config::getInstance()->get($module . '.api.secret'); |
|
29 | + $secret = Config::getInstance()->get($module.'.api.secret'); |
|
30 | 30 | if (NULL === $secret) { |
31 | 31 | $secret = Config::getInstance()->get("api.secret"); |
32 | 32 | } |
33 | 33 | if (NULL === $secret) { |
34 | 34 | $auth = TRUE; |
35 | - } else { |
|
35 | + }else { |
|
36 | 36 | $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN'); |
37 | 37 | if (array_key_exists('API_TOKEN', $this->query)) { |
38 | 38 | $token = $this->query['API_TOKEN']; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param ModelCriteria $query |
182 | 182 | */ |
183 | - private function addOrders(ModelCriteria &$query) |
|
183 | + private function addOrders(ModelCriteria & $query) |
|
184 | 184 | { |
185 | 185 | $orderAdded = FALSE; |
186 | 186 | $tableMap = $this->getTableMap(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $orderAdded = TRUE; |
190 | 190 | if ($direction === Order::ASC) { |
191 | 191 | $query->addAscendingOrderByColumn($column->getPhpName()); |
192 | - } else { |
|
192 | + }else { |
|
193 | 193 | $query->addDescendingOrderByColumn($column->getPhpName()); |
194 | 194 | } |
195 | 195 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | if (count($pks) == 1) { |
210 | 210 | $pks = array_keys($pks); |
211 | 211 | $this->extraColumns[$pks[0]] = self::API_MODEL_KEY_FIELD; |
212 | - } else { |
|
212 | + }else { |
|
213 | 213 | throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta')); |
214 | 214 | } |
215 | 215 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | } |
232 | 232 | if (null !== $column) { |
233 | 233 | $this->extraColumns[$column->getFullyQualifiedName()] = self::API_LIST_NAME_FIELD; |
234 | - } else { |
|
234 | + }else { |
|
235 | 235 | $this->addClassListName($tableMap); |
236 | 236 | } |
237 | 237 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @param ModelCriteria $query |
245 | 245 | */ |
246 | - private function addExtraColumns(ModelCriteria &$query) |
|
246 | + private function addExtraColumns(ModelCriteria & $query) |
|
247 | 247 | { |
248 | 248 | if (self::API_ACTION_LIST === $this->action) { |
249 | 249 | $this->addDefaultListField(); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param ModelCriteria $query |
263 | 263 | */ |
264 | - protected function joinTables(ModelCriteria &$query) |
|
264 | + protected function joinTables(ModelCriteria & $query) |
|
265 | 265 | { |
266 | 266 | //TODO for specific implementations |
267 | 267 | } |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @param ModelCriteria $query |
285 | 285 | */ |
286 | - private function addFilters(ModelCriteria &$query) |
|
286 | + private function addFilters(ModelCriteria & $query) |
|
287 | 287 | { |
288 | 288 | if (count($this->query) > 0) { |
289 | 289 | $tableMap = $this->getTableMap(); |
290 | 290 | foreach ($this->query as $field => $value) { |
291 | 291 | if (self::API_COMBO_FIELD === $field) { |
292 | 292 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
293 | - } else { |
|
293 | + }else { |
|
294 | 294 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
295 | 295 | } |
296 | 296 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | /** |
301 | 301 | * @param ModelCriteria $query |
302 | 302 | */ |
303 | - private function checkReturnFields(ModelCriteria &$query) |
|
303 | + private function checkReturnFields(ModelCriteria & $query) |
|
304 | 304 | { |
305 | 305 | $returnFields = $this->getRequest()->getQuery('__fields'); |
306 | 306 | if (null !== $returnFields) { |
@@ -336,10 +336,10 @@ discard block |
||
336 | 336 | list($page, $limit) = $this->extractPagination(); |
337 | 337 | if ($limit == -1) { |
338 | 338 | $this->list = $query->find($this->con); |
339 | - } else { |
|
339 | + }else { |
|
340 | 340 | $this->list = $query->paginate($page, $limit, $this->con); |
341 | 341 | } |
342 | - } catch (\Exception $e) { |
|
342 | + }catch (\Exception $e) { |
|
343 | 343 | Logger::log($e->getMessage(), LOG_ERR); |
344 | 344 | } |
345 | 345 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $this->joinTables($query); |
357 | 357 | $this->addExtraColumns($query); |
358 | 358 | $this->model = $query->findPk($pk); |
359 | - } catch (\Exception $e) { |
|
359 | + }catch (\Exception $e) { |
|
360 | 360 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
361 | 361 | } |
362 | 362 | } |
@@ -447,8 +447,8 @@ discard block |
||
447 | 447 | $saved = TRUE; |
448 | 448 | $model = $this->model->toArray(); |
449 | 449 | } |
450 | - } catch (\Exception $e) { |
|
451 | - $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage(); |
|
450 | + }catch (\Exception $e) { |
|
451 | + $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage(); |
|
452 | 452 | Logger::log($e->getMessage(), LOG_ERR); |
453 | 453 | } |
454 | 454 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | $this->model->delete($this->con); |
479 | 479 | $deleted = TRUE; |
480 | 480 | } |
481 | - } catch (\Exception $e) { |
|
481 | + }catch (\Exception $e) { |
|
482 | 482 | $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados'); |
483 | 483 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
484 | 484 | } |
@@ -513,14 +513,14 @@ discard block |
||
513 | 513 | $updated = TRUE; |
514 | 514 | $status = 200; |
515 | 515 | $model = $this->model->toArray(); |
516 | - } else { |
|
516 | + }else { |
|
517 | 517 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
518 | 518 | } |
519 | - } catch (\Exception $e) { |
|
519 | + }catch (\Exception $e) { |
|
520 | 520 | $model = $e->getMessage(); |
521 | 521 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
522 | 522 | } |
523 | - } else { |
|
523 | + }else { |
|
524 | 524 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
525 | 525 | } |
526 | 526 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | */ |
533 | 533 | private function extractQuery() |
534 | 534 | { |
535 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
535 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
536 | 536 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
537 | 537 | $query = $queryReflector->getMethod('create')->invoke($this->con); |
538 | 538 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | if (null !== $this->con && $this->con->inTransaction()) { |
577 | 577 | if ($status === 200) { |
578 | 578 | $this->con->commit(); |
579 | - } else { |
|
579 | + }else { |
|
580 | 580 | $this->con->rollBack(); |
581 | 581 | } |
582 | 582 | } |
@@ -628,8 +628,8 @@ discard block |
||
628 | 628 | "domain" => $this->getDomain(), |
629 | 629 | "listLabel" => self::API_LIST_NAME_FIELD, |
630 | 630 | 'modelId' => self::API_MODEL_KEY_FIELD, |
631 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
632 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
631 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
632 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
633 | 633 | ), [], ''); |
634 | 634 | } |
635 | 635 | |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | $total = $this->list->getNbResults(); |
669 | 669 | $pages = $this->list->getLastPage(); |
670 | 670 | } |
671 | - } catch (\Exception $e) { |
|
671 | + }catch (\Exception $e) { |
|
672 | 672 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
673 | 673 | } |
674 | 674 | |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | $return = array(); |
688 | 688 | if (NULL === $model && method_exists($model, 'toArray')) { |
689 | 689 | $code = 404; |
690 | - } else { |
|
690 | + }else { |
|
691 | 691 | $return = $model->toArray(); |
692 | 692 | } |
693 | 693 | |
@@ -702,10 +702,10 @@ discard block |
||
702 | 702 | $pks = ''; |
703 | 703 | $sep = ''; |
704 | 704 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
705 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
705 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
706 | 706 | $sep = ', "|", '; |
707 | 707 | } |
708 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = self::API_LIST_NAME_FIELD; |
|
708 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = self::API_LIST_NAME_FIELD; |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -30,16 +30,16 @@ |
||
30 | 30 | $scripts = $this->getNode("scripts"); |
31 | 31 | |
32 | 32 | //Creamos el parser |
33 | - $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\'' . $this->type . '\')') |
|
33 | + $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\''.$this->type.'\')') |
|
34 | 34 | ->raw(";\n"); |
35 | 35 | |
36 | 36 | //Asociamos el hash |
37 | - $compiler->write('$parser->setHash(\'' . $this->hash . '\')') |
|
37 | + $compiler->write('$parser->setHash(\''.$this->hash.'\')') |
|
38 | 38 | ->raw(";\n"); |
39 | 39 | |
40 | 40 | //Asociamos los ficheros |
41 | 41 | foreach ($scripts->getAttribute("value") as $value) { |
42 | - $compiler->write('$parser->addFile(\'' . $value . '\')')->raw(";\n"); |
|
42 | + $compiler->write('$parser->addFile(\''.$value.'\')')->raw(";\n"); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | //Procesamos los ficheros |