@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @CACHE 600 |
| 298 | 298 | * @ROUTE /api/{__API__} |
| 299 | 299 | * |
| 300 | - * @return \PSFS\base\dto\JsonResponse [{__API__}] |
|
| 300 | + * @return string|null [{__API__}] |
|
| 301 | 301 | */ |
| 302 | 302 | public function modelList() |
| 303 | 303 | { |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @param int $pk |
| 318 | 318 | * |
| 319 | - * @return \PSFS\base\dto\JsonResponse {__API__} |
|
| 319 | + * @return string|null {__API__} |
|
| 320 | 320 | */ |
| 321 | 321 | public function get($pk) |
| 322 | 322 | { |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | * @PAYLOAD {__API__} |
| 360 | 360 | * @ROUTE /api/{__API__} |
| 361 | 361 | * |
| 362 | - * @return \PSFS\base\dto\JsonResponse {__API__} |
|
| 362 | + * @return string|null {__API__} |
|
| 363 | 363 | */ |
| 364 | 364 | public function post() |
| 365 | 365 | { |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @param string $pk |
| 392 | 392 | * |
| 393 | - * @return \PSFS\base\dto\JsonResponse {__API__} |
|
| 393 | + * @return string|null {__API__} |
|
| 394 | 394 | */ |
| 395 | 395 | public function delete($pk = NULL) |
| 396 | 396 | { |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | * |
| 421 | 421 | * @param string $pk |
| 422 | 422 | * |
| 423 | - * @return \PSFS\base\dto\JsonResponse {__API__} |
|
| 423 | + * @return string|null {__API__} |
|
| 424 | 424 | * |
| 425 | 425 | */ |
| 426 | 426 | public function put($pk) |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * |
| 180 | 180 | * @param ModelCriteria $query |
| 181 | 181 | */ |
| 182 | - private function addOrders(ModelCriteria &$query) |
|
| 182 | + private function addOrders(ModelCriteria & $query) |
|
| 183 | 183 | { |
| 184 | 184 | $orderAdded = FALSE; |
| 185 | 185 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $orderAdded = TRUE; |
| 188 | 188 | if ($direction === Order::ASC) { |
| 189 | 189 | $query->addAscendingOrderByColumn($field); |
| 190 | - } else { |
|
| 190 | + }else { |
|
| 191 | 191 | $query->addDescendingOrderByColumn($field); |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * @param ModelCriteria $query |
| 204 | 204 | */ |
| 205 | - private function addExtraColumns(ModelCriteria &$query) |
|
| 205 | + private function addExtraColumns(ModelCriteria & $query) |
|
| 206 | 206 | { |
| 207 | 207 | if (!empty($this->extraColumns)) { |
| 208 | 208 | foreach ($this->extraColumns as $expression => $columnName) { |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @param ModelCriteria $query |
| 218 | 218 | */ |
| 219 | - protected function joinTables(ModelCriteria &$query) |
|
| 219 | + protected function joinTables(ModelCriteria & $query) |
|
| 220 | 220 | { |
| 221 | 221 | //TODO for specific implementations |
| 222 | 222 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @param ModelCriteria $query |
| 228 | 228 | */ |
| 229 | - private function addFilters(ModelCriteria &$query) |
|
| 229 | + private function addFilters(ModelCriteria & $query) |
|
| 230 | 230 | { |
| 231 | 231 | if (count($this->query) > 0) { |
| 232 | 232 | foreach ($this->query as $field => $value) { |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
| 244 | 244 | $text = preg_replace('/(\'|\")/', '', $value); |
| 245 | 245 | $query->filterBy($tableField, $text, Criteria::LIKE); |
| 246 | - } else { |
|
| 246 | + }else { |
|
| 247 | 247 | $query->filterBy($tableField, $value, Criteria::EQUAL); |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -266,10 +266,10 @@ discard block |
||
| 266 | 266 | list($page, $limit) = $this->extractPagination(); |
| 267 | 267 | if ($limit == -1) { |
| 268 | 268 | $this->list = $query->find($this->con); |
| 269 | - } else { |
|
| 269 | + }else { |
|
| 270 | 270 | $this->list = $query->paginate($page, $limit, $this->con); |
| 271 | 271 | } |
| 272 | - } catch (\Exception $e) { |
|
| 272 | + }catch (\Exception $e) { |
|
| 273 | 273 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
| 274 | 274 | } |
| 275 | 275 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | $this->joinTables($query); |
| 287 | 287 | $this->addExtraColumns($query); |
| 288 | 288 | $this->model = $query->findPk($pk); |
| 289 | - } catch (\Exception $e) { |
|
| 289 | + }catch (\Exception $e) { |
|
| 290 | 290 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $saved = TRUE; |
| 375 | 375 | $model = $this->model->toArray(); |
| 376 | 376 | } |
| 377 | - } catch (\Exception $e) { |
|
| 377 | + }catch (\Exception $e) { |
|
| 378 | 378 | jpre($e->getMessage(), TRUE); |
| 379 | 379 | Logger::getInstance()->errorLog($e->getMessage()); |
| 380 | 380 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | $this->model->delete($this->con); |
| 404 | 404 | $deleted = TRUE; |
| 405 | 405 | } |
| 406 | - } catch (\Exception $e) { |
|
| 406 | + }catch (\Exception $e) { |
|
| 407 | 407 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
| 408 | 408 | } |
| 409 | 409 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | */ |
| 448 | 448 | private function extractQuery() |
| 449 | 449 | { |
| 450 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
| 450 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
| 451 | 451 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
| 452 | 452 | $query = $queryReflector->getMethod('create')->invoke(NULL); |
| 453 | 453 | |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | if ($this->con->inTransaction()) { |
| 492 | 492 | if ($status === 200) { |
| 493 | 493 | $this->con->commit(); |
| 494 | - } else { |
|
| 494 | + }else { |
|
| 495 | 495 | $this->con->rollBack(); |
| 496 | 496 | } |
| 497 | 497 | } |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | return $this->render('api.admin.html.twig', array( |
| 536 | 536 | "api" => $this->getApi(), |
| 537 | 537 | "domain" => $this->domain, |
| 538 | - "url" => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)), |
|
| 538 | + "url" => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)), |
|
| 539 | 539 | )); |
| 540 | 540 | } |
| 541 | 541 | |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | $return = $this->list->toArray(); |
| 573 | 573 | $total = $this->list->getNbResults(); |
| 574 | 574 | $pages = $this->list->getLastPage(); |
| 575 | - } catch (\Exception $e) { |
|
| 575 | + }catch (\Exception $e) { |
|
| 576 | 576 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
| 577 | 577 | } |
| 578 | 578 | |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | $return = array(); |
| 593 | 593 | if (NULL === $model) { |
| 594 | 594 | $code = 404; |
| 595 | - } else { |
|
| 595 | + }else { |
|
| 596 | 596 | $return = $model->toArray(); |
| 597 | 597 | } |
| 598 | 598 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | if (!preg_match('/^\@ROOT/i', $domain)) { |
| 34 | 34 | $modules[] = str_replace('/', '', str_replace('@', '', $domain)); |
| 35 | 35 | } |
| 36 | - } catch (\Exception $e) { |
|
| 36 | + }catch (\Exception $e) { |
|
| 37 | 37 | $modules[] = $e->getMessage(); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function extractApiEndpoints($module) |
| 53 | 53 | { |
| 54 | - $module_path = CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Api"; |
|
| 54 | + $module_path = CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Api"; |
|
| 55 | 55 | $endpoints = []; |
| 56 | 56 | if (file_exists($module_path)) { |
| 57 | 57 | $finder = new Finder(); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if (count($finder)) { |
| 60 | 60 | /** @var \SplFileInfo $file */ |
| 61 | 61 | foreach ($finder as $file) { |
| 62 | - $namespace = "\\{$module}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
| 62 | + $namespace = "\\{$module}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
| 63 | 63 | $endpoints[$namespace] = $this->extractApiInfo($namespace); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | if (count($returnTypes)) { |
| 228 | 228 | $closure = $modelDto = []; |
| 229 | 229 | $isArray = false; |
| 230 | - foreach($returnTypes as $returnType) { |
|
| 230 | + foreach ($returnTypes as $returnType) { |
|
| 231 | 231 | try { |
| 232 | 232 | if (false === strpos($returnType, '@')) { |
| 233 | 233 | $class = str_replace('{__API__}', $model, $returnType); |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | if (class_exists($class)) { |
| 239 | 239 | $reflector = new \ReflectionClass($class); |
| 240 | 240 | if ($reflector->isSubclassOf(self::DTO_INTERFACE)) { |
| 241 | - foreach($reflector->getProperties(\ReflectionMethod::IS_PUBLIC) as $property) { |
|
| 241 | + foreach ($reflector->getProperties(\ReflectionMethod::IS_PUBLIC) as $property) { |
|
| 242 | 242 | $closure[$property->getName()] = $this->extractVarType($property->getDocComment()); |
| 243 | 243 | } |
| 244 | - } else { |
|
| 244 | + }else { |
|
| 245 | 245 | $modelDto = $this->extractModelFields($class); |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | - } catch(\Exception $e) { |
|
| 249 | + }catch (\Exception $e) { |
|
| 250 | 250 | Logger::getInstance()->errorLog($e->getMessage()); |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | - } catch(\Exception $e) { |
|
| 282 | + }catch (\Exception $e) { |
|
| 283 | 283 | Logger::getInstance()->errorLog($e->getMessage()); |
| 284 | 284 | } |
| 285 | 285 | |