@@ -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 | |
@@ -326,13 +326,13 @@ discard block |
||
| 326 | 326 | $this->con->beginTransaction(); |
| 327 | 327 | $this->hydrateModel($pk); |
| 328 | 328 | if (NULL !== $this->model) { |
| 329 | - if(method_exists('clearAllReferences', $this->model)) { |
|
| 329 | + if (method_exists('clearAllReferences', $this->model)) { |
|
| 330 | 330 | $this->model->clearAllReferences(true); |
| 331 | 331 | } |
| 332 | 332 | $this->model->delete($this->con); |
| 333 | 333 | $deleted = TRUE; |
| 334 | 334 | } |
| 335 | - } catch (\Exception $e) { |
|
| 335 | + }catch (\Exception $e) { |
|
| 336 | 336 | $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados'); |
| 337 | 337 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
| 338 | 338 | } |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $this->saveBulk(); |
| 361 | 361 | $saved = true; |
| 362 | 362 | $status = 200; |
| 363 | - } catch(\Exception $e) { |
|
| 363 | + }catch (\Exception $e) { |
|
| 364 | 364 | Logger::log($e->getMessage(), LOG_ERR, $this->getRequest()->getData()); |
| 365 | 365 | $message = _('Bulk insert rolled back'); |
| 366 | 366 | } |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | $total = $this->list->getNbResults(); |
| 393 | 393 | $pages = $this->list->getLastPage(); |
| 394 | 394 | } |
| 395 | - } catch (\Exception $e) { |
|
| 396 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 395 | + }catch (\Exception $e) { |
|
| 396 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | return array($return, $total, $pages); |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | $return = array(); |
| 412 | 412 | if (NULL === $model || !method_exists($model, 'toArray')) { |
| 413 | 413 | $code = 404; |
| 414 | - } else { |
|
| 414 | + }else { |
|
| 415 | 415 | $return = $model->toArray(); |
| 416 | 416 | } |
| 417 | 417 | |