@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | // autoloader |
15 | 15 | function PSFSAutoloader($class) |
16 | 16 | { |
17 | - Logger::log("Trying to load class {$class} with " . __FILE__); |
|
17 | + Logger::log("Trying to load class {$class} with ".__FILE__); |
|
18 | 18 | // it only autoload class into the Rain scope |
19 | 19 | if (str_contains($class, 'PSFS')) { |
20 | 20 | // Change order src |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
24 | 24 | |
25 | 25 | // filepath |
26 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
26 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
27 | 27 | |
28 | 28 | // require the file |
29 | 29 | if (file_exists($abs_path)) { |
30 | 30 | require_once $abs_path; |
31 | - } else { |
|
32 | - Logger::log("{$class} not loaded with " . __FILE__); |
|
31 | + }else { |
|
32 | + Logger::log("{$class} not loaded with ".__FILE__); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | return false; |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $now = new \DateTime(); |
19 | 19 | $now->setTimezone(new \DateTimeZone(Config::getParam('project.timezone', 'Europe/Madrid'))); |
20 | 20 | $config = Config::getInstance()->dumpConfig(); |
21 | - $config[self::CACHE_VAR_TAG] = 'v' . $now->format('Ymd.His'); |
|
21 | + $config[self::CACHE_VAR_TAG] = 'v'.$now->format('Ymd.His'); |
|
22 | 22 | Config::save($config); |
23 | 23 | return $config[self::CACHE_VAR_TAG]; |
24 | 24 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function __construct($hydrate = true) |
20 | 20 | { |
21 | 21 | parent::__construct(); |
22 | - if($hydrate) { |
|
22 | + if ($hydrate) { |
|
23 | 23 | $this->fromArray(Request::getInstance()->getData()); |
24 | 24 | } |
25 | 25 | } |
@@ -47,23 +47,23 @@ discard block |
||
47 | 47 | /** @var \ReflectionProperty $property */ |
48 | 48 | foreach ($properties as $property) { |
49 | 49 | $value = $property->getValue($this); |
50 | - if(is_object($value) && method_exists($value, 'toArray')) { |
|
50 | + if (is_object($value) && method_exists($value, 'toArray')) { |
|
51 | 51 | $dto[$property->getName()] = $value->toArray(); |
52 | - } elseif(is_array($value)) { |
|
53 | - foreach($value as &$arrValue) { |
|
54 | - if($arrValue instanceof Dto) { |
|
52 | + } elseif (is_array($value)) { |
|
53 | + foreach ($value as &$arrValue) { |
|
54 | + if ($arrValue instanceof Dto) { |
|
55 | 55 | $arrValue = $arrValue->toArray(); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | $dto[$property->getName()] = $value; |
59 | - } else { |
|
59 | + }else { |
|
60 | 60 | $type = InjectorHelper::extractVarType($property->getDocComment()); |
61 | 61 | $dto[$property->getName()] = $this->checkCastedValue($property->getValue($this), $type); |
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
65 | - } catch (\Exception $e) { |
|
66 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
65 | + }catch (\Exception $e) { |
|
66 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
67 | 67 | } |
68 | 68 | return $dto; |
69 | 69 | } |
@@ -86,26 +86,26 @@ discard block |
||
86 | 86 | protected function parseDtoField(array $properties, $key, $value = null) { |
87 | 87 | list($type, $isArray) = $this->extractTypes($properties, $key); |
88 | 88 | $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null; |
89 | - if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
90 | - if(null !== $value && is_array($value)) { |
|
91 | - if(!array_key_exists($type, $this->__cache)) { |
|
89 | + if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
90 | + if (null !== $value && is_array($value)) { |
|
91 | + if (!array_key_exists($type, $this->__cache)) { |
|
92 | 92 | $this->__cache[$type] = new $type(false); |
93 | 93 | } |
94 | - if($isArray) { |
|
94 | + if ($isArray) { |
|
95 | 95 | $this->$key = []; |
96 | - foreach($value as $data) { |
|
97 | - if(null !== $data && is_array($data)) { |
|
96 | + foreach ($value as $data) { |
|
97 | + if (null !== $data && is_array($data)) { |
|
98 | 98 | $dto = clone $this->__cache[$type]; |
99 | 99 | $dto->fromArray($data); |
100 | 100 | array_push($this->$key, $dto); |
101 | 101 | } |
102 | 102 | } |
103 | - } else { |
|
103 | + }else { |
|
104 | 104 | $this->$key = clone $this->__cache[$type]; |
105 | 105 | $this->$key->fromArray($value); |
106 | 106 | } |
107 | 107 | } |
108 | - } else { |
|
108 | + }else { |
|
109 | 109 | $this->castValue($key, $value, $type); |
110 | 110 | } |
111 | 111 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | /** |
133 | 133 | * @return mixed |
134 | 134 | */ |
135 | - public function jsonSerialize(): array|string|null |
|
135 | + public function jsonSerialize(): array | string | null |
|
136 | 136 | { |
137 | 137 | return $this->toArray(); |
138 | 138 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @return mixed |
173 | 173 | */ |
174 | 174 | protected function checkCastedValue($rawValue, $type) { |
175 | - if(null !== $rawValue) { |
|
175 | + if (null !== $rawValue) { |
|
176 | 176 | switch ($type) { |
177 | 177 | default: |
178 | 178 | case 'string': |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $value = (bool)$rawValue; |
192 | 192 | break; |
193 | 193 | } |
194 | - } else { |
|
194 | + }else { |
|
195 | 195 | $value = $rawValue; |
196 | 196 | } |
197 | 197 | return $value; |
@@ -56,20 +56,20 @@ discard block |
||
56 | 56 | public function init() |
57 | 57 | { |
58 | 58 | parent::init(); |
59 | - Logger::log(static::class . ' init', LOG_DEBUG); |
|
59 | + Logger::log(static::class.' init', LOG_DEBUG); |
|
60 | 60 | $this->domain = $this->getDomain(); |
61 | 61 | $this->hydrateRequestData(); |
62 | 62 | $this->hydrateOrders(); |
63 | - if($this instanceof CustomApi === false) { |
|
63 | + if ($this instanceof CustomApi === false) { |
|
64 | 64 | $this->createConnection($this->getTableMap()); |
65 | 65 | } |
66 | 66 | $this->checkFieldType(); |
67 | 67 | $this->setLoaded(true); |
68 | - Logger::log(static::class . ' loaded', LOG_DEBUG); |
|
68 | + Logger::log(static::class.' loaded', LOG_DEBUG); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | private function checkActions($method) { |
72 | - switch($method) { |
|
72 | + switch ($method) { |
|
73 | 73 | default: |
74 | 74 | case 'modelList': $this->action = self::API_ACTION_LIST; break; |
75 | 75 | case 'get': $this->action = self::API_ACTION_GET; break; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $code = 200; |
95 | 95 | list($return, $total, $pages) = $this->getList(); |
96 | 96 | $message = null; |
97 | - if(!$total) { |
|
97 | + if (!$total) { |
|
98 | 98 | $message = t('No se han encontrado elementos para la búsqueda'); |
99 | 99 | } |
100 | 100 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $pages = 1; |
120 | 120 | $message = null; |
121 | 121 | list($code, $return) = $this->getSingleResult($pk); |
122 | - if($code !== 200) { |
|
122 | + if ($code !== 200) { |
|
123 | 123 | $message = t('No se ha encontrado el elemento solicitado'); |
124 | 124 | } |
125 | 125 | |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | $status = 200; |
149 | 149 | $saved = TRUE; |
150 | 150 | $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
151 | - } else { |
|
151 | + }else { |
|
152 | 152 | $message = t('No se ha podido guardar el modelo seleccionado'); |
153 | 153 | } |
154 | - } catch (\Exception $e) { |
|
155 | - $message = t('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage(); |
|
154 | + }catch (\Exception $e) { |
|
155 | + $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
156 | 156 | $context = []; |
157 | - if(null !== $e->getPrevious()) { |
|
157 | + if (null !== $e->getPrevious()) { |
|
158 | 158 | $context[] = $e->getPrevious()->getMessage(); |
159 | 159 | } |
160 | 160 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | $updated = TRUE; |
191 | 191 | $status = 200; |
192 | 192 | $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
193 | - } else { |
|
193 | + }else { |
|
194 | 194 | $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
195 | 195 | } |
196 | - } catch (\Exception $e) { |
|
196 | + }catch (\Exception $e) { |
|
197 | 197 | $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
198 | 198 | $context = []; |
199 | - if(null !== $e->getPrevious()) { |
|
199 | + if (null !== $e->getPrevious()) { |
|
200 | 200 | $context[] = $e->getPrevious()->getMessage(); |
201 | 201 | } |
202 | 202 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
203 | 203 | } |
204 | - } else { |
|
204 | + }else { |
|
205 | 205 | $message = t('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
206 | 206 | } |
207 | 207 | |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | $this->con->beginTransaction(); |
230 | 230 | $this->hydrateModel($pk); |
231 | 231 | if (NULL !== $this->model) { |
232 | - if(method_exists('clearAllReferences', $this->model)) { |
|
232 | + if (method_exists('clearAllReferences', $this->model)) { |
|
233 | 233 | $this->model->clearAllReferences(true); |
234 | 234 | } |
235 | 235 | $this->model->delete($this->con); |
236 | 236 | $deleted = TRUE; |
237 | 237 | } |
238 | - } catch (\Exception $e) { |
|
238 | + }catch (\Exception $e) { |
|
239 | 239 | $context = []; |
240 | - if(null !== $e->getPrevious()) { |
|
240 | + if (null !== $e->getPrevious()) { |
|
241 | 241 | $context[] = $e->getPrevious()->getMessage(); |
242 | 242 | } |
243 | 243 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $this->saveBulk(); |
267 | 267 | $saved = true; |
268 | 268 | $status = 200; |
269 | - } catch(\Exception $e) { |
|
269 | + }catch (\Exception $e) { |
|
270 | 270 | Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData()); |
271 | 271 | $message = t('Bulk insert rolled back'); |
272 | 272 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | |
279 | 279 | /** @var CustomerTableMap $tableMap */ |
280 | 280 | $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap()); |
281 | - foreach($this->list->getData() as $data) { |
|
281 | + foreach ($this->list->getData() as $data) { |
|
282 | 282 | $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data); |
283 | 283 | } |
284 | 284 | return $return; |
@@ -295,23 +295,23 @@ discard block |
||
295 | 295 | try { |
296 | 296 | $this->paginate(); |
297 | 297 | if (null !== $this->list) { |
298 | - if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
298 | + if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
299 | 299 | $return = $this->extractDataWithFormat(); |
300 | - } else { |
|
300 | + }else { |
|
301 | 301 | $return = $this->list->toArray(null, false, $this->fieldType ?: TableMap::TYPE_PHPNAME, false); |
302 | 302 | } |
303 | 303 | $total = 0; |
304 | 304 | $pages = 0; |
305 | - if($this->list instanceof PropelModelPager) { |
|
305 | + if ($this->list instanceof PropelModelPager) { |
|
306 | 306 | $total = $this->list->getNbResults(); |
307 | 307 | $pages = $this->list->getLastPage(); |
308 | - } elseif($this->list instanceof ArrayCollection) { |
|
308 | + } elseif ($this->list instanceof ArrayCollection) { |
|
309 | 309 | $total = count($return); |
310 | 310 | $pages = 1; |
311 | 311 | } |
312 | 312 | } |
313 | - } catch (\Exception $e) { |
|
314 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
313 | + }catch (\Exception $e) { |
|
314 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | return array($return, $total, $pages); |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $return = array(); |
330 | 330 | if (NULL === $model || !method_exists($model, 'toArray')) { |
331 | 331 | $code = 404; |
332 | - } else { |
|
332 | + }else { |
|
333 | 333 | $return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
334 | 334 | } |
335 | 335 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | protected function hydrateOrders() |
38 | 38 | { |
39 | 39 | if (count($this->query)) { |
40 | - Logger::log(static::class . ' gathering query string', LOG_DEBUG); |
|
40 | + Logger::log(static::class.' gathering query string', LOG_DEBUG); |
|
41 | 41 | foreach ($this->query as $key => $value) { |
42 | 42 | if ($key === self::API_ORDER_FIELD) { |
43 | 43 | $orders = json_decode($value, true); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | */ |
56 | 56 | protected function extractPagination() |
57 | 57 | { |
58 | - Logger::log(static::class . ' extract pagination start', LOG_DEBUG); |
|
58 | + Logger::log(static::class.' extract pagination start', LOG_DEBUG); |
|
59 | 59 | $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1; |
60 | 60 | $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100; |
61 | - Logger::log(static::class . ' extract pagination end', LOG_DEBUG); |
|
61 | + Logger::log(static::class.' extract pagination end', LOG_DEBUG); |
|
62 | 62 | return array($page, (int)$limit); |
63 | 63 | } |
64 | 64 | |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @param ModelCriteria $query |
68 | 68 | * @throws \PSFS\base\exception\ApiException |
69 | 69 | */ |
70 | - protected function addOrders(ModelCriteria &$query) |
|
70 | + protected function addOrders(ModelCriteria & $query) |
|
71 | 71 | { |
72 | - Logger::log(static::class . ' extract orders start ', LOG_DEBUG); |
|
72 | + Logger::log(static::class.' extract orders start ', LOG_DEBUG); |
|
73 | 73 | $orderAdded = FALSE; |
74 | 74 | $tableMap = $this->getTableMap(); |
75 | 75 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | $orderAdded = TRUE; |
78 | 78 | if ($direction === Order::ASC) { |
79 | 79 | $query->addAscendingOrderByColumn($column->getPhpName()); |
80 | - } else { |
|
80 | + }else { |
|
81 | 81 | $query->addDescendingOrderByColumn($column->getPhpName()); |
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
85 | 85 | if (!$orderAdded) { |
86 | 86 | $pks = $this->getPkDbName(); |
87 | - foreach(array_keys($pks) as $key) { |
|
87 | + foreach (array_keys($pks) as $key) { |
|
88 | 88 | $query->addAscendingOrderByColumn($key); |
89 | 89 | } |
90 | 90 | } |
91 | - Logger::log(static::class . ' extract orders end', LOG_DEBUG); |
|
91 | + Logger::log(static::class.' extract orders end', LOG_DEBUG); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param ModelCriteria $query |
98 | 98 | */ |
99 | - protected function addFilters(ModelCriteria &$query) |
|
99 | + protected function addFilters(ModelCriteria & $query) |
|
100 | 100 | { |
101 | 101 | if (count($this->query) > 0) { |
102 | 102 | $tableMap = $this->getTableMap(); |
103 | 103 | foreach ($this->query as $field => $value) { |
104 | 104 | if (self::API_COMBO_FIELD === $field) { |
105 | 105 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
106 | - } elseif(!preg_match('/^__/', $field)) { |
|
106 | + } elseif (!preg_match('/^__/', $field)) { |
|
107 | 107 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
108 | 108 | } |
109 | 109 | } |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | list($page, $limit) = $this->extractPagination(); |
124 | 124 | if ($limit === -1) { |
125 | 125 | $this->list = $query->find($this->con); |
126 | - } else { |
|
126 | + }else { |
|
127 | 127 | $this->list = $query->paginate($page, $limit, $this->con); |
128 | 128 | } |
129 | 129 | $this->checkReturnFields($this->list->getQuery()); |
130 | - } catch (\Exception $e) { |
|
130 | + }catch (\Exception $e) { |
|
131 | 131 | Logger::log($e->getMessage(), LOG_ERR); |
132 | 132 | } |
133 | 133 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | $excluded_modules = explode(',', strtoupper(Config::getParam('hide.modules', ''))); |
48 | 48 | foreach ($systemRoutes as $params) { |
49 | 49 | $module = strtoupper($params['module']); |
50 | - if(in_array($module, $excluded_modules) && $module !== 'PSFS') { |
|
50 | + if (in_array($module, $excluded_modules) && $module !== 'PSFS') { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | if (isset($params['http']) && Request::VERB_GET === $params['http'] |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | if ($files->hasResults()) { |
55 | 55 | foreach ($files->getIterator() as $file) { |
56 | 56 | if ($namespace !== Router::PSFS_BASE_NAMESPACE && method_exists($file, 'getRelativePathname')) { |
57 | - $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
58 | - } else { |
|
57 | + $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
58 | + }else { |
|
59 | 59 | $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname())); |
60 | 60 | } |
61 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
61 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | $this->initializeFinder(); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | if (!is_array($this->domains)) { |
112 | 112 | $this->domains = []; |
113 | 113 | } |
114 | - $domain = '@' . $class->getConstant('DOMAIN') . '/'; |
|
114 | + $domain = '@'.$class->getConstant('DOMAIN').'/'; |
|
115 | 115 | if (!array_key_exists($domain, $this->domains)) { |
116 | 116 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
117 | 117 | } |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath, &$routing = []) |
139 | 139 | { |
140 | 140 | $extModule = $modulePath->getBasename(); |
141 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
141 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
142 | 142 | if (file_exists($moduleAutoloader)) { |
143 | 143 | include_once $moduleAutoloader; |
144 | 144 | if ($hydrateRoute) { |
145 | - $routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $routing); |
|
145 | + $routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $routing); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } |
@@ -158,18 +158,18 @@ discard block |
||
158 | 158 | $modulesToIgnore = explode(',', Config::getParam('hide.modules', '')); |
159 | 159 | try { |
160 | 160 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
161 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
161 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
162 | 162 | if (file_exists($externalModulePath)) { |
163 | 163 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
164 | 164 | if ($externalModule->hasResults()) { |
165 | 165 | foreach ($externalModule->getIterator() as $modulePath) { |
166 | - if(!in_array(strtoupper($modulePath->getRelativePathname()), $modulesToIgnore)) { |
|
166 | + if (!in_array(strtoupper($modulePath->getRelativePathname()), $modulesToIgnore)) { |
|
167 | 167 | $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath, $routing); |
168 | 168 | } |
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
172 | - } catch (Exception $e) { |
|
172 | + }catch (Exception $e) { |
|
173 | 173 | Logger::log($e->getMessage(), LOG_WARNING); |
174 | 174 | } |
175 | 175 | } |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | public function domainExists($domainToCheck) { |
182 | 182 | $exists = false; |
183 | 183 | $domains = array_keys($this->getDomains()); |
184 | - foreach($domains as $domain) { |
|
184 | + foreach ($domains as $domain) { |
|
185 | 185 | $cleanDomain = strtolower(str_replace(['@', '/', '\\'], '', $domain)); |
186 | - if($cleanDomain === strtolower($domainToCheck)) { |
|
186 | + if ($cleanDomain === strtolower($domainToCheck)) { |
|
187 | 187 | $exists = true; |
188 | 188 | break; |
189 | 189 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function init() |
64 | 64 | { |
65 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
66 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
65 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
66 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
67 | 67 | if (empty($this->routing) || Config::getParam('debug', true)) { |
68 | 68 | $this->debugLoad(); |
69 | 69 | } |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function debugLoad() |
81 | 81 | { |
82 | - if(!Config::getParam('skip.route_generation', false)) { |
|
82 | + if (!Config::getParam('skip.route_generation', false)) { |
|
83 | 83 | Logger::log('Begin routes load'); |
84 | 84 | $this->hydrateRouting(); |
85 | 85 | $this->simpatize(); |
86 | 86 | Logger::log('End routes load'); |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | Logger::log('Routes generation skipped'); |
89 | 89 | } |
90 | 90 | } |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | try { |
102 | 102 | //Search action and execute |
103 | 103 | return $this->searchAction($route); |
104 | - } catch (AccessDeniedException $e) { |
|
105 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
104 | + }catch (AccessDeniedException $e) { |
|
105 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
106 | 106 | return Admin::staticAdminLogon(); |
107 | - } catch (RouterException $r) { |
|
107 | + }catch (RouterException $r) { |
|
108 | 108 | Logger::log($r->getMessage(), LOG_WARNING); |
109 | 109 | $code = $r->getCode(); |
110 | - } catch (Exception $e) { |
|
110 | + }catch (Exception $e) { |
|
111 | 111 | Logger::log($e->getMessage(), LOG_ERR); |
112 | 112 | throw $e; |
113 | 113 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function searchAction($route) |
127 | 127 | { |
128 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
128 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
129 | 129 | //Revisamos si tenemos la ruta registrada |
130 | 130 | $parts = parse_url($route); |
131 | 131 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | throw new RouterException(t('Preconditions failed'), 412); |
148 | - } catch (Exception $e) { |
|
148 | + }catch (Exception $e) { |
|
149 | 149 | Logger::log($e->getMessage(), LOG_ERR); |
150 | 150 | throw $e; |
151 | 151 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | } |
172 | 172 | $valid = count($action['requirements']) === $checked; |
173 | - } else { |
|
173 | + }else { |
|
174 | 174 | $valid = true; |
175 | 175 | } |
176 | 176 | return $valid; |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | if ($modules->hasResults()) { |
194 | 194 | foreach ($modules->getIterator() as $modulePath) { |
195 | 195 | $module = $modulePath->getBasename(); |
196 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
196 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |
200 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
200 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $homeParams = NULL; |
215 | 215 | foreach ($this->routing as $pattern => $params) { |
216 | 216 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
217 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
217 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
218 | 218 | $homeParams = $params; |
219 | 219 | } |
220 | 220 | unset($method); |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | { |
247 | 247 | $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : ''; |
248 | 248 | if ('' === $slug) { |
249 | - return $baseUrl . '/'; |
|
249 | + return $baseUrl.'/'; |
|
250 | 250 | } |
251 | 251 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
252 | 252 | throw new RouterException(t('No existe la ruta especificada')); |
253 | 253 | } |
254 | - $url = $baseUrl . $this->slugs[$slug]; |
|
254 | + $url = $baseUrl.$this->slugs[$slug]; |
|
255 | 255 | if (!empty($params)) { |
256 | 256 | foreach ($params as $key => $value) { |
257 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
257 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
258 | 258 | } |
259 | 259 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
260 | - $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default']; |
|
260 | + $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default']; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | private function checkPreActions($class, $method) |
271 | 271 | { |
272 | - $preAction = 'pre' . ucfirst($method); |
|
272 | + $preAction = 'pre'.ucfirst($method); |
|
273 | 273 | if (method_exists($class, $preAction)) { |
274 | 274 | Inspector::stats('[Router] Pre action invoked', Inspector::SCOPE_DEBUG); |
275 | 275 | try { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]); |
278 | 278 | error_clear_last(); |
279 | 279 | } |
280 | - } catch (Exception $e) { |
|
280 | + }catch (Exception $e) { |
|
281 | 281 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
282 | 282 | } |
283 | 283 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
296 | 296 | { |
297 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
297 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
298 | 298 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
299 | 299 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
300 | 300 | $cache = Cache::needCache(); |
@@ -302,15 +302,15 @@ discard block |
||
302 | 302 | $return = null; |
303 | 303 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
304 | 304 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
305 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
305 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
306 | 306 | if (NULL !== $cachedData) { |
307 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
307 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
308 | 308 | Template::getInstance()->renderCache($cachedData, $headers); |
309 | 309 | $execute = FALSE; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | if ($execute) { |
313 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
313 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
314 | 314 | $this->checkPreActions($class, $action['method']); |
315 | 315 | $return = call_user_func_array([$class, $action['method']], $params); |
316 | 316 | if (false === $return) { |