@@ -31,14 +31,18 @@ |
||
31 | 31 | //Hidratamos con los comandos de PSFS |
32 | 32 | $commands = new Finder(); |
33 | 33 | $commands->in(__DIR__)->notName("PSFSConsole.php"); |
34 | - foreach ($commands as $com) include_once($com->getRealPath()); |
|
34 | + foreach ($commands as $com) { |
|
35 | + include_once($com->getRealPath()); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | //Hidratamos con los comandos de los módulos |
37 | 39 | if (file_exists(CORE_DIR)) |
38 | 40 | { |
39 | 41 | $commands = new Finder(); |
40 | 42 | $commands->in(CORE_DIR)->path("Command")->name("*.php"); |
41 | - foreach ($commands as $com) include_once($com->getRealPath()); |
|
43 | + foreach ($commands as $com) { |
|
44 | + include_once($com->getRealPath()); |
|
45 | + } |
|
42 | 46 | } |
43 | 47 | |
44 | 48 | $console->run(); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use PSFS\controller\Admin; |
7 | 7 | use Symfony\Component\Finder\Finder; |
8 | 8 | |
9 | - class AdminServices extends Service{ |
|
9 | + class AdminServices extends Service { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @Inyectable |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function setAdminHeaders() |
32 | 32 | { |
33 | - if("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup"); |
|
33 | + if ("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup"); |
|
34 | 34 | $platform = trim(Config::getInstance()->get("platform_name")); |
35 | 35 | header('HTTP/1.1 401 Unauthorized'); |
36 | - header('WWW-Authenticate: Basic Realm="' . $platform. '"'); |
|
36 | + header('WWW-Authenticate: Basic Realm="'.$platform.'"'); |
|
37 | 37 | echo _("Zona restringida"); |
38 | 38 | exit(); |
39 | 39 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | public function getAdmins() |
46 | 46 | { |
47 | 47 | $admins = $this->security->getAdmins(); |
48 | - if(!empty($admins)) |
|
48 | + if (!empty($admins)) |
|
49 | 49 | { |
50 | - if(!$this->security->checkAdmin()) |
|
50 | + if (!$this->security->checkAdmin()) |
|
51 | 51 | { |
52 | 52 | $this->setAdminHeaders(); |
53 | 53 | } |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | */ |
63 | 63 | private function parseAdmins(&$admins) |
64 | 64 | { |
65 | - if(!empty($admins)) foreach($admins as &$admin) |
|
65 | + if (!empty($admins)) foreach ($admins as &$admin) |
|
66 | 66 | { |
67 | - if(isset($admin["profile"])) |
|
67 | + if (isset($admin["profile"])) |
|
68 | 68 | { |
69 | 69 | $admin["class"] = $admin["profile"] == sha1("admin") ? 'primary' : "warning"; |
70 | - }else{ |
|
70 | + }else { |
|
71 | 71 | $admin["class"] = "primary"; |
72 | 72 | } |
73 | 73 | } |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | $files->files()->in(LOG_DIR)->name("*.log")->sortByModifiedTime(); |
88 | 88 | $logs = array(); |
89 | 89 | /** @var \SplFileInfo $file */ |
90 | - foreach($files as $file) |
|
90 | + foreach ($files as $file) |
|
91 | 91 | { |
92 | - $size = $file->getSize() / 8 / 1024; |
|
92 | + $size = $file->getSize()/8/1024; |
|
93 | 93 | $time = date("c", $file->getMTime()); |
94 | 94 | $dateTime = new \DateTime($time); |
95 | - if(!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
|
95 | + if (!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
|
96 | 96 | $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array( |
97 | 97 | "filename" => $file->getFilename(), |
98 | 98 | "size" => round($size, 3) |
@@ -116,27 +116,27 @@ discard block |
||
116 | 116 | $files->files()->in(LOG_DIR)->name($selectedLog); |
117 | 117 | $file = null; |
118 | 118 | $log = array(); |
119 | - foreach($files as $match) |
|
119 | + foreach ($files as $match) |
|
120 | 120 | { |
121 | 121 | $file = $match; |
122 | 122 | break; |
123 | 123 | } |
124 | 124 | /** @var \SplFileInfo $file */ |
125 | - if(!empty($file)) |
|
125 | + if (!empty($file)) |
|
126 | 126 | { |
127 | 127 | $time = date("c", $file->getMTime()); |
128 | 128 | $dateTime = new \DateTime($time); |
129 | 129 | $monthOpen = $dateTime->format("m"); |
130 | - $content = file($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename()); |
|
130 | + $content = file($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename()); |
|
131 | 131 | krsort($content); |
132 | 132 | $detailLog = array(); |
133 | - foreach($content as &$line) |
|
133 | + foreach ($content as &$line) |
|
134 | 134 | { |
135 | 135 | list($line, $detail) = $this->parseLogLine($line, $match); |
136 | 136 | $detailLog[] = array_merge(array( |
137 | 137 | "log" => $line, |
138 | 138 | ), $detail); |
139 | - if(count($detailLog) >= 1000) break; |
|
139 | + if (count($detailLog) >= 1000) break; |
|
140 | 140 | } |
141 | 141 | $log = $detailLog; |
142 | 142 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | $type = (isset($match[1][0])) ? $match[1][0] : ''; |
167 | 167 | $type = explode(".", $type); |
168 | - $type = count($type)>1 ? $type[1] : $type[0]; |
|
168 | + $type = count($type) > 1 ? $type[1] : $type[0]; |
|
169 | 169 | switch ($type) { |
170 | 170 | case 'INFO': |
171 | 171 | $detail["type"] = "success"; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | break; |
182 | 182 | } |
183 | 183 | |
184 | - } catch (\Exception $e) { |
|
184 | + }catch (\Exception $e) { |
|
185 | 185 | $detail = array( |
186 | 186 | "type" => "danger", |
187 | 187 | ); |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function setAdminHeaders() |
32 | 32 | { |
33 | - if("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup"); |
|
33 | + if("login" === $this->config->get("admin_login")) { |
|
34 | + return Admin::getInstance()->adminLogin("admin-setup"); |
|
35 | + } |
|
34 | 36 | $platform = trim(Config::getInstance()->get("platform_name")); |
35 | 37 | header('HTTP/1.1 401 Unauthorized'); |
36 | 38 | header('WWW-Authenticate: Basic Realm="' . $platform. '"'); |
@@ -62,12 +64,14 @@ discard block |
||
62 | 64 | */ |
63 | 65 | private function parseAdmins(&$admins) |
64 | 66 | { |
65 | - if(!empty($admins)) foreach($admins as &$admin) |
|
67 | + if(!empty($admins)) { |
|
68 | + foreach($admins as &$admin) |
|
66 | 69 | { |
67 | 70 | if(isset($admin["profile"])) |
68 | 71 | { |
69 | 72 | $admin["class"] = $admin["profile"] == sha1("admin") ? 'primary' : "warning"; |
70 | - }else{ |
|
73 | + } |
|
74 | + } else{ |
|
71 | 75 | $admin["class"] = "primary"; |
72 | 76 | } |
73 | 77 | } |
@@ -92,7 +96,9 @@ discard block |
||
92 | 96 | $size = $file->getSize() / 8 / 1024; |
93 | 97 | $time = date("c", $file->getMTime()); |
94 | 98 | $dateTime = new \DateTime($time); |
95 | - if(!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
|
99 | + if(!isset($logs[$dateTime->format("Y")])) { |
|
100 | + $logs[$dateTime->format("Y")] = array(); |
|
101 | + } |
|
96 | 102 | $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array( |
97 | 103 | "filename" => $file->getFilename(), |
98 | 104 | "size" => round($size, 3) |
@@ -136,7 +142,9 @@ discard block |
||
136 | 142 | $detailLog[] = array_merge(array( |
137 | 143 | "log" => $line, |
138 | 144 | ), $detail); |
139 | - if(count($detailLog) >= 1000) break; |
|
145 | + if(count($detailLog) >= 1000) { |
|
146 | + break; |
|
147 | + } |
|
140 | 148 | } |
141 | 149 | $log = $detailLog; |
142 | 150 | } |
@@ -160,7 +168,9 @@ discard block |
||
160 | 168 | |
161 | 169 | $detail = json_decode($match[0][0], TRUE); |
162 | 170 | } |
163 | - if (empty($detail)) $detail = array(); |
|
171 | + if (empty($detail)) { |
|
172 | + $detail = array(); |
|
173 | + } |
|
164 | 174 | preg_match_all('/\>\ (.*):/i', $line, $match); |
165 | 175 | |
166 | 176 | $type = (isset($match[1][0])) ? $match[1][0] : ''; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | { |
22 | 22 | $array = array(); |
23 | 23 | $array['fields'] = array(); |
24 | - foreach($this->fields as $field) { |
|
24 | + foreach ($this->fields as $field) { |
|
25 | 25 | $array['fields'][] = $field->__toArray(); |
26 | 26 | } |
27 | 27 | return $array; |
@@ -26,13 +26,13 @@ |
||
26 | 26 | { |
27 | 27 | $namespace = explode('\\', $this->getModelTableMap()); |
28 | 28 | $module = strtolower($namespace[0]); |
29 | - $secret = Config::getInstance()->get($module . '.api.secret'); |
|
29 | + $secret = Config::getInstance()->get($module.'.api.secret'); |
|
30 | 30 | if (NULL === $secret) { |
31 | 31 | $secret = Config::getInstance()->get("api.secret"); |
32 | 32 | } |
33 | 33 | if (NULL === $secret) { |
34 | 34 | $auth = TRUE; |
35 | - } else { |
|
35 | + }else { |
|
36 | 36 | $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN'); |
37 | 37 | if (array_key_exists('API_TOKEN', $this->query)) { |
38 | 38 | $token = $this->query['API_TOKEN']; |
@@ -7,7 +7,19 @@ |
||
7 | 7 | * @package PSFS\base\types\interfaces |
8 | 8 | */ |
9 | 9 | interface AuthInterface { |
10 | + |
|
11 | + /** |
|
12 | + * @return boolean |
|
13 | + */ |
|
10 | 14 | function isLogged(); |
15 | + |
|
16 | + /** |
|
17 | + * @return boolean |
|
18 | + */ |
|
11 | 19 | function isAdmin(); |
20 | + |
|
21 | + /** |
|
22 | + * @return boolean |
|
23 | + */ |
|
12 | 24 | function canDo($action); |
13 | 25 | } |
@@ -7,6 +7,14 @@ |
||
7 | 7 | * @package PSFS\base\types\interfaces |
8 | 8 | */ |
9 | 9 | interface ControllerInterface { |
10 | + |
|
11 | + /** |
|
12 | + * @return string|null |
|
13 | + */ |
|
10 | 14 | public function render($template, Array $vars = null); |
15 | + |
|
16 | + /** |
|
17 | + * @return void |
|
18 | + */ |
|
11 | 19 | public function response($response, $type = 'text/html'); |
12 | 20 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use PSFS\base\exception\SecurityException; |
13 | 13 | use PSFS\base\Singleton; |
14 | 14 | |
15 | - require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php"; |
|
15 | + require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php"; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Class Dispatcher |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | { |
83 | 83 | $this->locale = $this->config->get("default_language"); |
84 | 84 | // Load translations |
85 | - putenv("LC_ALL=" . $this->locale); |
|
85 | + putenv("LC_ALL=".$this->locale); |
|
86 | 86 | setlocale(LC_ALL, $this->locale); |
87 | 87 | // Load the locale path |
88 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
88 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
89 | 89 | Config::createDir($locale_path); |
90 | 90 | bindtextdomain('translations', $locale_path); |
91 | 91 | textdomain('translations'); |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function run() |
101 | 101 | { |
102 | - $this->log->infoLog("Begin request " . $this->parser->getRequestUri()); |
|
102 | + $this->log->infoLog("Begin request ".$this->parser->getRequestUri()); |
|
103 | 103 | // |
104 | 104 | try { |
105 | 105 | if ($this->config->isConfigured()) { |
106 | 106 | if (!$this->parser->isFile()) { |
107 | 107 | return $this->router->execute($this->actualUri); |
108 | 108 | } |
109 | - } else { |
|
109 | + }else { |
|
110 | 110 | return $this->router->getAdmin()->config(); |
111 | 111 | } |
112 | - } catch (ConfigException $c) { |
|
112 | + }catch (ConfigException $c) { |
|
113 | 113 | return $this->dumpException($c); |
114 | - } catch (SecurityException $s) { |
|
114 | + }catch (SecurityException $s) { |
|
115 | 115 | return $this->security->notAuthorized($this->actualUri); |
116 | - } catch (RouterException $r) { |
|
116 | + }catch (RouterException $r) { |
|
117 | 117 | return $this->router->httpNotFound($r); |
118 | - } catch (\Exception $e) { |
|
118 | + }catch (\Exception $e) { |
|
119 | 119 | return $this->dumpException($e); |
120 | 120 | } |
121 | 121 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $use /= 1024; |
157 | 157 | break; |
158 | 158 | case "MBytes": |
159 | - $use /= (1024 * 1024); |
|
159 | + $use /= (1024*1024); |
|
160 | 160 | break; |
161 | 161 | case "Bytes": |
162 | 162 | default: |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | { |
182 | 182 | if ($this->config->getDebugMode()) { |
183 | 183 | //Warning & Notice handler |
184 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
184 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
185 | 185 | throw new \ErrorException($errstr, 500, $errno, $errfile, $errline); |
186 | 186 | }); |
187 | 187 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @param ModelCriteria $query |
181 | 181 | */ |
182 | - private function addOrders(ModelCriteria &$query) |
|
182 | + private function addOrders(ModelCriteria & $query) |
|
183 | 183 | { |
184 | 184 | $orderAdded = FALSE; |
185 | 185 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $orderAdded = TRUE; |
188 | 188 | if ($direction === Order::ASC) { |
189 | 189 | $query->addAscendingOrderByColumn($field); |
190 | - } else { |
|
190 | + }else { |
|
191 | 191 | $query->addDescendingOrderByColumn($field); |
192 | 192 | } |
193 | 193 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @param ModelCriteria $query |
204 | 204 | */ |
205 | - private function addExtraColumns(ModelCriteria &$query) |
|
205 | + private function addExtraColumns(ModelCriteria & $query) |
|
206 | 206 | { |
207 | 207 | if (!empty($this->extraColumns)) { |
208 | 208 | foreach ($this->extraColumns as $expression => $columnName) { |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param ModelCriteria $query |
218 | 218 | */ |
219 | - protected function joinTables(ModelCriteria &$query) |
|
219 | + protected function joinTables(ModelCriteria & $query) |
|
220 | 220 | { |
221 | 221 | //TODO for specific implementations |
222 | 222 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @param ModelCriteria $query |
228 | 228 | */ |
229 | - private function addFilters(ModelCriteria &$query) |
|
229 | + private function addFilters(ModelCriteria & $query) |
|
230 | 230 | { |
231 | 231 | if (count($this->query) > 0) { |
232 | 232 | foreach ($this->query as $field => $value) { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { |
244 | 244 | $text = preg_replace('/(\'|\")/', '', $value); |
245 | 245 | $query->filterBy($tableField, $text, Criteria::LIKE); |
246 | - } else { |
|
246 | + }else { |
|
247 | 247 | $query->filterBy($tableField, $value, Criteria::EQUAL); |
248 | 248 | } |
249 | 249 | } |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | list($page, $limit) = $this->extractPagination(); |
267 | 267 | if ($limit == -1) { |
268 | 268 | $this->list = $query->find($this->con); |
269 | - } else { |
|
269 | + }else { |
|
270 | 270 | $this->list = $query->paginate($page, $limit, $this->con); |
271 | 271 | } |
272 | - } catch (\Exception $e) { |
|
272 | + }catch (\Exception $e) { |
|
273 | 273 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
274 | 274 | } |
275 | 275 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $this->joinTables($query); |
287 | 287 | $this->addExtraColumns($query); |
288 | 288 | $this->model = $query->findPk($pk); |
289 | - } catch (\Exception $e) { |
|
289 | + }catch (\Exception $e) { |
|
290 | 290 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
291 | 291 | } |
292 | 292 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $saved = TRUE; |
375 | 375 | $model = $this->model->toArray(); |
376 | 376 | } |
377 | - } catch (\Exception $e) { |
|
377 | + }catch (\Exception $e) { |
|
378 | 378 | jpre($e->getMessage(), TRUE); |
379 | 379 | Logger::getInstance()->errorLog($e->getMessage()); |
380 | 380 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $this->model->delete($this->con); |
404 | 404 | $deleted = TRUE; |
405 | 405 | } |
406 | - } catch (\Exception $e) { |
|
406 | + }catch (\Exception $e) { |
|
407 | 407 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
408 | 408 | } |
409 | 409 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | */ |
448 | 448 | private function extractQuery() |
449 | 449 | { |
450 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
450 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
451 | 451 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
452 | 452 | $query = $queryReflector->getMethod('create')->invoke(NULL); |
453 | 453 | |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | if ($this->con->inTransaction()) { |
492 | 492 | if ($status === 200) { |
493 | 493 | $this->con->commit(); |
494 | - } else { |
|
494 | + }else { |
|
495 | 495 | $this->con->rollBack(); |
496 | 496 | } |
497 | 497 | } |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | return $this->render('api.admin.html.twig', array( |
536 | 536 | "api" => $this->getApi(), |
537 | 537 | "domain" => $this->domain, |
538 | - "url" => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)), |
|
538 | + "url" => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)), |
|
539 | 539 | )); |
540 | 540 | } |
541 | 541 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | $return = $this->list->toArray(); |
573 | 573 | $total = $this->list->getNbResults(); |
574 | 574 | $pages = $this->list->getLastPage(); |
575 | - } catch (\Exception $e) { |
|
575 | + }catch (\Exception $e) { |
|
576 | 576 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
577 | 577 | } |
578 | 578 | |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | $return = array(); |
593 | 593 | if (NULL === $model) { |
594 | 594 | $code = 404; |
595 | - } else { |
|
595 | + }else { |
|
596 | 596 | $return = $model->toArray(); |
597 | 597 | } |
598 | 598 |
@@ -371,7 +371,7 @@ |
||
371 | 371 | * @param array $parts |
372 | 372 | * @param int $partLength |
373 | 373 | * |
374 | - * @return array |
|
374 | + * @return string[] |
|
375 | 375 | */ |
376 | 376 | private static function extractTsAndMod(array &$parts, $partLength) |
377 | 377 | { |
@@ -422,7 +422,7 @@ |
||
422 | 422 | "type" => $type, |
423 | 423 | ]; |
424 | 424 | if (strlen($format)) { |
425 | - $dto['properties'][$field]['format'] = $format; |
|
425 | + $dto['properties'][$field]['format'] = $format; |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | if (!preg_match('/^\@ROOT/i', $domain)) { |
34 | 34 | $modules[] = str_replace('/', '', str_replace('@', '', $domain)); |
35 | 35 | } |
36 | - } catch (\Exception $e) { |
|
36 | + }catch (\Exception $e) { |
|
37 | 37 | $modules[] = $e->getMessage(); |
38 | 38 | } |
39 | 39 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function extractApiEndpoints($module) |
53 | 53 | { |
54 | - $module_path = CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Api"; |
|
54 | + $module_path = CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Api"; |
|
55 | 55 | $endpoints = []; |
56 | 56 | if (file_exists($module_path)) { |
57 | 57 | $finder = new Finder(); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (count($finder)) { |
60 | 60 | /** @var \SplFileInfo $file */ |
61 | 61 | foreach ($finder as $file) { |
62 | - $namespace = "\\{$module}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
62 | + $namespace = "\\{$module}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
63 | 63 | $endpoints[$namespace] = $this->extractApiInfo($namespace); |
64 | 64 | } |
65 | 65 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if (NULL !== $mInfo) { |
89 | 89 | $info[] = $mInfo; |
90 | 90 | } |
91 | - } catch (\Exception $e) { |
|
91 | + }catch (\Exception $e) { |
|
92 | 92 | Logger::getInstance()->errorLog($e->getMessage()); |
93 | 93 | } |
94 | 94 | } |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | if ($reflector->isSubclassOf(self::DTO_INTERFACE)) { |
222 | 222 | foreach ($reflector->getProperties(\ReflectionMethod::IS_PUBLIC) as $property) { |
223 | 223 | $type = $this->extractVarType($property->getDocComment()); |
224 | - if(class_exists($type)) { |
|
224 | + if (class_exists($type)) { |
|
225 | 225 | $properties[$property->getName()] = $this->extractModelFields($type); |
226 | - } else { |
|
226 | + }else { |
|
227 | 227 | $properties[$property->getName()] = $type; |
228 | 228 | } |
229 | 229 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | protected function extractReturn($model, $comments = '') |
244 | 244 | { |
245 | - $modelDto = []; |
|
245 | + $modelDto = []; |
|
246 | 246 | preg_match('/\@return\ (.*)\((.*)\)\n/i', $comments, $returnTypes); |
247 | 247 | if (count($returnTypes)) { |
248 | 248 | // Extract principal DTO information |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
296 | 296 | $payload = $this->extractDtoProperties($namespace); |
297 | 297 | } |
298 | - } catch (\Exception $e) { |
|
298 | + }catch (\Exception $e) { |
|
299 | 299 | Logger::getInstance()->errorLog($e->getMessage()); |
300 | 300 | } |
301 | 301 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | if (in_array($methodInfo['method'], ['POST', 'PUT'])) { |
332 | 332 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); |
333 | 333 | } |
334 | - } catch (\Exception $e) { |
|
334 | + }catch (\Exception $e) { |
|
335 | 335 | jpre($e->getMessage()); |
336 | 336 | Logger::getInstance()->errorLog($e->getMessage()); |
337 | 337 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | */ |
350 | 350 | public static function translateSwaggerFormats($format) |
351 | 351 | { |
352 | - switch(strtolower($format)) { |
|
352 | + switch (strtolower($format)) { |
|
353 | 353 | case 'bool': |
354 | 354 | case 'boolean': |
355 | 355 | $swaggerType = 'boolean'; |
@@ -410,13 +410,13 @@ discard block |
||
410 | 410 | ]]); |
411 | 411 | if (array_key_exists($subDtoName, $subDto)) { |
412 | 412 | $definitions = $subDto; |
413 | - } else { |
|
413 | + }else { |
|
414 | 414 | $definitions[$subDtoName] = $subDto; |
415 | 415 | } |
416 | 416 | $dto['properties'][$field] = [ |
417 | - '$ref' => "#/definitions/" . $subDtoName, |
|
417 | + '$ref' => "#/definitions/".$subDtoName, |
|
418 | 418 | ]; |
419 | - } else { |
|
419 | + }else { |
|
420 | 420 | list($type, $format) = self::translateSwaggerFormats($format); |
421 | 421 | $dto['properties'][$field] = [ |
422 | 422 | "type" => $type, |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | "url" => Router::getInstance()->getRoute(''), |
454 | 454 | ] |
455 | 455 | ]; |
456 | - foreach($endpoints as $model) { |
|
456 | + foreach ($endpoints as $model) { |
|
457 | 457 | foreach ($model as $endpoint) { |
458 | 458 | $dtos += self::extractSwaggerDefinition($endpoint); |
459 | 459 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | protected function extractDtoName($dto, $isArray = false) |
473 | 473 | { |
474 | 474 | $dto = explode('\\', $dto); |
475 | - $modelDto = array_pop($dto) . "Dto"; |
|
475 | + $modelDto = array_pop($dto)."Dto"; |
|
476 | 476 | if ($isArray) { |
477 | 477 | $modelDto .= "List"; |
478 | 478 | } |