@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use PSFS\base\Request; |
| 15 | 15 | use PSFS\base\Singleton; |
| 16 | 16 | use PSFS\base\types\helpers\ApiHelper; |
| 17 | -use PSFS\base\types\helpers\Inspector; |
|
| 18 | 17 | use PSFS\base\types\traits\Api\ManagerTrait; |
| 19 | 18 | |
| 20 | 19 | /** |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | public function init() |
| 83 | 83 | { |
| 84 | 84 | parent::init(); |
| 85 | - Logger::log(static::class . ' init', LOG_DEBUG); |
|
| 85 | + Logger::log(static::class.' init', LOG_DEBUG); |
|
| 86 | 86 | $this->domain = $this->getDomain(); |
| 87 | 87 | $this->hydrateRequestData(); |
| 88 | 88 | $this->hydrateOrders(); |
| 89 | - if($this instanceof CustomApi === false) { |
|
| 89 | + if ($this instanceof CustomApi === false) { |
|
| 90 | 90 | $this->createConnection($this->getTableMap()); |
| 91 | 91 | } |
| 92 | 92 | $this->setLoaded(true); |
| 93 | - Logger::log(static::class . ' loaded', LOG_DEBUG); |
|
| 93 | + Logger::log(static::class.' loaded', LOG_DEBUG); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | private function checkActions($method) { |
| 97 | - switch($method) { |
|
| 97 | + switch ($method) { |
|
| 98 | 98 | default: |
| 99 | 99 | case 'modelList': $this->action = self::API_ACTION_LIST; break; |
| 100 | 100 | case 'get': $this->action = self::API_ACTION_GET; break; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | protected function hydrateOrders() |
| 112 | 112 | { |
| 113 | 113 | if (count($this->query)) { |
| 114 | - Logger::log(static::class . ' gathering query string', LOG_DEBUG); |
|
| 114 | + Logger::log(static::class.' gathering query string', LOG_DEBUG); |
|
| 115 | 115 | foreach ($this->query as $key => $value) { |
| 116 | 116 | if ($key === self::API_ORDER_FIELD && is_array($value)) { |
| 117 | 117 | foreach ($value as $field => $direction) { |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function extractPagination() |
| 130 | 130 | { |
| 131 | - Logger::log(static::class . ' extract pagination start', LOG_DEBUG); |
|
| 131 | + Logger::log(static::class.' extract pagination start', LOG_DEBUG); |
|
| 132 | 132 | $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1; |
| 133 | 133 | $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100; |
| 134 | - Logger::log(static::class . ' extract pagination end', LOG_DEBUG); |
|
| 134 | + Logger::log(static::class.' extract pagination end', LOG_DEBUG); |
|
| 135 | 135 | return array($page, $limit); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | private function addOrders(ModelCriteria &$query) |
| 144 | 144 | { |
| 145 | - Logger::log(static::class . ' extract orders start ', LOG_DEBUG); |
|
| 145 | + Logger::log(static::class.' extract orders start ', LOG_DEBUG); |
|
| 146 | 146 | $orderAdded = FALSE; |
| 147 | 147 | $tableMap = $this->getTableMap(); |
| 148 | 148 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -150,17 +150,17 @@ discard block |
||
| 150 | 150 | $orderAdded = TRUE; |
| 151 | 151 | if ($direction === Order::ASC) { |
| 152 | 152 | $query->addAscendingOrderByColumn($column->getPhpName()); |
| 153 | - } else { |
|
| 153 | + }else { |
|
| 154 | 154 | $query->addDescendingOrderByColumn($column->getPhpName()); |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | if (!$orderAdded) { |
| 159 | - foreach($this->getPkDbName() as $pk => $phpName) { |
|
| 159 | + foreach ($this->getPkDbName() as $pk => $phpName) { |
|
| 160 | 160 | $query->addAscendingOrderByColumn($pk); |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | - Logger::log(static::class . ' extract orders end', LOG_DEBUG); |
|
| 163 | + Logger::log(static::class.' extract orders end', LOG_DEBUG); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | foreach ($this->query as $field => $value) { |
| 176 | 176 | if (self::API_COMBO_FIELD === $field) { |
| 177 | 177 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
| 178 | - } elseif(!preg_match('/^__/', $field)) { |
|
| 178 | + } elseif (!preg_match('/^__/', $field)) { |
|
| 179 | 179 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -196,10 +196,10 @@ discard block |
||
| 196 | 196 | list($page, $limit) = $this->extractPagination(); |
| 197 | 197 | if ($limit == -1) { |
| 198 | 198 | $this->list = $query->find($this->con); |
| 199 | - } else { |
|
| 199 | + }else { |
|
| 200 | 200 | $this->list = $query->paginate($page, $limit, $this->con); |
| 201 | 201 | } |
| 202 | - } catch (\Exception $e) { |
|
| 202 | + }catch (\Exception $e) { |
|
| 203 | 203 | Logger::log($e->getMessage(), LOG_ERR); |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $code = 200; |
| 219 | 219 | list($return, $total, $pages) = $this->getList(); |
| 220 | 220 | $message = null; |
| 221 | - if(!$total) { |
|
| 221 | + if (!$total) { |
|
| 222 | 222 | $message = i18n::_('No se han encontrado elementos para la búsqueda'); |
| 223 | 223 | } |
| 224 | 224 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $pages = 1; |
| 245 | 245 | $message = null; |
| 246 | 246 | list($code, $return) = $this->getSingleResult($pk); |
| 247 | - if($code !== 200) { |
|
| 247 | + if ($code !== 200) { |
|
| 248 | 248 | $message = i18n::_('No se ha encontrado el elemento solicitado'); |
| 249 | 249 | } |
| 250 | 250 | |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | $status = 200; |
| 274 | 274 | $saved = TRUE; |
| 275 | 275 | $model = $this->model->toArray(); |
| 276 | - } else { |
|
| 276 | + }else { |
|
| 277 | 277 | $message = i18n::_('No se ha podido guardar el modelo seleccionado'); |
| 278 | 278 | } |
| 279 | - } catch (\Exception $e) { |
|
| 280 | - $message = i18n::_('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage(); |
|
| 279 | + }catch (\Exception $e) { |
|
| 280 | + $message = i18n::_('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
| 281 | 281 | $context = []; |
| 282 | - if(null !== $e->getPrevious()) { |
|
| 282 | + if (null !== $e->getPrevious()) { |
|
| 283 | 283 | $context[] = $e->getPrevious()->getMessage(); |
| 284 | 284 | } |
| 285 | 285 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -315,18 +315,18 @@ discard block |
||
| 315 | 315 | $updated = TRUE; |
| 316 | 316 | $status = 200; |
| 317 | 317 | $model = $this->model->toArray(); |
| 318 | - } else { |
|
| 318 | + }else { |
|
| 319 | 319 | $message = i18n::_('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 320 | 320 | } |
| 321 | - } catch (\Exception $e) { |
|
| 321 | + }catch (\Exception $e) { |
|
| 322 | 322 | $message = i18n::_('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 323 | 323 | $context = []; |
| 324 | - if(null !== $e->getPrevious()) { |
|
| 324 | + if (null !== $e->getPrevious()) { |
|
| 325 | 325 | $context[] = $e->getPrevious()->getMessage(); |
| 326 | 326 | } |
| 327 | 327 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
| 328 | 328 | } |
| 329 | - } else { |
|
| 329 | + }else { |
|
| 330 | 330 | $message = i18n::_('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
| 331 | 331 | } |
| 332 | 332 | |
@@ -354,15 +354,15 @@ discard block |
||
| 354 | 354 | $this->con->beginTransaction(); |
| 355 | 355 | $this->hydrateModel($pk); |
| 356 | 356 | if (NULL !== $this->model) { |
| 357 | - if(method_exists('clearAllReferences', $this->model)) { |
|
| 357 | + if (method_exists('clearAllReferences', $this->model)) { |
|
| 358 | 358 | $this->model->clearAllReferences(true); |
| 359 | 359 | } |
| 360 | 360 | $this->model->delete($this->con); |
| 361 | 361 | $deleted = TRUE; |
| 362 | 362 | } |
| 363 | - } catch (\Exception $e) { |
|
| 363 | + }catch (\Exception $e) { |
|
| 364 | 364 | $context = []; |
| 365 | - if(null !== $e->getPrevious()) { |
|
| 365 | + if (null !== $e->getPrevious()) { |
|
| 366 | 366 | $context[] = $e->getPrevious()->getMessage(); |
| 367 | 367 | } |
| 368 | 368 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $this->saveBulk(); |
| 393 | 393 | $saved = true; |
| 394 | 394 | $status = 200; |
| 395 | - } catch(\Exception $e) { |
|
| 395 | + }catch (\Exception $e) { |
|
| 396 | 396 | Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData()); |
| 397 | 397 | $message = i18n::_('Bulk insert rolled back'); |
| 398 | 398 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | /** @var CustomerTableMap $tableMap */ |
| 416 | 416 | $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap()); |
| 417 | - foreach($this->list->getData() as $data) { |
|
| 417 | + foreach ($this->list->getData() as $data) { |
|
| 418 | 418 | $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data); |
| 419 | 419 | } |
| 420 | 420 | return $return; |
@@ -431,23 +431,23 @@ discard block |
||
| 431 | 431 | try { |
| 432 | 432 | $this->paginate(); |
| 433 | 433 | if (null !== $this->list) { |
| 434 | - if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
| 434 | + if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
| 435 | 435 | $return = $this->extractDataWithFormat(); |
| 436 | - } else { |
|
| 436 | + }else { |
|
| 437 | 437 | $return = $this->list->toArray(null, false, TableMap::TYPE_PHPNAME, false); |
| 438 | 438 | } |
| 439 | 439 | $total = 0; |
| 440 | 440 | $pages = 0; |
| 441 | - if($this->list instanceof PropelModelPager) { |
|
| 441 | + if ($this->list instanceof PropelModelPager) { |
|
| 442 | 442 | $total = $this->list->getNbResults(); |
| 443 | 443 | $pages = $this->list->getLastPage(); |
| 444 | - } elseif($this->list instanceof ArrayCollection) { |
|
| 444 | + } elseif ($this->list instanceof ArrayCollection) { |
|
| 445 | 445 | $total = count($return); |
| 446 | 446 | $pages = 1; |
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | - } catch (\Exception $e) { |
|
| 450 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 449 | + }catch (\Exception $e) { |
|
| 450 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | return array($return, $total, $pages); |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | $return = array(); |
| 466 | 466 | if (NULL === $model || !method_exists($model, 'toArray')) { |
| 467 | 467 | $code = 404; |
| 468 | - } else { |
|
| 468 | + }else { |
|
| 469 | 469 | $return = $model->toArray(TableMap::TYPE_PHPNAME, true, [], true); |
| 470 | 470 | } |
| 471 | 471 | |
@@ -48,14 +48,14 @@ |
||
| 48 | 48 | /* @var $file SplFileInfo */ |
| 49 | 49 | foreach ($finder as $file) { |
| 50 | 50 | $path = $file->getRealPath(); |
| 51 | - if(!in_array($path, $loaded_files)) { |
|
| 51 | + if (!in_array($path, $loaded_files)) { |
|
| 52 | 52 | $loaded_files[] = $path; |
| 53 | 53 | require_once($path); |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | -if(!function_exists('t')) { |
|
| 58 | +if (!function_exists('t')) { |
|
| 59 | 59 | function t($message, $key = null, $reload = false) { |
| 60 | 60 | return CustomTranslateExtension::_($message, $key, $reload); |
| 61 | 61 | } |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function init() |
| 77 | 77 | { |
| 78 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
| 78 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
| 79 | 79 | if (empty($this->routing) || Config::getInstance()->getDebugMode()) { |
| 80 | 80 | $this->debugLoad(); |
| 81 | - } else { |
|
| 82 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
| 81 | + }else { |
|
| 82 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
| 83 | 83 | } |
| 84 | 84 | $this->checkExternalModules(false); |
| 85 | 85 | $this->setLoaded(); |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $not_found_route = Config::getParam('route.404'); |
| 120 | - if(null !== $not_found_route) { |
|
| 120 | + if (null !== $not_found_route) { |
|
| 121 | 121 | Request::getInstance()->redirect($this->getRoute($not_found_route, true)); |
| 122 | - } else { |
|
| 122 | + }else { |
|
| 123 | 123 | return $template->render('error.html.twig', array( |
| 124 | 124 | 'exception' => $e, |
| 125 | 125 | 'trace' => $e->getTraceAsString(), |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | try { |
| 171 | 171 | //Search action and execute |
| 172 | 172 | $this->searchAction($route); |
| 173 | - } catch (AccessDeniedException $e) { |
|
| 174 | - Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
| 173 | + }catch (AccessDeniedException $e) { |
|
| 174 | + Logger::log(_('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
| 175 | 175 | return Admin::staticAdminLogon($route); |
| 176 | - } catch (RouterException $r) { |
|
| 176 | + }catch (RouterException $r) { |
|
| 177 | 177 | Logger::log($r->getMessage(), LOG_WARNING); |
| 178 | - } catch (\Exception $e) { |
|
| 178 | + }catch (\Exception $e) { |
|
| 179 | 179 | Logger::log($e->getMessage(), LOG_ERR); |
| 180 | 180 | throw $e; |
| 181 | 181 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | protected function searchAction($route) |
| 194 | 194 | { |
| 195 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
| 195 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
| 196 | 196 | //Revisamos si tenemos la ruta registrada |
| 197 | 197 | $parts = parse_url($route); |
| 198 | 198 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -207,12 +207,12 @@ discard block |
||
| 207 | 207 | /** @var $class \PSFS\base\types\Controller */ |
| 208 | 208 | $class = RouterHelper::getClassToCall($action); |
| 209 | 209 | try { |
| 210 | - if($this->checkRequirements($action, $get)) { |
|
| 210 | + if ($this->checkRequirements($action, $get)) { |
|
| 211 | 211 | $this->executeCachedRoute($route, $action, $class, $get); |
| 212 | - } else { |
|
| 212 | + }else { |
|
| 213 | 213 | throw new RouterException(_('La ruta no es válida'), 400); |
| 214 | 214 | } |
| 215 | - } catch (\Exception $e) { |
|
| 215 | + }catch (\Exception $e) { |
|
| 216 | 216 | Logger::log($e->getMessage(), LOG_ERR); |
| 217 | 217 | throw $e; |
| 218 | 218 | } |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | * @return bool |
| 228 | 228 | */ |
| 229 | 229 | private function checkRequirements(array $action, $params = []) { |
| 230 | - if(!empty($params) && !empty($action['requirements'])) { |
|
| 230 | + if (!empty($params) && !empty($action['requirements'])) { |
|
| 231 | 231 | $checked = 0; |
| 232 | - foreach(array_keys($params) as $key) { |
|
| 233 | - if(in_array($key, $action['requirements'], true)) { |
|
| 232 | + foreach (array_keys($params) as $key) { |
|
| 233 | + if (in_array($key, $action['requirements'], true)) { |
|
| 234 | 234 | $checked++; |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | $valid = count($action['requirements']) === $checked; |
| 238 | - } else { |
|
| 238 | + }else { |
|
| 239 | 239 | $valid = true; |
| 240 | 240 | } |
| 241 | 241 | return $valid; |
@@ -285,14 +285,14 @@ discard block |
||
| 285 | 285 | $this->checkExternalModules(); |
| 286 | 286 | if (file_exists($modulesPath)) { |
| 287 | 287 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
| 288 | - if($modules->hasResults()) { |
|
| 288 | + if ($modules->hasResults()) { |
|
| 289 | 289 | foreach ($modules->getIterator() as $modulePath) { |
| 290 | 290 | $module = $modulePath->getBasename(); |
| 291 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
| 291 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 295 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $home_params = NULL; |
| 309 | 309 | foreach ($this->routing as $pattern => $params) { |
| 310 | 310 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
| 311 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
| 311 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
| 312 | 312 | $home_params = $params; |
| 313 | 313 | } |
| 314 | 314 | } |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | private function inspectDir($origen, $namespace = 'PSFS', $routing = []) |
| 330 | 330 | { |
| 331 | 331 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name('*.php'); |
| 332 | - if($files->hasResults()) { |
|
| 332 | + if ($files->hasResults()) { |
|
| 333 | 333 | foreach ($files->getIterator() as $file) { |
| 334 | - if(method_exists($file, 'getRelativePathname') && $namespace !== 'PSFS') { |
|
| 335 | - $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
| 336 | - } else { |
|
| 334 | + if (method_exists($file, 'getRelativePathname') && $namespace !== 'PSFS') { |
|
| 335 | + $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
| 336 | + }else { |
|
| 337 | 337 | $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname())); |
| 338 | 338 | } |
| 339 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
| 339 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | $this->finder = new Finder(); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | private function addRouting($namespace, &$routing, $module = 'PSFS') |
| 366 | 366 | { |
| 367 | 367 | if (self::exists($namespace)) { |
| 368 | - if(I18nHelper::checkI18Class($namespace)) { |
|
| 368 | + if (I18nHelper::checkI18Class($namespace)) { |
|
| 369 | 369 | return $routing; |
| 370 | 370 | } |
| 371 | 371 | $reflection = new \ReflectionClass($namespace); |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | if (!$this->domains) { |
| 408 | 408 | $this->domains = []; |
| 409 | 409 | } |
| 410 | - $domain = '@' . $class->getConstant('DOMAIN') . '/'; |
|
| 410 | + $domain = '@'.$class->getConstant('DOMAIN').'/'; |
|
| 411 | 411 | if (!array_key_exists($domain, $this->domains)) { |
| 412 | 412 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
| 413 | 413 | } |
@@ -423,11 +423,11 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | public function simpatize() |
| 425 | 425 | { |
| 426 | - $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php'; |
|
| 427 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
| 426 | + $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php'; |
|
| 427 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
| 428 | 428 | $this->generateSlugs($absoluteTranslationFileName); |
| 429 | 429 | GeneratorHelper::createDir(CONFIG_DIR); |
| 430 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 430 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 431 | 431 | |
| 432 | 432 | return $this; |
| 433 | 433 | } |
@@ -443,18 +443,18 @@ discard block |
||
| 443 | 443 | public function getRoute($slug = '', $absolute = FALSE, array $params = []) |
| 444 | 444 | { |
| 445 | 445 | if ('' === $slug) { |
| 446 | - return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
| 446 | + return $absolute ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
| 447 | 447 | } |
| 448 | 448 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
| 449 | 449 | throw new RouterException(_('No existe la ruta especificada')); |
| 450 | 450 | } |
| 451 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
| 451 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
| 452 | 452 | if (!empty($params)) { |
| 453 | 453 | foreach ($params as $key => $value) { |
| 454 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
| 454 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
| 455 | 455 | } |
| 456 | 456 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
| 457 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
| 457 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -491,15 +491,15 @@ discard block |
||
| 491 | 491 | * @param string $method |
| 492 | 492 | */ |
| 493 | 493 | private function checkPreActions($class, $method) { |
| 494 | - $preAction = 'pre' . ucfirst($method); |
|
| 495 | - if(method_exists($class, $preAction)) { |
|
| 494 | + $preAction = 'pre'.ucfirst($method); |
|
| 495 | + if (method_exists($class, $preAction)) { |
|
| 496 | 496 | Logger::log(_('Pre action invoked')); |
| 497 | 497 | try { |
| 498 | - if(false === call_user_func_array([$class, $preAction])) { |
|
| 498 | + if (false === call_user_func_array([$class, $preAction])) { |
|
| 499 | 499 | Logger::log(_('Pre action failed'), LOG_ERR, [error_get_last()]); |
| 500 | 500 | error_clear_last(); |
| 501 | 501 | } |
| 502 | - } catch (\Exception $e) { |
|
| 502 | + }catch (\Exception $e) { |
|
| 503 | 503 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
| 504 | 504 | } |
| 505 | 505 | } |
@@ -515,16 +515,16 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
| 517 | 517 | { |
| 518 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
| 518 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
| 519 | 519 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
| 520 | 520 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
| 521 | 521 | $cache = Cache::needCache(); |
| 522 | 522 | $execute = TRUE; |
| 523 | 523 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
| 524 | 524 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
| 525 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
| 525 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
| 526 | 526 | if (NULL !== $cachedData) { |
| 527 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
| 527 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
| 528 | 528 | Template::getInstance()->renderCache($cachedData, $headers); |
| 529 | 529 | $execute = FALSE; |
| 530 | 530 | } |
@@ -567,11 +567,11 @@ discard block |
||
| 567 | 567 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath) |
| 568 | 568 | { |
| 569 | 569 | $extModule = $modulePath->getBasename(); |
| 570 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
| 571 | - if(file_exists($moduleAutoloader)) { |
|
| 570 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
| 571 | + if (file_exists($moduleAutoloader)) { |
|
| 572 | 572 | include_once $moduleAutoloader; |
| 573 | 573 | if ($hydrateRoute) { |
| 574 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
| 574 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
| 575 | 575 | } |
| 576 | 576 | } |
| 577 | 577 | } |
@@ -585,16 +585,16 @@ discard block |
||
| 585 | 585 | { |
| 586 | 586 | try { |
| 587 | 587 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
| 588 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
| 589 | - if(file_exists($externalModulePath)) { |
|
| 588 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
| 589 | + if (file_exists($externalModulePath)) { |
|
| 590 | 590 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
| 591 | - if($externalModule->hasResults()) { |
|
| 591 | + if ($externalModule->hasResults()) { |
|
| 592 | 592 | foreach ($externalModule->getIterator() as $modulePath) { |
| 593 | 593 | $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath); |
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | - } catch (\Exception $e) { |
|
| 597 | + }catch (\Exception $e) { |
|
| 598 | 598 | Logger::log($e->getMessage(), LOG_WARNING); |
| 599 | 599 | $module = null; |
| 600 | 600 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function __construct() |
| 24 | 24 | { |
| 25 | - Logger::log(static::class . ' constructor invoked'); |
|
| 25 | + Logger::log(static::class.' constructor invoked'); |
|
| 26 | 26 | $this->init(); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | $calledClass = static::class; |
| 82 | 82 | try { |
| 83 | 83 | $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
| 84 | - $setter = 'set' . ucfirst($variable); |
|
| 84 | + $setter = 'set'.ucfirst($variable); |
|
| 85 | 85 | if (method_exists($calledClass, $setter)) { |
| 86 | 86 | $this->$setter($instance); |
| 87 | - } else { |
|
| 87 | + }else { |
|
| 88 | 88 | $this->$variable = $instance; |
| 89 | 89 | } |
| 90 | - } catch (\Exception $e) { |
|
| 91 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
| 90 | + }catch (\Exception $e) { |
|
| 91 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
| 92 | 92 | throw $e; |
| 93 | 93 | } |
| 94 | 94 | return $this; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | { |
| 104 | 104 | if (!$this->isLoaded()) { |
| 105 | 105 | $filename = sha1(get_class($this)); |
| 106 | - $cacheFilename = 'reflections' . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . ".json"; |
|
| 106 | + $cacheFilename = 'reflections'.DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.".json"; |
|
| 107 | 107 | /** @var \PSFS\base\Cache $cacheService */ |
| 108 | 108 | $cacheService = Cache::getInstance(); |
| 109 | 109 | /** @var \PSFS\base\config\Config $configService */ |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | $this->setLoaded(); |
| 124 | - } else { |
|
| 125 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
| 124 | + }else { |
|
| 125 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | public static function getClassToCall(array $action) |
| 20 | 20 | { |
| 21 | 21 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
| 22 | - $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class']; |
|
| 22 | + $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class']; |
|
| 23 | 23 | $reflectionClass = new \ReflectionClass($actionClass); |
| 24 | - if($reflectionClass->hasMethod('getInstance')) { |
|
| 24 | + if ($reflectionClass->hasMethod('getInstance')) { |
|
| 25 | 25 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
| 26 | - } else { |
|
| 26 | + }else { |
|
| 27 | 27 | $class = new $actionClass; |
| 28 | 28 | } |
| 29 | 29 | return $class; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $expr = preg_quote($expr, '/'); |
| 111 | 111 | $expr = str_replace('###', '(.*)', $expr); |
| 112 | 112 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
| 113 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
| 113 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
| 114 | 114 | return $matched; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
| 123 | 123 | { |
| 124 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
| 125 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
| 124 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
| 125 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
| 126 | 126 | $tpl_path = "templates"; |
| 127 | 127 | $public_path = "public"; |
| 128 | 128 | $model_path = "models"; |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | $model_path = ucfirst($model_path); |
| 133 | 133 | } |
| 134 | 134 | if ($class->hasConstant("TPL")) { |
| 135 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
| 135 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
| 136 | 136 | } |
| 137 | 137 | return [ |
| 138 | 138 | 'base' => $path, |
| 139 | - 'template' => $path . $tpl_path, |
|
| 140 | - 'model' => $path . $model_path, |
|
| 141 | - 'public' => $path . $public_path, |
|
| 139 | + 'template' => $path.$tpl_path, |
|
| 140 | + 'model' => $path.$model_path, |
|
| 141 | + 'public' => $path.$public_path, |
|
| 142 | 142 | ]; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | foreach ($parameters as $param) { |
| 163 | 163 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
| 164 | 164 | $params[$param->getName()] = $param->getDefaultValue(); |
| 165 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
| 166 | - } elseif(!$param->isOptional()) { |
|
| 165 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
| 166 | + } elseif (!$param->isOptional()) { |
|
| 167 | 167 | $requirements[] = $param->getName(); |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | - } else { |
|
| 170 | + }else { |
|
| 171 | 171 | $default = $regex; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $default = str_replace('{__DOMAIN__}', $module, $default); |
| 250 | 250 | $httpMethod = self::extractReflectionHttpMethod($docComments); |
| 251 | 251 | $label = self::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
| 252 | - $route = $httpMethod . "#|#" . $regex; |
|
| 252 | + $route = $httpMethod."#|#".$regex; |
|
| 253 | 253 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
| 254 | 254 | $info = [ |
| 255 | 255 | 'method' => $method->getName(), |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $locale = Request::header('X-API-LANG', $default); |
| 29 | 29 | if (empty($locale)) { |
| 30 | 30 | $locale = Security::getInstance()->getSessionKey(self::PSFS_SESSION_LANGUAGE_KEY); |
| 31 | - if(empty($locale) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) { |
|
| 31 | + if (empty($locale) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) { |
|
| 32 | 32 | $BrowserLocales = explode(",", str_replace("-", "_", $_SERVER["HTTP_ACCEPT_LANGUAGE"])); // brosers use en-US, Linux uses en_US |
| 33 | 33 | for ($i = 0, $ct = count($BrowserLocales); $i < $ct; $i++) { |
| 34 | 34 | list($BrowserLocales[$i]) = explode(";", $BrowserLocales[$i]); //trick for "en;q=0.8" |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | // TODO check more en locales |
| 45 | 45 | if (strtolower($locale) === 'en') { |
| 46 | 46 | $locale = 'en_GB'; |
| 47 | - } else { |
|
| 48 | - $locale = $locale . '_' . strtoupper($locale); |
|
| 47 | + }else { |
|
| 48 | + $locale = $locale.'_'.strtoupper($locale); |
|
| 49 | 49 | } |
| 50 | 50 | $default_locales = explode(',', Config::getParam('i18n.locales', '')); |
| 51 | 51 | if (!in_array($locale, array_merge($default_locales, self::$langs))) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $translations = array(); |
| 67 | 67 | if (file_exists($absoluteTranslationFileName)) { |
| 68 | 68 | @include($absoluteTranslationFileName); |
| 69 | - } else { |
|
| 69 | + }else { |
|
| 70 | 70 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | public static function setLocale($default = 'es_ES') |
| 82 | 82 | { |
| 83 | 83 | $locale = self::extractLocale($default); |
| 84 | - Logger::log('Set locale to project [' . $locale . ']'); |
|
| 84 | + Logger::log('Set locale to project ['.$locale.']'); |
|
| 85 | 85 | // Load translations |
| 86 | - putenv("LC_ALL=" . $locale); |
|
| 86 | + putenv("LC_ALL=".$locale); |
|
| 87 | 87 | setlocale(LC_ALL, $locale); |
| 88 | 88 | // Load the locale path |
| 89 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
| 90 | - Logger::log('Set locale dir ' . $locale_path); |
|
| 89 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
| 90 | + Logger::log('Set locale dir '.$locale_path); |
|
| 91 | 91 | GeneratorHelper::createDir($locale_path); |
| 92 | 92 | bindtextdomain('translations', $locale_path); |
| 93 | 93 | textdomain('translations'); |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public static function checkI18Class($namespace) { |
| 125 | 125 | $isI18n = false; |
| 126 | - if(preg_match('/I18n$/i', $namespace)) { |
|
| 126 | + if (preg_match('/I18n$/i', $namespace)) { |
|
| 127 | 127 | $parentClass = preg_replace('/I18n$/i', '', $namespace); |
| 128 | - if(Router::exists($parentClass)) { |
|
| 128 | + if (Router::exists($parentClass)) { |
|
| 129 | 129 | $isI18n = true; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'], |
| 152 | 152 | ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'], |
| 153 | 153 | ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'], |
| 154 | - ['n', 'N', 'c', 'C',], |
|
| 154 | + ['n', 'N', 'c', 'C', ], |
|
| 155 | 155 | ]; |
| 156 | 156 | |
| 157 | 157 | $text = filter_var($string, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); |
| 158 | - for($i = 0, $total = count($from); $i < $total; $i++) { |
|
| 159 | - $text = str_replace($from[$i],$to[$i], $text); |
|
| 158 | + for ($i = 0, $total = count($from); $i < $total; $i++) { |
|
| 159 | + $text = str_replace($from[$i], $to[$i], $text); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | return $text; |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | public static function dropInstance() { |
| 42 | 42 | $class = static::class; |
| 43 | - if(isset(self::$instance[$class])) { |
|
| 43 | + if (isset(self::$instance[$class])) { |
|
| 44 | 44 | self::$instance[$class] = null; |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | protected function hydrateBulkRequest() { |
| 97 | 97 | $class = new \ReflectionClass($this->getModelNamespace()); |
| 98 | 98 | $this->list = []; |
| 99 | - foreach($this->data as $item) { |
|
| 100 | - if(is_array($item)) { |
|
| 101 | - if(count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
| 99 | + foreach ($this->data as $item) { |
|
| 100 | + if (is_array($item)) { |
|
| 101 | + if (count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
| 102 | 102 | /** @var ActiveRecordInterface $model */ |
| 103 | 103 | $model = $class->newInstance(); |
| 104 | 104 | $this->hydrateModelFromRequest($model, $item); |
| 105 | 105 | $this->list[] = $model; |
| 106 | - } else { |
|
| 107 | - Logger::log(_('Max items per bulk insert raised'), LOG_WARNING, count($this->data) . _('items')); |
|
| 106 | + }else { |
|
| 107 | + Logger::log(_('Max items per bulk insert raised'), LOG_WARNING, count($this->data)._('items')); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | protected function saveBulk() { |
| 117 | 117 | $tablemap = $this->getTableMap(); |
| 118 | - foreach($this->list as &$model) { |
|
| 118 | + foreach ($this->list as &$model) { |
|
| 119 | 119 | $con = Propel::getWriteConnection($tablemap::DATABASE_NAME); |
| 120 | 120 | try { |
| 121 | 121 | $model->save($con); |
| 122 | 122 | $con->commit(); |
| 123 | - } catch(\Exception $e) { |
|
| 123 | + }catch (\Exception $e) { |
|
| 124 | 124 | Logger::log($e->getMessage(), LOG_ERR, $model->toArray()); |
| 125 | 125 | $con->rollBack(); |
| 126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | protected function exportList() { |
| 134 | 134 | $list = []; |
| 135 | 135 | /** @var ActiveRecordInterface $item */ |
| 136 | - foreach($this->list as $item) { |
|
| 136 | + foreach ($this->list as $item) { |
|
| 137 | 137 | $list[] = $item->toArray(); |
| 138 | 138 | } |
| 139 | 139 | return $list; |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function findPk(ModelCriteria $query, $pk) { |
| 159 | 159 | $pks = explode(Api::API_PK_SEPARATOR, urldecode($pk)); |
| 160 | - if(count($pks) === 1 && !empty($pks[0])) { |
|
| 160 | + if (count($pks) === 1 && !empty($pks[0])) { |
|
| 161 | 161 | $query->filterByPrimaryKey($pks[0]); |
| 162 | - } else { |
|
| 162 | + }else { |
|
| 163 | 163 | $i = 0; |
| 164 | - foreach($this->getPkDbName() as $key => $phpName) { |
|
| 164 | + foreach ($this->getPkDbName() as $key => $phpName) { |
|
| 165 | 165 | try { |
| 166 | 166 | $query->filterBy($phpName, $pks[$i]); |
| 167 | 167 | $i++; |
| 168 | - if($i >= count($pks)) break; |
|
| 169 | - } catch(\Exception $e) { |
|
| 168 | + if ($i >= count($pks)) break; |
|
| 169 | + }catch (\Exception $e) { |
|
| 170 | 170 | Logger::log($e->getMessage(), LOG_DEBUG); |
| 171 | 171 | } |
| 172 | 172 | } |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | try { |
| 197 | 197 | $query = $this->prepareQuery(); |
| 198 | 198 | $this->model = $this->findPk($query, $pk); |
| 199 | - } catch (\Exception $e) { |
|
| 200 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 199 | + }catch (\Exception $e) { |
|
| 200 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |