@@ -28,11 +28,11 @@ |
||
28 | 28 | try { |
29 | 29 | Cache::getInstance()->storeData($filename, $fileContent, Cache::TEXT, true); |
30 | 30 | $created = true; |
31 | - } catch (\Exception $e) { |
|
31 | + }catch (\Exception $e) { |
|
32 | 32 | Logger::log($e->getMessage(), LOG_ERR); |
33 | 33 | } |
34 | - } else { |
|
35 | - Logger::log($filename . t(' not exists or cant write'), LOG_ERR); |
|
34 | + }else { |
|
35 | + Logger::log($filename.t(' not exists or cant write'), LOG_ERR); |
|
36 | 36 | } |
37 | 37 | return $created; |
38 | 38 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function extractApiEndpoints(array $module) |
46 | 46 | { |
47 | - $modulePath = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
47 | + $modulePath = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
48 | 48 | $moduleName = $module['name']; |
49 | 49 | $endpoints = []; |
50 | 50 | if (file_exists($modulePath)) { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** @var SplFileInfo $file */ |
55 | 55 | foreach ($finder as $file) { |
56 | 56 | $filename = str_replace([$modulePath, '/'], ['', '\\'], $file->getPathname()); |
57 | - $namespace = "\\{$moduleName}\\Api" . str_replace('.php', '', $filename); |
|
57 | + $namespace = "\\{$moduleName}\\Api".str_replace('.php', '', $filename); |
|
58 | 58 | $info = $this->extractApiInfo($namespace, $moduleName); |
59 | 59 | if (!empty($info)) { |
60 | 60 | $endpoints[$namespace] = $info; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | if (NULL !== $mInfo) { |
85 | 85 | $info[] = $mInfo; |
86 | 86 | } |
87 | - } catch (Exception $e) { |
|
87 | + }catch (Exception $e) { |
|
88 | 88 | Logger::log($e->getMessage(), LOG_ERR); |
89 | 89 | } |
90 | 90 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | $formatted = [ |
87 | 87 | "swagger" => "2.0", |
88 | 88 | "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)), |
89 | - "basePath" => '/' . $module['name'] . '/api', |
|
89 | + "basePath" => '/'.$module['name'].'/api', |
|
90 | 90 | "schemes" => [Request::getInstance()->getServer('HTTPS') === 'on' ? 'https' : 'http'], |
91 | 91 | "info" => [ |
92 | - "title" => t('Documentación API módulo ') . $module['name'], |
|
92 | + "title" => t('Documentación API módulo ').$module['name'], |
|
93 | 93 | "version" => Config::getParam('api.version', '1.0.0'), |
94 | 94 | "contact" => [ |
95 | 95 | "name" => Config::getParam("author", "Fran López"), |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | foreach ($endpoints as $model) { |
102 | 102 | foreach ($model as $endpoint) { |
103 | 103 | if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
104 | - $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']); |
|
104 | + $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']); |
|
105 | 105 | $description = $endpoint['description']; |
106 | 106 | $method = strtolower($endpoint['method']); |
107 | 107 | $paths[$url][$method] = [ |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | } |
144 | 144 | ksort($dtos); |
145 | - uasort($paths, function ($path1, $path2) { |
|
145 | + uasort($paths, function($path1, $path2) { |
|
146 | 146 | $key1 = array_keys($path1)[0]; |
147 | 147 | $key2 = array_keys($path2)[0]; |
148 | 148 | return strcmp($path1[$key1]['tags'][0], $path2[$key2]['tags'][0]); |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | $modelDto['objects'][$dtoName][$param] = [ |
167 | 167 | 'type' => 'array', |
168 | 168 | 'items' => [ |
169 | - '$ref' => '#/definitions/' . $info['type'], |
|
169 | + '$ref' => '#/definitions/'.$info['type'], |
|
170 | 170 | ] |
171 | 171 | ]; |
172 | - } else { |
|
172 | + }else { |
|
173 | 173 | $modelDto['objects'][$dtoName][$param] = [ |
174 | 174 | 'type' => 'object', |
175 | - '$ref' => '#/definitions/' . $info['type'], |
|
175 | + '$ref' => '#/definitions/'.$info['type'], |
|
176 | 176 | ]; |
177 | 177 | } |
178 | 178 | $modelDto['objects'][$info['class']] = $info['properties']; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | if (array_key_exists('objects', $paramDto)) { |
181 | 181 | $modelDto['objects'] = array_merge($modelDto['objects'], $paramDto['objects']); |
182 | 182 | } |
183 | - } else { |
|
183 | + }else { |
|
184 | 184 | $modelDto['objects'][$dtoName][$param] = $info; |
185 | 185 | } |
186 | 186 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $return = $this->extractReturn($modelNamespace, $docComments); |
212 | 212 | $url = array_pop($route); |
213 | 213 | $methodInfo = [ |
214 | - 'url' => str_replace('/' . $module . '/api', '', $url), |
|
214 | + 'url' => str_replace('/'.$module.'/api', '', $url), |
|
215 | 215 | 'method' => $info['http'], |
216 | 216 | 'description' => $info['label'], |
217 | 217 | 'return' => $return, |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments); |
223 | 223 | $this->setQueryParams($method, $methodInfo); |
224 | 224 | $this->setRequestHeaders($reflection, $methodInfo); |
225 | - } catch (Exception $e) { |
|
225 | + }catch (Exception $e) { |
|
226 | 226 | Logger::log($e->getMessage(), LOG_ERR); |
227 | 227 | } |
228 | 228 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | foreach ($method->getParameters() as $parameter) { |
323 | 323 | $parameterName = $parameter->getName(); |
324 | 324 | $types = []; |
325 | - preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types); |
|
325 | + preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types); |
|
326 | 326 | if (count($types) > 1 && count($types[1]) > 0) { |
327 | 327 | $methodInfo['parameters'][$parameterName] = $types[1][0]; |
328 | 328 | } |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | ]; |
44 | 44 | if ($endpoint['payload']['is_array']) { |
45 | 45 | $schema['items'] = [ |
46 | - '$ref' => '#/definitions/' . $endpoint['payload']['type'], |
|
46 | + '$ref' => '#/definitions/'.$endpoint['payload']['type'], |
|
47 | 47 | ]; |
48 | - } else { |
|
49 | - $schema['$ref'] = '#/definitions/' . $endpoint['payload']['type']; |
|
48 | + }else { |
|
49 | + $schema['$ref'] = '#/definitions/'.$endpoint['payload']['type']; |
|
50 | 50 | } |
51 | 51 | if (!self::searchPayloadParam($paths[$url][$method]['parameters'], $endpoint['payload']['type'])) { |
52 | 52 | $paths[$url][$method]['parameters'][] = [ |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) { |
78 | 78 | $classDefinition = [ |
79 | 79 | 'type' => 'object', |
80 | - '$ref' => '#/definitions/' . $class, |
|
80 | + '$ref' => '#/definitions/'.$class, |
|
81 | 81 | ]; |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | $classDefinition = [ |
84 | 84 | 'type' => 'array', |
85 | 85 | 'items' => [ |
86 | - '$ref' => '#/definitions/' . $class, |
|
86 | + '$ref' => '#/definitions/'.$class, |
|
87 | 87 | ], |
88 | 88 | ]; |
89 | 89 | } |
@@ -152,7 +152,7 @@ |
||
152 | 152 | { |
153 | 153 | if ($mappedColumn->getSize() > 100) { |
154 | 154 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
155 | - } else { |
|
155 | + }else { |
|
156 | 156 | $fDto = self::generateStringField($field, $required); |
157 | 157 | } |
158 | 158 | return $fDto; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $dump = ''; |
121 | 121 | try { |
122 | 122 | $dump = $this->tpl->render($tpl, $vars); |
123 | - } catch (\Exception $e) { |
|
123 | + }catch (\Exception $e) { |
|
124 | 124 | Logger::log($e->getMessage(), LOG_ERR); |
125 | 125 | } |
126 | 126 | return $dump; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | public function regenerateTemplates() |
148 | 148 | { |
149 | 149 | $this->generateTemplatesCache(); |
150 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
150 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
151 | 151 | $translations = []; |
152 | 152 | if (is_array($domains)) { |
153 | 153 | $translations = $this->parsePathTranslations($domains); |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | // force compilation |
173 | 173 | if ($file->isFile()) { |
174 | 174 | try { |
175 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
176 | - } catch (\Exception $e) { |
|
175 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
176 | + }catch (\Exception $e) { |
|
177 | 177 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
178 | 178 | } |
179 | 179 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | private function loadDomains() |
255 | 255 | { |
256 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
256 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
257 | 257 | if (null !== $domains) { |
258 | 258 | foreach ($domains as $domain => $paths) { |
259 | 259 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | $loader = new FilesystemLoader(GeneratorHelper::getTemplatePath()); |
270 | 270 | $this->tpl = new Environment($loader, array( |
271 | - 'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig', |
|
271 | + 'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig', |
|
272 | 272 | 'debug' => (bool)$this->debug, |
273 | 273 | 'auto_reload' => Config::getParam('twig.autoreload', TRUE), |
274 | 274 | )); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getAdmins() |
66 | 66 | { |
67 | - return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true); |
|
67 | + return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | if (!empty($user) && !empty($admins[$user])) { |
91 | 91 | $auth = $admins[$user]['hash']; |
92 | - $this->authorized = ($auth === sha1($user . $pass)); |
|
92 | + $this->authorized = ($auth === sha1($user.$pass)); |
|
93 | 93 | if ($this->authorized) { |
94 | 94 | $this->updateAdmin($user, $admins[$user]['profile']); |
95 | 95 | ResponseHelper::setCookieHeaders([ |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ]); |
103 | 103 | $this->setSessionKey(self::LOGGED_USER_TOKEN, base64_encode("{$user}:{$pass}")); |
104 | 104 | } |
105 | - } else { |
|
105 | + }else { |
|
106 | 106 | $this->admin = null; |
107 | 107 | $this->setSessionKey(self::ADMIN_ID_TOKEN, null); |
108 | 108 | } |
@@ -86,11 +86,11 @@ |
||
86 | 86 | public static function save($user) |
87 | 87 | { |
88 | 88 | $saved = true; |
89 | - $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: []; |
|
90 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
89 | + $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: []; |
|
90 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
91 | 91 | $admins[$user['username']]['profile'] = $user['profile']; |
92 | 92 | |
93 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true); |
|
93 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true); |
|
94 | 94 | return $saved; |
95 | 95 | } |
96 | 96 |
@@ -38,9 +38,9 @@ |
||
38 | 38 | if (self::isTest()) { |
39 | 39 | throw new UserAuthException(); |
40 | 40 | } |
41 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
41 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
42 | 42 | return AdminServices::getInstance()->setAdminHeaders(); |
43 | - } else { |
|
43 | + }else { |
|
44 | 44 | return UserController::showAdminManager(); |
45 | 45 | } |
46 | 46 | } |