@@ -1,13 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace PSFS\base\types; |
3 | 3 | |
4 | -use CORE\Models\Customer; |
|
5 | 4 | use CORE\Models\Map\CustomerTableMap; |
6 | 5 | use Propel\Runtime\ActiveQuery\ModelCriteria; |
7 | -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; |
|
8 | -use Propel\Runtime\DataFetcher\ArrayDataFetcher; |
|
9 | -use Propel\Runtime\Formatter\ObjectFormatter; |
|
10 | -use Propel\Runtime\Map\ColumnMap; |
|
11 | 6 | use Propel\Runtime\Map\TableMap; |
12 | 7 | use Propel\Runtime\Propel; |
13 | 8 | use Propel\Runtime\Util\PropelModelPager; |
@@ -16,10 +11,8 @@ discard block |
||
16 | 11 | use PSFS\base\dto\Order; |
17 | 12 | use PSFS\base\Logger; |
18 | 13 | use PSFS\base\Request; |
19 | -use PSFS\base\Security; |
|
20 | 14 | use PSFS\base\Singleton; |
21 | 15 | use PSFS\base\types\helpers\ApiHelper; |
22 | -use PSFS\base\types\helpers\Inspector; |
|
23 | 16 | use PSFS\base\types\traits\Api\ManagerTrait; |
24 | 17 | |
25 | 18 | /** |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | public function init() |
82 | 82 | { |
83 | 83 | parent::init(); |
84 | - Logger::log(get_called_class() . ' init', LOG_DEBUG); |
|
84 | + Logger::log(get_called_class().' init', LOG_DEBUG); |
|
85 | 85 | $this->domain = $this->getDomain(); |
86 | 86 | $this->hydrateRequestData(); |
87 | 87 | $this->hydrateOrders(); |
88 | - if($this instanceof CustomApi === false) { |
|
88 | + if ($this instanceof CustomApi === false) { |
|
89 | 89 | $this->createConnection($this->getTableMap()); |
90 | 90 | } |
91 | 91 | $this->setLoaded(true); |
92 | - Logger::log(get_called_class() . ' loaded', LOG_DEBUG); |
|
92 | + Logger::log(get_called_class().' loaded', LOG_DEBUG); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | protected function hydrateOrders() |
99 | 99 | { |
100 | 100 | if (count($this->query)) { |
101 | - Logger::log(get_called_class() . ' gathering query string', LOG_DEBUG); |
|
101 | + Logger::log(get_called_class().' gathering query string', LOG_DEBUG); |
|
102 | 102 | foreach ($this->query as $key => $value) { |
103 | 103 | if ($key === self::API_ORDER_FIELD && is_array($value)) { |
104 | 104 | foreach ($value as $field => $direction) { |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | */ |
116 | 116 | protected function extractPagination() |
117 | 117 | { |
118 | - Logger::log(get_called_class() . ' extract pagination start', LOG_DEBUG); |
|
118 | + Logger::log(get_called_class().' extract pagination start', LOG_DEBUG); |
|
119 | 119 | $page = (array_key_exists(self::API_PAGE_FIELD, $this->query)) ? $this->query[self::API_PAGE_FIELD] : 1; |
120 | 120 | $limit = (array_key_exists(self::API_LIMIT_FIELD, $this->query)) ? $this->query[self::API_LIMIT_FIELD] : 100; |
121 | - Logger::log(get_called_class() . ' extract pagination end', LOG_DEBUG); |
|
121 | + Logger::log(get_called_class().' extract pagination end', LOG_DEBUG); |
|
122 | 122 | return array($page, $limit); |
123 | 123 | } |
124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | private function addOrders(ModelCriteria &$query) |
131 | 131 | { |
132 | - Logger::log(get_called_class() . ' extract orders start ', LOG_DEBUG); |
|
132 | + Logger::log(get_called_class().' extract orders start ', LOG_DEBUG); |
|
133 | 133 | $orderAdded = FALSE; |
134 | 134 | $tableMap = $this->getTableMap(); |
135 | 135 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -137,17 +137,17 @@ discard block |
||
137 | 137 | $orderAdded = TRUE; |
138 | 138 | if ($direction === Order::ASC) { |
139 | 139 | $query->addAscendingOrderByColumn($column->getPhpName()); |
140 | - } else { |
|
140 | + }else { |
|
141 | 141 | $query->addDescendingOrderByColumn($column->getPhpName()); |
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
145 | 145 | if (!$orderAdded) { |
146 | - foreach($this->getPkDbName() as $pk => $phpName) { |
|
146 | + foreach ($this->getPkDbName() as $pk => $phpName) { |
|
147 | 147 | $query->addAscendingOrderByColumn($pk); |
148 | 148 | } |
149 | 149 | } |
150 | - Logger::log(get_called_class() . ' extract orders end', LOG_DEBUG); |
|
150 | + Logger::log(get_called_class().' extract orders end', LOG_DEBUG); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | foreach ($this->query as $field => $value) { |
163 | 163 | if (self::API_COMBO_FIELD === $field) { |
164 | 164 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
165 | - } elseif(!preg_match('/^__/', $field)) { |
|
165 | + } elseif (!preg_match('/^__/', $field)) { |
|
166 | 166 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
167 | 167 | } |
168 | 168 | } |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | list($page, $limit) = $this->extractPagination(); |
184 | 184 | if ($limit == -1) { |
185 | 185 | $this->list = $query->find($this->con); |
186 | - } else { |
|
186 | + }else { |
|
187 | 187 | $this->list = $query->paginate($page, $limit, $this->con); |
188 | 188 | } |
189 | - } catch (\Exception $e) { |
|
189 | + }catch (\Exception $e) { |
|
190 | 190 | Logger::log($e->getMessage(), LOG_ERR); |
191 | 191 | } |
192 | 192 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $code = 200; |
206 | 206 | list($return, $total, $pages) = $this->getList(); |
207 | 207 | $message = null; |
208 | - if(!$total) { |
|
208 | + if (!$total) { |
|
209 | 209 | $message = _('No se han encontrado elementos para la búsqueda'); |
210 | 210 | } |
211 | 211 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $pages = 1; |
232 | 232 | $message = null; |
233 | 233 | list($code, $return) = $this->getSingleResult($pk); |
234 | - if($code !== 200) { |
|
234 | + if ($code !== 200) { |
|
235 | 235 | $message = _('No se ha encontrado el elemento solicitado'); |
236 | 236 | } |
237 | 237 | |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | $status = 200; |
261 | 261 | $saved = TRUE; |
262 | 262 | $model = $this->model->toArray(); |
263 | - } else { |
|
263 | + }else { |
|
264 | 264 | $message = _('No se ha podido guardar el modelo seleccionado'); |
265 | 265 | } |
266 | - } catch (\Exception $e) { |
|
267 | - $message = _('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage(); |
|
266 | + }catch (\Exception $e) { |
|
267 | + $message = _('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
268 | 268 | Logger::log($e->getMessage(), LOG_ERR); |
269 | 269 | } |
270 | 270 | |
@@ -298,14 +298,14 @@ discard block |
||
298 | 298 | $updated = TRUE; |
299 | 299 | $status = 200; |
300 | 300 | $model = $this->model->toArray(); |
301 | - } else { |
|
301 | + }else { |
|
302 | 302 | $message = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
303 | 303 | } |
304 | - } catch (\Exception $e) { |
|
304 | + }catch (\Exception $e) { |
|
305 | 305 | $message = $e->getMessage(); |
306 | 306 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
307 | 307 | } |
308 | - } else { |
|
308 | + }else { |
|
309 | 309 | $message = _('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
310 | 310 | } |
311 | 311 | |
@@ -333,13 +333,13 @@ discard block |
||
333 | 333 | $this->con->beginTransaction(); |
334 | 334 | $this->hydrateModel($pk); |
335 | 335 | if (NULL !== $this->model) { |
336 | - if(method_exists('clearAllReferences', $this->model)) { |
|
336 | + if (method_exists('clearAllReferences', $this->model)) { |
|
337 | 337 | $this->model->clearAllReferences(true); |
338 | 338 | } |
339 | 339 | $this->model->delete($this->con); |
340 | 340 | $deleted = TRUE; |
341 | 341 | } |
342 | - } catch (\Exception $e) { |
|
342 | + }catch (\Exception $e) { |
|
343 | 343 | $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados'); |
344 | 344 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
345 | 345 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $this->saveBulk(); |
368 | 368 | $saved = true; |
369 | 369 | $status = 200; |
370 | - } catch(\Exception $e) { |
|
370 | + }catch (\Exception $e) { |
|
371 | 371 | Logger::log($e->getMessage(), LOG_ERR, $this->getRequest()->getData()); |
372 | 372 | $message = _('Bulk insert rolled back'); |
373 | 373 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | |
390 | 390 | /** @var CustomerTableMap $tableMap */ |
391 | 391 | $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap()); |
392 | - foreach($this->list->getData() as $data) { |
|
392 | + foreach ($this->list->getData() as $data) { |
|
393 | 393 | $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data); |
394 | 394 | } |
395 | 395 | return $return; |
@@ -406,20 +406,20 @@ discard block |
||
406 | 406 | try { |
407 | 407 | $this->paginate(); |
408 | 408 | if (null !== $this->list) { |
409 | - if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
409 | + if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
410 | 410 | $return = $this->extractDataWithFormat(); |
411 | - } else { |
|
411 | + }else { |
|
412 | 412 | $return = $this->list->toArray(null, false, TableMap::TYPE_PHPNAME, false); |
413 | 413 | } |
414 | 414 | $total = 0; |
415 | 415 | $pages = 0; |
416 | - if($this->list instanceof PropelModelPager) { |
|
416 | + if ($this->list instanceof PropelModelPager) { |
|
417 | 417 | $total = $this->list->getNbResults(); |
418 | 418 | $pages = $this->list->getLastPage(); |
419 | 419 | } |
420 | 420 | } |
421 | - } catch (\Exception $e) { |
|
422 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
421 | + }catch (\Exception $e) { |
|
422 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | return array($return, $total, $pages); |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | $return = array(); |
438 | 438 | if (NULL === $model || !method_exists($model, 'toArray')) { |
439 | 439 | $code = 404; |
440 | - } else { |
|
440 | + }else { |
|
441 | 441 | $return = $model->toArray(); |
442 | 442 | } |
443 | 443 |
@@ -3,8 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use PSFS\base\config\Config; |
5 | 5 | use PSFS\base\Logger; |
6 | -use PSFS\base\Request; |
|
7 | -use PSFS\base\Router; |
|
8 | 6 | |
9 | 7 | /** |
10 | 8 | * Class SystemTrait |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $use /= 1024; |
38 | 38 | break; |
39 | 39 | case "MBytes": |
40 | - $use /= (1024 * 1024); |
|
40 | + $use /= (1024*1024); |
|
41 | 41 | break; |
42 | 42 | case "Bytes": |
43 | 43 | default: |
@@ -61,20 +61,20 @@ discard block |
||
61 | 61 | protected function bindWarningAsExceptions() |
62 | 62 | { |
63 | 63 | Logger::log('Added handlers for errors'); |
64 | - if(Config::getParam('debug')) { |
|
64 | + if (Config::getParam('debug')) { |
|
65 | 65 | Logger::log('Setting error_reporting as E_ALL'); |
66 | 66 | ini_set('error_reporting', E_ALL); |
67 | 67 | ini_set('display_errors', 1); |
68 | 68 | } |
69 | 69 | //Warning & Notice handler |
70 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
70 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
71 | 71 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]); |
72 | 72 | return true; |
73 | 73 | }, E_ALL | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED); |
74 | 74 | |
75 | - register_shutdown_function(function () { |
|
75 | + register_shutdown_function(function() { |
|
76 | 76 | $error = error_get_last(); |
77 | - if( $error !== NULL) { |
|
77 | + if ($error !== NULL) { |
|
78 | 78 | $errno = $error["type"]; |
79 | 79 | $errfile = $error["file"]; |
80 | 80 | $errline = $error["line"]; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | Logger::log('Initializing stats (mem + ts)'); |
95 | 95 | if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) { |
96 | 96 | $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT']; |
97 | - } else { |
|
97 | + }else { |
|
98 | 98 | $this->ts = PSFS_START_TS; |
99 | 99 | } |
100 | 100 | $this->mem = PSFS_START_MEM; |
@@ -6,20 +6,20 @@ discard block |
||
6 | 6 | |
7 | 7 | defined('SOURCE_DIR') or define('SOURCE_DIR', __DIR__); |
8 | 8 | if (preg_match('/vendor/', SOURCE_DIR)) { |
9 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
10 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
11 | -} else { |
|
12 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
13 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
9 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
10 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
11 | +}else { |
|
12 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
13 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
14 | 14 | } |
15 | -defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
16 | -defined('LOG_DIR') or define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
17 | -defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
18 | -defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
19 | -defined('WEB_DIR') or define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
20 | -defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
15 | +defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor'); |
|
16 | +defined('LOG_DIR') or define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
17 | +defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
18 | +defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
19 | +defined('WEB_DIR') or define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
20 | +defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
21 | 21 | |
22 | -if(!class_exists(bootstrap::class)) { |
|
22 | +if (!class_exists(bootstrap::class)) { |
|
23 | 23 | /** |
24 | 24 | * Class Bootstrap |
25 | 25 | * @package PSFS |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | class bootstrap { |
28 | 28 | protected static $loaded = false; |
29 | 29 | public static function load() { |
30 | - if(!self::$loaded) { |
|
30 | + if (!self::$loaded) { |
|
31 | 31 | defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true); |
32 | - if(class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
32 | + if (class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
33 | 33 | self::$loaded = true; |
34 | 34 | } |
35 | 35 | } |
@@ -29,7 +29,9 @@ |
||
29 | 29 | public static function load() { |
30 | 30 | if(!self::$loaded) { |
31 | 31 | defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true); |
32 | - if(class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
32 | + if(class_exists("\\PSFS\\base\\Logger")) { |
|
33 | + \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
34 | + } |
|
33 | 35 | self::$loaded = true; |
34 | 36 | } |
35 | 37 | } |
@@ -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); |
@@ -496,17 +496,17 @@ discard block |
||
496 | 496 | */ |
497 | 497 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
498 | 498 | { |
499 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
499 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
500 | 500 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
501 | 501 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
502 | 502 | $cache = Cache::needCache(); |
503 | 503 | $execute = TRUE; |
504 | 504 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
505 | 505 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
506 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, |
|
506 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, |
|
507 | 507 | $cache); |
508 | 508 | if (NULL !== $cachedData) { |
509 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', |
|
509 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', |
|
510 | 510 | $cache, null, Cache::JSON); |
511 | 511 | Template::getInstance()->renderCache($cachedData, $headers); |
512 | 512 | $execute = FALSE; |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath) |
550 | 550 | { |
551 | 551 | $extModule = $modulePath->getBasename(); |
552 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
553 | - if(file_exists($moduleAutoloader)) { |
|
552 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
553 | + if (file_exists($moduleAutoloader)) { |
|
554 | 554 | include_once $moduleAutoloader; |
555 | 555 | if ($hydrateRoute) { |
556 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
556 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | } |
@@ -567,16 +567,16 @@ discard block |
||
567 | 567 | { |
568 | 568 | try { |
569 | 569 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
570 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
571 | - if(file_exists($externalModulePath)) { |
|
570 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
571 | + if (file_exists($externalModulePath)) { |
|
572 | 572 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
573 | - if($externalModule->hasResults()) { |
|
573 | + if ($externalModule->hasResults()) { |
|
574 | 574 | foreach ($externalModule->getIterator() as $modulePath) { |
575 | 575 | $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath); |
576 | 576 | } |
577 | 577 | } |
578 | 578 | } |
579 | - } catch (\Exception $e) { |
|
579 | + }catch (\Exception $e) { |
|
580 | 580 | Logger::log($e->getMessage(), LOG_WARNING); |
581 | 581 | $module = null; |
582 | 582 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | if (!defined('LOG_DIR')) { |
18 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
19 | - define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
18 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
19 | + define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $config = Config::getInstance(); |
55 | 55 | $args = func_get_args(); |
56 | 56 | list($logger, $debug, $path) = $this->setup($config, $args); |
57 | - $this->stream = fopen($path . DIRECTORY_SEPARATOR . date('Ymd') . '.log', 'a+'); |
|
57 | + $this->stream = fopen($path.DIRECTORY_SEPARATOR.date('Ymd').'.log', 'a+'); |
|
58 | 58 | $this->addPushLogger($logger, $debug, $config); |
59 | 59 | $this->log_level = Config::getParam('log.level', 'info'); |
60 | 60 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | private function createLoggerPath(Config $config) |
198 | 198 | { |
199 | 199 | $logger = $this->setLoggerName($config); |
200 | - $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m'); |
|
200 | + $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m'); |
|
201 | 201 | GeneratorHelper::createDir($path); |
202 | 202 | |
203 | 203 | return $path; |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public static function log($msg, $type = LOG_DEBUG, array $context = null) |
212 | 212 | { |
213 | - if(null === $context) { |
|
213 | + if (null === $context) { |
|
214 | 214 | $context = []; |
215 | 215 | } |
216 | - if(Config::getParam('profiling.enable')) { |
|
216 | + if (Config::getParam('profiling.enable')) { |
|
217 | 217 | Inspector::stats($msg); |
218 | 218 | } |
219 | 219 | switch ($type) { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | { |
263 | 263 | $context['uri'] = null !== $_SERVER && array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : 'Unknow'; |
264 | 264 | $context['method'] = null !== $_SERVER && array_key_exists('REQUEST_METHOD', $_SERVER) ? $_SERVER['REQUEST_METHOD'] : 'Unknow'; |
265 | - if(null !== $_SERVER && array_key_exists('HTTP_X_PSFS_UID', $_SERVER)) { |
|
265 | + if (null !== $_SERVER && array_key_exists('HTTP_X_PSFS_UID', $_SERVER)) { |
|
266 | 266 | $context['uid'] = $_SERVER['HTTP_X_PSFS_UID']; |
267 | 267 | } |
268 | 268 | return $context; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | protected $isMultipart = false; |
70 | 70 | |
71 | 71 | private function closeConnection() { |
72 | - if(null !== $this->con) { |
|
72 | + if (null !== $this->con) { |
|
73 | 73 | curl_close($this->con); |
74 | 74 | } |
75 | 75 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function setIsJson($isJson = true) { |
234 | 234 | $this->isJson = $isJson; |
235 | - if($isJson) { |
|
235 | + if ($isJson) { |
|
236 | 236 | $this->setIsMultipart(false); |
237 | 237 | } |
238 | 238 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function setIsMultipart($isMultipart = true) { |
251 | 251 | $this->isMultipart = $isMultipart; |
252 | - if($isMultipart) { |
|
252 | + if ($isMultipart) { |
|
253 | 253 | $this->setIsJson(false); |
254 | 254 | } |
255 | 255 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $this->url = NULL; |
270 | 270 | $this->params = array(); |
271 | 271 | $this->headers = array(); |
272 | - Logger::log('Context service for ' . static::class . ' cleared!'); |
|
272 | + Logger::log('Context service for '.static::class.' cleared!'); |
|
273 | 273 | $this->closeConnection(); |
274 | 274 | } |
275 | 275 | |
@@ -312,18 +312,18 @@ discard block |
||
312 | 312 | } |
313 | 313 | |
314 | 314 | protected function applyOptions() { |
315 | - if(count($this->options)) { |
|
315 | + if (count($this->options)) { |
|
316 | 316 | curl_setopt_array($this->con, $this->options); |
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | 320 | protected function applyHeaders() { |
321 | 321 | $headers = []; |
322 | - foreach($this->headers as $key => $value) { |
|
323 | - $headers[] = $key . ': ' . $value; |
|
322 | + foreach ($this->headers as $key => $value) { |
|
323 | + $headers[] = $key.': '.$value; |
|
324 | 324 | } |
325 | 325 | $headers[self::PSFS_TRACK_HEADER] = Logger::getUid(); |
326 | - if(count($headers)) { |
|
326 | + if (count($headers)) { |
|
327 | 327 | curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers); |
328 | 328 | } |
329 | 329 | } |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | case Request::VERB_GET: |
335 | 335 | default: |
336 | 336 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_GET); |
337 | - if(!empty($this->params)) { |
|
337 | + if (!empty($this->params)) { |
|
338 | 338 | $sep = !preg_match('/\?/', $this->getUrl()) ? '?' : ''; |
339 | - $this->url = $this->url . $sep . http_build_query($this->params); |
|
339 | + $this->url = $this->url.$sep.http_build_query($this->params); |
|
340 | 340 | } |
341 | 341 | break; |
342 | 342 | case Request::VERB_POST: |
343 | 343 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_POST); |
344 | - if($this->getIsJson()) { |
|
344 | + if ($this->getIsJson()) { |
|
345 | 345 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
346 | - } elseif($this->getIsMultipart()) { |
|
346 | + } elseif ($this->getIsMultipart()) { |
|
347 | 347 | $this->addOption(CURLOPT_POSTFIELDS, $this->params); |
348 | - } else { |
|
348 | + }else { |
|
349 | 349 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
350 | 350 | } |
351 | 351 | break; |
@@ -355,21 +355,21 @@ discard block |
||
355 | 355 | case Request::VERB_PUT: |
356 | 356 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_PUT); |
357 | 357 | |
358 | - if($this->getIsJson()) { |
|
358 | + if ($this->getIsJson()) { |
|
359 | 359 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
360 | - } elseif($this->getIsMultipart()) { |
|
360 | + } elseif ($this->getIsMultipart()) { |
|
361 | 361 | $this->addOption(CURLOPT_POSTFIELDS, $this->params); |
362 | - } else { |
|
362 | + }else { |
|
363 | 363 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
364 | 364 | } |
365 | 365 | break; |
366 | 366 | case Request::VERB_PATCH: |
367 | 367 | $this->addOption(CURLOPT_CUSTOMREQUEST, Request::VERB_PATCH); |
368 | - if($this->getIsJson()) { |
|
368 | + if ($this->getIsJson()) { |
|
369 | 369 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
370 | - } elseif($this->getIsMultipart()) { |
|
370 | + } elseif ($this->getIsMultipart()) { |
|
371 | 371 | $this->addOption(CURLOPT_POSTFIELDS, $this->params); |
372 | - } else { |
|
372 | + }else { |
|
373 | 373 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
374 | 374 | } |
375 | 375 | break; |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | $this->setDefaults(); |
387 | 387 | $this->applyOptions(); |
388 | 388 | $this->applyHeaders(); |
389 | - if('debug' === Config::getParam('log.level')) { |
|
389 | + if ('debug' === Config::getParam('log.level')) { |
|
390 | 390 | curl_setopt($this->con, CURLOPT_VERBOSE, true); |
391 | 391 | $verbose = fopen('php://temp', 'w+'); |
392 | 392 | curl_setopt($this->con, CURLOPT_STDERR, $verbose); |
393 | 393 | } |
394 | 394 | $result = curl_exec($this->con); |
395 | 395 | $this->result = $this->isJson ? json_decode($result, true) : $result; |
396 | - if('debug' === Config::getParam('log.level')) { |
|
396 | + if ('debug' === Config::getParam('log.level')) { |
|
397 | 397 | rewind($verbose); |
398 | 398 | $verboseLog = stream_get_contents($verbose); |
399 | 399 | Logger::log($verboseLog, LOG_DEBUG, [ |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | ]); |
404 | 404 | $this->info['verbose'] = $verboseLog; |
405 | 405 | } |
406 | - Logger::log($this->url . ' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
406 | + Logger::log($this->url.' response: ', LOG_DEBUG, is_array($this->result) ? $this->result : [$this->result]); |
|
407 | 407 | $this->info = array_merge($this->info, curl_getinfo($this->con)); |
408 | 408 | } |
409 | 409 |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | $behaviors = $tableMap->getBehaviors(); |
36 | 36 | foreach ($map::getFieldNames() as $field) { |
37 | 37 | $fDto = self::parseFormField($domain, $tableMap, $field, $behaviors); |
38 | - if(null !== $fDto) { |
|
38 | + if (null !== $fDto) { |
|
39 | 39 | $form->addField($fDto); |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | - if(array_key_exists('i18n', $behaviors)) { |
|
44 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
45 | - if(null !== $relateI18n) { |
|
43 | + if (array_key_exists('i18n', $behaviors)) { |
|
44 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
45 | + if (null !== $relateI18n) { |
|
46 | 46 | $i18NTableMap = $relateI18n->getLocalTable(); |
47 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
48 | - if(!$form->fieldExists($columnMap->getPhpName())) { |
|
47 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
48 | + if (!$form->fieldExists($columnMap->getPhpName())) { |
|
49 | 49 | $fDto = self::parseFormField($domain, $i18NTableMap, $columnMap->getPhpName(), $i18NTableMap->getBehaviors()); |
50 | - if(null !== $fDto) { |
|
50 | + if (null !== $fDto) { |
|
51 | 51 | $fDto->pk = false; |
52 | 52 | $form->addField($fDto); |
53 | 53 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $fDto->entity = $relatedModel; |
77 | 77 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
78 | 78 | $fDto->relatedField = $relatedField->getPhpName(); |
79 | - $fDto->url = Router::getInstance()->getRoute(strtolower($domain) . '-api-' . $relatedModel); |
|
79 | + $fDto->url = Router::getInstance()->getRoute(strtolower($domain).'-api-'.$relatedModel); |
|
80 | 80 | return $fDto; |
81 | 81 | } |
82 | 82 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $column = null; |
185 | 185 | try { |
186 | 186 | $column = $tableMap->getColumnByPhpName($field); |
187 | - } catch (\Exception $e) { |
|
187 | + }catch (\Exception $e) { |
|
188 | 188 | Logger::log($e->getMessage(), LOG_DEBUG); |
189 | 189 | //foreach($tableMap->getRelations() as $relation) { |
190 | 190 | // $column = self::checkFieldExists($relation->getLocalTable(), $field); |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) |
202 | 202 | { |
203 | 203 | $tableField = $column->getFullyQualifiedName(); |
204 | - if(is_array($value)) { |
|
205 | - if(null !== $column->getValueSet()) { |
|
204 | + if (is_array($value)) { |
|
205 | + if (null !== $column->getValueSet()) { |
|
206 | 206 | $valueSet = $column->getValueSet(); |
207 | - if(in_array($value, $valueSet)) { |
|
207 | + if (in_array($value, $valueSet)) { |
|
208 | 208 | $value = array_search($value, $valueSet); |
209 | 209 | } |
210 | 210 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
215 | 215 | $text = preg_replace('/(\'|\")/', '', $value); |
216 | 216 | $text = preg_replace('/\ /', '%', $text); |
217 | - $query->add($tableField, '%' . $text . '%', Criteria::LIKE); |
|
217 | + $query->add($tableField, '%'.$text.'%', Criteria::LIKE); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -230,29 +230,29 @@ discard block |
||
230 | 230 | $sep = ''; |
231 | 231 | foreach ($tableMap->getColumns() as $column) { |
232 | 232 | if ($column->isText()) { |
233 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
233 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
234 | 234 | $sep = ', " ", '; |
235 | 235 | } |
236 | 236 | } |
237 | - foreach($tableMap->getRelations() as $relation) { |
|
238 | - if(preg_match('/I18n$/i', $relation->getName())) { |
|
237 | + foreach ($tableMap->getRelations() as $relation) { |
|
238 | + if (preg_match('/I18n$/i', $relation->getName())) { |
|
239 | 239 | $localeTableMap = $relation->getLocalTable(); |
240 | 240 | foreach ($localeTableMap->getColumns() as $column) { |
241 | 241 | if ($column->isText()) { |
242 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
242 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
243 | 243 | $sep = ', " ", '; |
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
248 | 248 | foreach ($extraColumns as $extra => $name) { |
249 | - $exp .= $sep . $extra; |
|
249 | + $exp .= $sep.$extra; |
|
250 | 250 | $sep = ', " ", '; |
251 | 251 | } |
252 | 252 | $exp .= ")"; |
253 | 253 | $text = preg_replace('/(\'|\")/', '', $value); |
254 | 254 | $text = preg_replace('/\ /', '%', $text); |
255 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
255 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public static function extractQuery($modelNameNamespace, ConnectionInterface $con = null) |
279 | 279 | { |
280 | - $queryReflector = new \ReflectionClass($modelNameNamespace . "Query"); |
|
280 | + $queryReflector = new \ReflectionClass($modelNameNamespace."Query"); |
|
281 | 281 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
282 | 282 | $query = $queryReflector->getMethod('create')->invoke($con); |
283 | 283 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } elseif ($mappedColumn->isText()) { |
307 | 307 | if ($mappedColumn->getSize() > 100) { |
308 | 308 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
309 | - } else { |
|
309 | + }else { |
|
310 | 310 | $fDto = self::generateStringField($field, $required); |
311 | 311 | } |
312 | 312 | } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public static function extractPrimaryKeyColumnName(TableMap $tableMap) { |
345 | 345 | $modelPk = null; |
346 | - foreach($tableMap->getPrimaryKeys() as $pk) { |
|
346 | + foreach ($tableMap->getPrimaryKeys() as $pk) { |
|
347 | 347 | $modelPk = $pk; |
348 | 348 | break; |
349 | 349 | } |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | |
353 | 353 | private static function mapResult(ActiveRecordInterface $model, array $data = []) { |
354 | 354 | $result = []; |
355 | - foreach($data as $key => $value) { |
|
355 | + foreach ($data as $key => $value) { |
|
356 | 356 | try { |
357 | 357 | $realValue = $model->getByName($key); |
358 | - } catch(\Exception $e) { |
|
358 | + }catch (\Exception $e) { |
|
359 | 359 | $realValue = $value; |
360 | 360 | } |
361 | - if(Api::API_MODEL_KEY_FIELD === $key) { |
|
361 | + if (Api::API_MODEL_KEY_FIELD === $key) { |
|
362 | 362 | $result[$key] = (integer)$realValue; |
363 | - } else { |
|
363 | + }else { |
|
364 | 364 | $result[$key] = $realValue; |
365 | 365 | } |
366 | 366 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | /** @var ActiveRecordInterface $obj */ |
377 | 377 | $obj = @$formatter->getAllObjectsFromRow($data); |
378 | 378 | $result = self::mapResult($obj, $data); |
379 | - if(!preg_match('/' . $modelPk->getPhpName() . '/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
379 | + if (!preg_match('/'.$modelPk->getPhpName().'/i', $query[Api::API_FIELDS_RESULT_FIELD])) { |
|
380 | 380 | unset($result[$modelPk->getPhpName()]); |
381 | 381 | } |
382 | 382 | return $result; |