@@ -4,15 +4,12 @@ |
||
| 4 | 4 | use Propel\Runtime\ActiveQuery\ModelCriteria; |
| 5 | 5 | use Propel\Runtime\Map\TableMap; |
| 6 | 6 | use Propel\Runtime\Propel; |
| 7 | -use PSFS\base\config\Config; |
|
| 8 | 7 | use PSFS\base\dto\JsonResponse; |
| 9 | 8 | use PSFS\base\dto\Order; |
| 10 | 9 | use PSFS\base\Logger; |
| 11 | 10 | use PSFS\base\Request; |
| 12 | -use PSFS\base\Security; |
|
| 13 | 11 | use PSFS\base\Singleton; |
| 14 | 12 | use PSFS\base\types\helpers\ApiHelper; |
| 15 | -use PSFS\base\types\helpers\Inspector; |
|
| 16 | 13 | use PSFS\base\types\traits\Api\ManagerTrait; |
| 17 | 14 | |
| 18 | 15 | /** |
@@ -74,15 +74,15 @@ discard block |
||
| 74 | 74 | public function init() |
| 75 | 75 | { |
| 76 | 76 | parent::init(); |
| 77 | - Logger::log(get_called_class() . ' init', LOG_DEBUG); |
|
| 77 | + Logger::log(get_called_class().' init', LOG_DEBUG); |
|
| 78 | 78 | $this->domain = $this->getDomain(); |
| 79 | 79 | $this->hydrateRequestData(); |
| 80 | 80 | $this->hydrateOrders(); |
| 81 | - if($this instanceof CustomApi === false) { |
|
| 81 | + if ($this instanceof CustomApi === false) { |
|
| 82 | 82 | $this->createConnection($this->getTableMap()); |
| 83 | 83 | } |
| 84 | 84 | $this->setLoaded(true); |
| 85 | - Logger::log(get_called_class() . ' loaded', LOG_DEBUG); |
|
| 85 | + Logger::log(get_called_class().' loaded', LOG_DEBUG); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | protected function hydrateOrders() |
| 92 | 92 | { |
| 93 | 93 | if (count($this->query)) { |
| 94 | - Logger::log(get_called_class() . ' gathering query string', LOG_DEBUG); |
|
| 94 | + Logger::log(get_called_class().' gathering query string', LOG_DEBUG); |
|
| 95 | 95 | foreach ($this->query as $key => $value) { |
| 96 | 96 | if ($key === self::API_ORDER_FIELD) { |
| 97 | 97 | foreach ($value as $field => $direction) { |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function extractPagination() |
| 110 | 110 | { |
| 111 | - Logger::log(get_called_class() . ' extract pagination start', LOG_DEBUG); |
|
| 111 | + Logger::log(get_called_class().' extract pagination start', LOG_DEBUG); |
|
| 112 | 112 | $page = (array_key_exists(self::API_PAGE_FIELD, $this->query)) ? $this->query[self::API_PAGE_FIELD] : 1; |
| 113 | 113 | $limit = (array_key_exists(self::API_LIMIT_FIELD, $this->query)) ? $this->query[self::API_LIMIT_FIELD] : 100; |
| 114 | - Logger::log(get_called_class() . ' extract pagination end', LOG_DEBUG); |
|
| 114 | + Logger::log(get_called_class().' extract pagination end', LOG_DEBUG); |
|
| 115 | 115 | return array($page, $limit); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @param ModelCriteria $query |
| 122 | 122 | */ |
| 123 | - private function addOrders(ModelCriteria &$query) |
|
| 123 | + private function addOrders(ModelCriteria & $query) |
|
| 124 | 124 | { |
| 125 | - Logger::log(get_called_class() . ' extract orders start ', LOG_DEBUG); |
|
| 125 | + Logger::log(get_called_class().' extract orders start ', LOG_DEBUG); |
|
| 126 | 126 | $orderAdded = FALSE; |
| 127 | 127 | $tableMap = $this->getTableMap(); |
| 128 | 128 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -130,17 +130,17 @@ discard block |
||
| 130 | 130 | $orderAdded = TRUE; |
| 131 | 131 | if ($direction === Order::ASC) { |
| 132 | 132 | $query->addAscendingOrderByColumn($column->getPhpName()); |
| 133 | - } else { |
|
| 133 | + }else { |
|
| 134 | 134 | $query->addDescendingOrderByColumn($column->getPhpName()); |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | if (!$orderAdded) { |
| 139 | - foreach($this->getPkDbName() as $pk => $phpName) { |
|
| 139 | + foreach ($this->getPkDbName() as $pk => $phpName) { |
|
| 140 | 140 | $query->addAscendingOrderByColumn($pk); |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | - Logger::log(get_called_class() . ' extract orders end', LOG_DEBUG); |
|
| 143 | + Logger::log(get_called_class().' extract orders end', LOG_DEBUG); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @param ModelCriteria $query |
| 150 | 150 | */ |
| 151 | - protected function addFilters(ModelCriteria &$query) |
|
| 151 | + protected function addFilters(ModelCriteria & $query) |
|
| 152 | 152 | { |
| 153 | 153 | if (count($this->query) > 0) { |
| 154 | 154 | $tableMap = $this->getTableMap(); |
| 155 | 155 | foreach ($this->query as $field => $value) { |
| 156 | 156 | if (self::API_COMBO_FIELD === $field) { |
| 157 | 157 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
| 158 | - } elseif(!preg_match('/^__/', $field)) { |
|
| 158 | + } elseif (!preg_match('/^__/', $field)) { |
|
| 159 | 159 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | list($page, $limit) = $this->extractPagination(); |
| 177 | 177 | if ($limit == -1) { |
| 178 | 178 | $this->list = $query->find($this->con); |
| 179 | - } else { |
|
| 179 | + }else { |
|
| 180 | 180 | $this->list = $query->paginate($page, $limit, $this->con); |
| 181 | 181 | } |
| 182 | - } catch (\Exception $e) { |
|
| 182 | + }catch (\Exception $e) { |
|
| 183 | 183 | Logger::log($e->getMessage(), LOG_ERR); |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $code = 200; |
| 199 | 199 | list($return, $total, $pages) = $this->getList(); |
| 200 | 200 | $message = null; |
| 201 | - if(!$total) { |
|
| 201 | + if (!$total) { |
|
| 202 | 202 | $message = _('No se han encontrado elementos para la búsqueda'); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $pages = 1; |
| 225 | 225 | $message = null; |
| 226 | 226 | list($code, $return) = $this->getSingleResult($pk); |
| 227 | - if($code !== 200) { |
|
| 227 | + if ($code !== 200) { |
|
| 228 | 228 | $message = _('No se ha encontrado el elemento solicitado'); |
| 229 | 229 | } |
| 230 | 230 | |
@@ -253,11 +253,11 @@ discard block |
||
| 253 | 253 | $status = 200; |
| 254 | 254 | $saved = TRUE; |
| 255 | 255 | $model = $this->model->toArray(); |
| 256 | - } else { |
|
| 256 | + }else { |
|
| 257 | 257 | $message = _('No se ha podido guardar el modelo seleccionado'); |
| 258 | 258 | } |
| 259 | - } catch (\Exception $e) { |
|
| 260 | - $message = _('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage(); |
|
| 259 | + }catch (\Exception $e) { |
|
| 260 | + $message = _('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
| 261 | 261 | Logger::log($e->getMessage(), LOG_ERR); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -291,14 +291,14 @@ discard block |
||
| 291 | 291 | $updated = TRUE; |
| 292 | 292 | $status = 200; |
| 293 | 293 | $model = $this->model->toArray(); |
| 294 | - } else { |
|
| 294 | + }else { |
|
| 295 | 295 | $message = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 296 | 296 | } |
| 297 | - } catch (\Exception $e) { |
|
| 297 | + }catch (\Exception $e) { |
|
| 298 | 298 | $message = $e->getMessage(); |
| 299 | 299 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
| 300 | 300 | } |
| 301 | - } else { |
|
| 301 | + }else { |
|
| 302 | 302 | $message = _('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
| 303 | 303 | } |
| 304 | 304 | |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | $this->model->delete($this->con); |
| 329 | 329 | $deleted = TRUE; |
| 330 | 330 | } |
| 331 | - } catch (\Exception $e) { |
|
| 331 | + }catch (\Exception $e) { |
|
| 332 | 332 | $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados'); |
| 333 | 333 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
| 334 | 334 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $this->saveBulk(); |
| 357 | 357 | $saved = true; |
| 358 | 358 | $status = 200; |
| 359 | - } catch(\Exception $e) { |
|
| 359 | + }catch (\Exception $e) { |
|
| 360 | 360 | Logger::log($e->getMessage(), LOG_ERR, $this->getRequest()->getData()); |
| 361 | 361 | $message = _('Bulk insert rolled back'); |
| 362 | 362 | } |
@@ -388,8 +388,8 @@ discard block |
||
| 388 | 388 | $total = $this->list->getNbResults(); |
| 389 | 389 | $pages = $this->list->getLastPage(); |
| 390 | 390 | } |
| 391 | - } catch (\Exception $e) { |
|
| 392 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 391 | + }catch (\Exception $e) { |
|
| 392 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | return array($return, $total, $pages); |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | $return = array(); |
| 408 | 408 | if (NULL === $model || !method_exists($model, 'toArray')) { |
| 409 | 409 | $code = 404; |
| 410 | - } else { |
|
| 410 | + }else { |
|
| 411 | 411 | $return = $model->toArray(); |
| 412 | 412 | } |
| 413 | 413 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param $object |
| 48 | 48 | * @param $paths |
| 49 | 49 | * @param $url |
| 50 | - * @param $method |
|
| 50 | + * @param string $method |
|
| 51 | 51 | * @param $dtos |
| 52 | 52 | * @return array |
| 53 | 53 | */ |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * Translator from php types to swagger types |
| 85 | 85 | * @param string $format |
| 86 | 86 | * |
| 87 | - * @return array |
|
| 87 | + * @return string[] |
|
| 88 | 88 | */ |
| 89 | 89 | public static function translateSwaggerFormats($format) |
| 90 | 90 | { |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | ]; |
| 28 | 28 | if ($endpoint['payload']['is_array']) { |
| 29 | 29 | $schema['items'] = [ |
| 30 | - '$ref' => '#/definitions/' . $endpoint['payload']['type'], |
|
| 30 | + '$ref' => '#/definitions/'.$endpoint['payload']['type'], |
|
| 31 | 31 | ]; |
| 32 | - } else { |
|
| 33 | - $schema['$ref'] = '#/definitions/' . $endpoint['payload']['type']; |
|
| 32 | + }else { |
|
| 33 | + $schema['$ref'] = '#/definitions/'.$endpoint['payload']['type']; |
|
| 34 | 34 | } |
| 35 | 35 | $paths[$url][$method]['parameters'][] = [ |
| 36 | 36 | 'in' => 'body', |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) { |
| 59 | 59 | $classDefinition = [ |
| 60 | 60 | 'type' => 'object', |
| 61 | - '$ref' => '#/definitions/' . $class, |
|
| 61 | + '$ref' => '#/definitions/'.$class, |
|
| 62 | 62 | ]; |
| 63 | - } else { |
|
| 63 | + }else { |
|
| 64 | 64 | $classDefinition = [ |
| 65 | 65 | 'type' => 'array', |
| 66 | 66 | 'items' => [ |
| 67 | - '$ref' => '#/definitions/' . $class, |
|
| 67 | + '$ref' => '#/definitions/'.$class, |
|
| 68 | 68 | ], |
| 69 | 69 | ]; |
| 70 | 70 | } |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | namespace PSFS\base\types\helpers; |
| 3 | 3 | |
| 4 | 4 | use PSFS\base\Logger; |
| 5 | -use PSFS\services\DocumentorService; |
|
| 6 | 5 | |
| 7 | 6 | /** |
| 8 | 7 | * Class InjectorHelper |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | use PSFS\base\Router; |
| 10 | 10 | use PSFS\base\Service; |
| 11 | 11 | use PSFS\base\types\helpers\DocumentorHelper; |
| 12 | -use PSFS\base\types\helpers\GeneratorHelper; |
|
| 13 | 12 | use PSFS\base\types\helpers\I18nHelper; |
| 14 | 13 | use PSFS\base\types\helpers\InjectorHelper; |
| 15 | 14 | use PSFS\base\types\helpers\RouterHelper; |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) { |
| 58 | 58 | $modules = [ |
| 59 | 59 | 'name' => $module, |
| 60 | - 'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'), |
|
| 60 | + 'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'), |
|
| 61 | 61 | ]; |
| 62 | 62 | } |
| 63 | - } catch (\Exception $e) { |
|
| 63 | + }catch (\Exception $e) { |
|
| 64 | 64 | $modules[] = $e->getMessage(); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function extractApiEndpoints(array $module) |
| 80 | 80 | { |
| 81 | - $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
| 81 | + $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
| 82 | 82 | $module_name = $module['name']; |
| 83 | 83 | $endpoints = []; |
| 84 | 84 | if (file_exists($module_path)) { |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | if (count($finder)) { |
| 88 | 88 | /** @var \SplFileInfo $file */ |
| 89 | 89 | foreach ($finder as $file) { |
| 90 | - $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
| 90 | + $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
| 91 | 91 | $info = $this->extractApiInfo($namespace, $module_name); |
| 92 | 92 | if (!empty($info)) { |
| 93 | 93 | $endpoints[$namespace] = $info; |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | if (Router::exists($namespace) && !I18nHelper::checkI18Class($namespace)) { |
| 112 | 112 | $reflection = new \ReflectionClass($namespace); |
| 113 | 113 | $visible = InjectorHelper::checkIsVisible($reflection->getDocComment()); |
| 114 | - if($visible) { |
|
| 114 | + if ($visible) { |
|
| 115 | 115 | foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
| 116 | 116 | try { |
| 117 | 117 | $mInfo = $this->extractMethodInfo($namespace, $method, $reflection, $module); |
| 118 | 118 | if (NULL !== $mInfo) { |
| 119 | 119 | $info[] = $mInfo; |
| 120 | 120 | } |
| 121 | - } catch (\Exception $e) { |
|
| 121 | + }catch (\Exception $e) { |
|
| 122 | 122 | Logger::getInstance()->errorLog($e->getMessage()); |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $payload = $this->extractModelFields($namespace); |
| 252 | 252 | $reflector = new \ReflectionClass($namespace); |
| 253 | 253 | $namespace = $reflector->getShortName(); |
| 254 | - } else { |
|
| 254 | + }else { |
|
| 255 | 255 | $namespace = $model; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -338,10 +338,10 @@ discard block |
||
| 338 | 338 | "required" => $field->isNotNull(), |
| 339 | 339 | 'format' => $format, |
| 340 | 340 | ]; |
| 341 | - if(count($field->getValueSet())) { |
|
| 341 | + if (count($field->getValueSet())) { |
|
| 342 | 342 | $info['enum'] = array_values($field->getValueSet()); |
| 343 | 343 | } |
| 344 | - if(null !== $field->getDefaultValue()) { |
|
| 344 | + if (null !== $field->getDefaultValue()) { |
|
| 345 | 345 | $info['default'] = $field->getDefaultValue(); |
| 346 | 346 | } |
| 347 | 347 | $payload[$field->getPhpName()] = $info; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
| 350 | 350 | $payload = $this->extractDtoProperties($namespace); |
| 351 | 351 | } |
| 352 | - } catch (\Exception $e) { |
|
| 352 | + }catch (\Exception $e) { |
|
| 353 | 353 | Logger::getInstance()->errorLog($e->getMessage()); |
| 354 | 354 | } |
| 355 | 355 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | $return = $this->extractReturn($modelNamespace, $docComments); |
| 381 | 381 | $url = array_pop($route); |
| 382 | 382 | $methodInfo = [ |
| 383 | - 'url' => str_replace("/" . $module . "/api", '', $url), |
|
| 383 | + 'url' => str_replace("/".$module."/api", '', $url), |
|
| 384 | 384 | 'method' => $info['http'], |
| 385 | 385 | 'description' => $info['label'], |
| 386 | 386 | 'return' => $return, |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments); |
| 392 | 392 | $this->setQueryParams($method, $methodInfo); |
| 393 | 393 | $this->setRequestHeaders($reflection, $methodInfo); |
| 394 | - } catch (\Exception $e) { |
|
| 394 | + }catch (\Exception $e) { |
|
| 395 | 395 | Logger::getInstance()->errorLog($e->getMessage()); |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -460,10 +460,10 @@ discard block |
||
| 460 | 460 | $formatted = [ |
| 461 | 461 | "swagger" => "2.0", |
| 462 | 462 | "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)), |
| 463 | - "basePath" => '/' . $module['name'] . '/api', |
|
| 463 | + "basePath" => '/'.$module['name'].'/api', |
|
| 464 | 464 | "schemes" => [Request::getInstance()->getServer('HTTPS') == 'on' ? "https" : "http"], |
| 465 | 465 | "info" => [ |
| 466 | - "title" => _('Documentación API módulo ') . $module['name'], |
|
| 466 | + "title" => _('Documentación API módulo ').$module['name'], |
|
| 467 | 467 | "version" => Config::getParam('api.version', '1.0.0'), |
| 468 | 468 | "contact" => [ |
| 469 | 469 | "name" => Config::getParam("author", "Fran López"), |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | foreach ($endpoints as $model) { |
| 477 | 477 | foreach ($model as $endpoint) { |
| 478 | 478 | if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
| 479 | - $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']); |
|
| 479 | + $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']); |
|
| 480 | 480 | $description = $endpoint['description']; |
| 481 | 481 | $method = strtolower($endpoint['method']); |
| 482 | 482 | $paths[$url][$method] = [ |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | protected function extractDtoName($dto, $isArray = false) |
| 536 | 536 | { |
| 537 | 537 | $dto = explode('\\', $dto); |
| 538 | - $modelDto = array_pop($dto) . "Dto"; |
|
| 538 | + $modelDto = array_pop($dto)."Dto"; |
|
| 539 | 539 | if ($isArray) { |
| 540 | 540 | $modelDto .= "List"; |
| 541 | 541 | } |
@@ -585,10 +585,10 @@ discard block |
||
| 585 | 585 | { |
| 586 | 586 | |
| 587 | 587 | $methodInfo['headers'] = []; |
| 588 | - foreach($reflection->getProperties() as $property) { |
|
| 588 | + foreach ($reflection->getProperties() as $property) { |
|
| 589 | 589 | $doc = $property->getDocComment(); |
| 590 | 590 | preg_match('/@header\ (.*)\n/i', $doc, $headers); |
| 591 | - if(count($headers)) { |
|
| 591 | + if (count($headers)) { |
|
| 592 | 592 | $header = [ |
| 593 | 593 | "name" => $headers[1], |
| 594 | 594 | "in" => "header", |
@@ -600,13 +600,13 @@ discard block |
||
| 600 | 600 | |
| 601 | 601 | // Extract description |
| 602 | 602 | preg_match('/@label\ (.*)\n/i', $doc, $label); |
| 603 | - if(count($label)) { |
|
| 603 | + if (count($label)) { |
|
| 604 | 604 | $header['description'] = _($label[1]); |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | // Extract default value |
| 608 | 608 | preg_match('/@default\ (.*)\n/i', $doc, $default); |
| 609 | - if(count($default)) { |
|
| 609 | + if (count($default)) { |
|
| 610 | 610 | $header['default'] = $default[1]; |
| 611 | 611 | } |
| 612 | 612 | $methodInfo['headers'][] = $header; |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | foreach ($method->getParameters() as $parameter) { |
| 638 | 638 | $parameterName = $parameter->getName(); |
| 639 | 639 | $types = []; |
| 640 | - preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types); |
|
| 640 | + preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types); |
|
| 641 | 641 | if (count($types) > 1) { |
| 642 | 642 | $methodInfo['parameters'][$parameterName] = $types[1][0]; |
| 643 | 643 | } |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | protected function hydrateBulkRequest() { |
| 97 | 97 | $class = new \ReflectionClass($this->getModelNamespace()); |
| 98 | - foreach($this->data as $item) { |
|
| 99 | - if(count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
| 98 | + foreach ($this->data as $item) { |
|
| 99 | + if (count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
| 100 | 100 | /** @var ActiveRecordInterface $model */ |
| 101 | 101 | $model = $class->newInstance(); |
| 102 | 102 | $this->hydrateModelFromRequest($model, $item); |
| 103 | 103 | $this->list[] = $model; |
| 104 | - } else { |
|
| 105 | - Logger::log(_('Max items per bulk insert raised'), LOG_WARNING, count($this->data) . _('items')); |
|
| 104 | + }else { |
|
| 105 | + Logger::log(_('Max items per bulk insert raised'), LOG_WARNING, count($this->data)._('items')); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | protected function saveBulk() { |
| 114 | 114 | $tablemap = $this->getTableMap(); |
| 115 | - foreach($this->list as &$model) { |
|
| 115 | + foreach ($this->list as &$model) { |
|
| 116 | 116 | $con = Propel::getWriteConnection($tablemap::DATABASE_NAME); |
| 117 | 117 | try { |
| 118 | 118 | $model->save($con); |
| 119 | 119 | $con->commit(); |
| 120 | - } catch(\Exception $e) { |
|
| 120 | + }catch (\Exception $e) { |
|
| 121 | 121 | Logger::log($e->getMessage(), LOG_ERR, $model->toArray()); |
| 122 | 122 | $con->rollBack(); |
| 123 | 123 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | protected function exportList() { |
| 131 | 131 | $list = []; |
| 132 | 132 | /** @var ActiveRecordInterface $item */ |
| 133 | - foreach($this->list as $item) { |
|
| 133 | + foreach ($this->list as $item) { |
|
| 134 | 134 | $list[] = $item->toArray(); |
| 135 | 135 | } |
| 136 | 136 | return $list; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @param ModelCriteria $query |
| 143 | 143 | */ |
| 144 | - protected function joinTables(ModelCriteria &$query) |
|
| 144 | + protected function joinTables(ModelCriteria & $query) |
|
| 145 | 145 | { |
| 146 | 146 | //TODO for specific implementations |
| 147 | 147 | } |
@@ -154,16 +154,16 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function findPk(ModelCriteria $query, $pk) { |
| 156 | 156 | $pks = explode(Api::API_PK_SEPARATOR, urldecode($pk)); |
| 157 | - if(count($pks) == 1 && !empty($pks[0])) { |
|
| 157 | + if (count($pks) == 1 && !empty($pks[0])) { |
|
| 158 | 158 | $model = $query->findPk($pks[0], $this->con); |
| 159 | - } else { |
|
| 159 | + }else { |
|
| 160 | 160 | $i = 0; |
| 161 | - foreach($this->getPkDbName() as $key => $phpName) { |
|
| 161 | + foreach ($this->getPkDbName() as $key => $phpName) { |
|
| 162 | 162 | try { |
| 163 | 163 | $query->filterBy($phpName, $pks[$i]); |
| 164 | 164 | $i++; |
| 165 | - if($i >= count($pks)) break; |
|
| 166 | - } catch(\Exception $e) { |
|
| 165 | + if ($i >= count($pks)) break; |
|
| 166 | + }catch (\Exception $e) { |
|
| 167 | 167 | Logger::log($e->getMessage(), LOG_DEBUG); |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | try { |
| 194 | 194 | $query = $this->prepareQuery(); |
| 195 | 195 | $this->model = $this->findPk($query, $pk); |
| 196 | - } catch (\Exception $e) { |
|
| 197 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 196 | + }catch (\Exception $e) { |
|
| 197 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | /** |
| 216 | 216 | * @param ModelCriteria $query |
| 217 | 217 | */ |
| 218 | - protected function checkReturnFields(ModelCriteria &$query) |
|
| 218 | + protected function checkReturnFields(ModelCriteria & $query) |
|
| 219 | 219 | { |
| 220 | 220 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
| 221 | 221 | if (null !== $returnFields) { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $this->con = Propel::getConnection($tableMap::DATABASE_NAME); |
| 34 | 34 | $this->con->beginTransaction(); |
| 35 | - if(method_exists($this->con, 'useDebug')) { |
|
| 35 | + if (method_exists($this->con, 'useDebug')) { |
|
| 36 | 36 | Logger::log('Enabling debug queries mode', LOG_INFO); |
| 37 | 37 | $this->con->useDebug(Config::getParam('debug')); |
| 38 | 38 | } |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | protected function closeTransaction($status) |
| 47 | 47 | { |
| 48 | - if(null !== $this->con) { |
|
| 48 | + if (null !== $this->con) { |
|
| 49 | 49 | $this->traceDebugQuery(); |
| 50 | 50 | if (null !== $this->con && $this->con->inTransaction()) { |
| 51 | 51 | if ($status === 200) { |
| 52 | 52 | $this->con->commit(); |
| 53 | - } else { |
|
| 53 | + }else { |
|
| 54 | 54 | $this->con->rollBack(); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | * Checks if the connection has a transaction initialized |
| 73 | 73 | */ |
| 74 | 74 | protected function checkTransaction() { |
| 75 | - if(null !== $this->con && !$this->con->inTransaction()) { |
|
| 75 | + if (null !== $this->con && !$this->con->inTransaction()) { |
|
| 76 | 76 | $this->con->beginTransaction(); |
| 77 | 77 | } |
| 78 | - if(null !== $this->con && $this->con->inTransaction()) { |
|
| 78 | + if (null !== $this->con && $this->con->inTransaction()) { |
|
| 79 | 79 | $this->items++; |
| 80 | 80 | } |
| 81 | - if($this->items >= Config::getParam('api.block.limit', 1000)) { |
|
| 81 | + if ($this->items >= Config::getParam('api.block.limit', 1000)) { |
|
| 82 | 82 | $this->con->commit(); |
| 83 | 83 | $this->items = 0; |
| 84 | 84 | } |