@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | $routes = []; |
33 | 33 | foreach ($systemRoutes as $route => $params) { |
34 | - if(isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) { |
|
34 | + if (isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) { |
|
35 | 35 | $module = strtoupper($params['module']); |
36 | 36 | $mode = $params["visible"] ? 'visible' : 'hidden'; |
37 | 37 | $routes[$module][$mode][] = [ |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | ]; |
42 | 42 | } |
43 | 43 | } |
44 | - foreach($routes as $module => &$route) { |
|
45 | - if(array_key_exists('visible', $route)) { |
|
44 | + foreach ($routes as $module => &$route) { |
|
45 | + if (array_key_exists('visible', $route)) { |
|
46 | 46 | uasort($route["visible"], '\PSFS\base\types\helpers\AdminHelper::sortByLabel'); |
47 | 47 | } |
48 | - if(array_key_exists('hidden', $route)) { |
|
48 | + if (array_key_exists('hidden', $route)) { |
|
49 | 49 | uasort($route["hidden"], '\PSFS\base\types\helpers\AdminHelper::sortByLabel'); |
50 | 50 | } |
51 | 51 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | $objects = scandir($dir); |
20 | 20 | foreach ($objects as $object) { |
21 | 21 | if ($object != "." && $object != "..") { |
22 | - if (filetype($dir . "/" . $object) == "dir") { |
|
23 | - self::deleteDir($dir . "/" . $object); |
|
24 | - } else { |
|
25 | - unlink($dir . "/" . $object); |
|
22 | + if (filetype($dir."/".$object) == "dir") { |
|
23 | + self::deleteDir($dir."/".$object); |
|
24 | + }else { |
|
25 | + unlink($dir."/".$object); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | { |
39 | 39 | $rootDirs = array("css", "js", "media", "font"); |
40 | 40 | foreach ($rootDirs as $dir) { |
41 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
41 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
42 | 42 | try { |
43 | - self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
44 | - } catch (\Exception $e) { |
|
43 | + self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
44 | + }catch (\Exception $e) { |
|
45 | 45 | Logger::log($e->getMessage()); |
46 | 46 | } |
47 | 47 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | { |
58 | 58 | try { |
59 | 59 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
60 | - throw new \Exception(_('Can\'t create directory ') . $dir); |
|
60 | + throw new \Exception(_('Can\'t create directory ').$dir); |
|
61 | 61 | } |
62 | - } catch (\Exception $e) { |
|
62 | + }catch (\Exception $e) { |
|
63 | 63 | Logger::log($e->getMessage(), LOG_WARNING); |
64 | 64 | if (!file_exists(dirname($dir))) { |
65 | - throw new GeneratorException($e->getMessage() . $dir); |
|
65 | + throw new GeneratorException($e->getMessage().$dir); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public static function getTemplatePath() |
75 | 75 | { |
76 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
76 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
77 | 77 | return realpath($path); |
78 | 78 | } |
79 | 79 | |
@@ -91,15 +91,15 @@ discard block |
||
91 | 91 | * @throws GeneratorException |
92 | 92 | */ |
93 | 93 | public static function checkCustomNamespaceApi($namespace) { |
94 | - if(!empty($namespace)) { |
|
95 | - if(class_exists($namespace)) { |
|
94 | + if (!empty($namespace)) { |
|
95 | + if (class_exists($namespace)) { |
|
96 | 96 | $reflector = new \ReflectionClass($namespace); |
97 | - if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
97 | + if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) { |
|
98 | 98 | throw new GeneratorException(_('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501); |
99 | - } elseif(!$reflector->isAbstract()) { |
|
99 | + } elseif (!$reflector->isAbstract()) { |
|
100 | 100 | throw new GeneratorException(_('La clase definida debe ser abstracta'), 501); |
101 | 101 | } |
102 | - } else { |
|
102 | + }else { |
|
103 | 103 | throw new GeneratorException(_('La clase definida para extender la API no existe'), 501); |
104 | 104 | } |
105 | 105 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Método que guarda en fichero los datos pasados |
149 | - * @param $path |
|
149 | + * @param string $path |
|
150 | 150 | * @param $data |
151 | 151 | * @param int $transform |
152 | 152 | * @param boolean $absolute |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Método estático que revisa si se necesita cachear la respuesta de un servicio o no |
204 | - * @return integer|boolean |
|
204 | + * @return integer |
|
205 | 205 | */ |
206 | 206 | public static function needCache() |
207 | 207 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | GeneratorHelper::createDir(dirname($path)); |
52 | 52 | if (false === FileHelper::writeFile($path, $data)) { |
53 | - throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path); |
|
53 | + throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | Logger::log('Gathering data from cache', LOG_DEBUG, ['path' => $path]); |
67 | 67 | $data = null; |
68 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
68 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
69 | 69 | if (file_exists($absolutePath)) { |
70 | 70 | $data = FileHelper::readFile($absolutePath); |
71 | 71 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
83 | 83 | { |
84 | 84 | Logger::log('Checking expiration', LOG_DEBUG, ['path' => $path]); |
85 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
85 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
86 | 86 | $lasModificationDate = filemtime($absolutePath); |
87 | 87 | return ($lasModificationDate + $expires <= time()); |
88 | 88 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | { |
152 | 152 | Logger::log('Store data in cache', LOG_DEBUG, ['path' => $path]); |
153 | 153 | $data = Cache::transformData($data, $transform); |
154 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
154 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
155 | 155 | $this->saveTextToFile($data, $absolutePath); |
156 | 156 | } |
157 | 157 | |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | { |
168 | 168 | $data = null; |
169 | 169 | Logger::log('Reading data from cache', LOG_DEBUG, ['path' => $path]); |
170 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
170 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
171 | 171 | if (is_callable($function) && $this->hasExpiredCache($path, $expires)) { |
172 | 172 | $data = call_user_func($function); |
173 | 173 | $this->storeData($path, $data, $transform, false, $expires); |
174 | - } else { |
|
174 | + }else { |
|
175 | 175 | $data = $this->getDataFromFile($path, $transform); |
176 | 176 | } |
177 | 177 | } |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | * Flush cache when save a registry |
229 | 229 | */ |
230 | 230 | public function flushCache() { |
231 | - if(Config::getParam('cache.data.enable', false)) { |
|
231 | + if (Config::getParam('cache.data.enable', false)) { |
|
232 | 232 | Logger::log('Flushing cache', LOG_DEBUG); |
233 | 233 | $action = Security::getInstance()->getSessionKey("__CACHE__"); |
234 | - if(is_array($action)) { |
|
235 | - $hashPath = FileHelper::generateCachePath($action, $action['params']) . '..' . DIRECTORY_SEPARATOR . ' .. ' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
236 | - if(!file_exists($hashPath)) { |
|
237 | - $hashPath = CACHE_DIR . DIRECTORY_SEPARATOR . $hashPath; |
|
234 | + if (is_array($action)) { |
|
235 | + $hashPath = FileHelper::generateCachePath($action, $action['params']).'..'.DIRECTORY_SEPARATOR.' .. '.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
236 | + if (!file_exists($hashPath)) { |
|
237 | + $hashPath = CACHE_DIR.DIRECTORY_SEPARATOR.$hashPath; |
|
238 | 238 | } |
239 | 239 | FileHelper::deleteDir($hashPath); |
240 | 240 | } |
@@ -121,9 +121,11 @@ |
||
121 | 121 | $cacheService->storeData($cacheFilename, $properties, $cache); |
122 | 122 | } |
123 | 123 | /** @var \ReflectionProperty $property */ |
124 | - if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { |
|
124 | + if (!empty($properties) && is_array($properties)) { |
|
125 | + foreach ($properties as $property => $class) { |
|
125 | 126 | $this->load($property, true, $class); |
126 | 127 | } |
128 | + } |
|
127 | 129 | $this->setLoaded(); |
128 | 130 | } else { |
129 | 131 | Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function __construct() |
17 | 17 | { |
18 | - Logger::log(get_class($this) . ' constructor invoked'); |
|
18 | + Logger::log(get_class($this).' constructor invoked'); |
|
19 | 19 | $this->init(); |
20 | 20 | } |
21 | 21 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | $calledClass = get_called_class(); |
69 | 69 | try { |
70 | 70 | $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
71 | - $setter = "set" . ucfirst($variable); |
|
71 | + $setter = "set".ucfirst($variable); |
|
72 | 72 | if (method_exists($calledClass, $setter)) { |
73 | 73 | $this->$setter($instance); |
74 | - } else { |
|
74 | + }else { |
|
75 | 75 | $this->$variable = $instance; |
76 | 76 | } |
77 | - } catch (\Exception $e) { |
|
78 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
77 | + }catch (\Exception $e) { |
|
78 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
79 | 79 | throw $e; |
80 | 80 | } |
81 | 81 | return $this; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | if (!$this->isLoaded()) { |
90 | 90 | $filename = sha1(get_class($this)); |
91 | - $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . ".json"; |
|
91 | + $cacheFilename = "reflections".DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.".json"; |
|
92 | 92 | /** @var \PSFS\base\Cache $cacheService */ |
93 | 93 | $cacheService = Cache::getInstance(); |
94 | 94 | /** @var \PSFS\base\config\Config $configService */ |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | $this->load($property, true, $class); |
105 | 105 | } |
106 | 106 | $this->setLoaded(); |
107 | - } else { |
|
108 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
107 | + }else { |
|
108 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
@@ -17,11 +17,11 @@ |
||
17 | 17 | public static function checkApiActions($namespace, $domain, $api) { |
18 | 18 | $actions = []; |
19 | 19 | $reflector = new \ReflectionClass($namespace); |
20 | - if(null !== $reflector) { |
|
21 | - foreach($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
20 | + if (null !== $reflector) { |
|
21 | + foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
22 | 22 | $docComments = $apiAction->getDocComment(); |
23 | 23 | $action = self::extractAction($docComments); |
24 | - if(null !== $action) { |
|
24 | + if (null !== $action) { |
|
25 | 25 | list($route, $info) = RouterHelper::extractRouteInfo($apiAction, $api, $domain); |
26 | 26 | list($method, $cleanRoute) = RouterHelper::extractHttpRoute($route); |
27 | 27 | $formAction = new FormAction(); |
@@ -31,9 +31,10 @@ |
||
31 | 31 | function getallheaders() |
32 | 32 | { |
33 | 33 | $headers = array(); |
34 | - foreach ($_SERVER as $h => $v) |
|
35 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
34 | + foreach ($_SERVER as $h => $v) { |
|
35 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
36 | 36 | $headers[$hp[1]] = $v; |
37 | + } |
|
37 | 38 | return $headers; |
38 | 39 | } |
39 | 40 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | /* @var $file SplFileInfo */ |
47 | 47 | foreach ($finder as $file) { |
48 | 48 | $path = $file->getRealPath(); |
49 | - if(!in_array($path, $loaded_files)) { |
|
49 | + if (!in_array($path, $loaded_files)) { |
|
50 | 50 | $loaded_files[] = $path; |
51 | 51 | require_once($path); |
52 | 52 | } |
@@ -7,4 +7,4 @@ |
||
7 | 7 | */ |
8 | 8 | Trait BoostrapTrait {} |
9 | 9 | |
10 | -require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php'; |
|
11 | 10 | \ No newline at end of file |
11 | +require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'bootstrap.php'; |
|
12 | 12 | \ No newline at end of file |
@@ -34,7 +34,7 @@ |
||
34 | 34 | */ |
35 | 35 | public static function dropInstance() { |
36 | 36 | $class = get_called_class(); |
37 | - if(isset(self::$instance[$class])) { |
|
37 | + if (isset(self::$instance[$class])) { |
|
38 | 38 | self::$instance[$class] = null; |
39 | 39 | } |
40 | 40 | } |
@@ -202,7 +202,7 @@ |
||
202 | 202 | |
203 | 203 | /** |
204 | 204 | * Método que fuerza la descarga de un fichero |
205 | - * @param $data |
|
205 | + * @param string $data |
|
206 | 206 | * @param string $content |
207 | 207 | * @param string $filename |
208 | 208 | * @return mixed |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->setStatusCode(Template::STATUS_OK); |
121 | 121 | break; |
122 | 122 | default: |
123 | - $this->setStatusCode('HTTP/1.0 ' . $status ?: 200); |
|
123 | + $this->setStatusCode('HTTP/1.0 '.$status ?: 200); |
|
124 | 124 | break; |
125 | 125 | } |
126 | 126 | return $this; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
139 | 139 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
140 | 140 | ResponseHelper::setCookieHeaders($cookies); |
141 | - header('Content-type: ' . $contentType); |
|
141 | + header('Content-type: '.$contentType); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | |
@@ -154,16 +154,16 @@ discard block |
||
154 | 154 | Logger::log('Start output response'); |
155 | 155 | ob_start(); |
156 | 156 | $this->setReponseHeaders($contentType, $cookies); |
157 | - header('Content-length: ' . strlen($output)); |
|
158 | - header('CRC: ' . crc32($output)); |
|
157 | + header('Content-length: '.strlen($output)); |
|
158 | + header('CRC: '.crc32($output)); |
|
159 | 159 | |
160 | 160 | $needCache = Cache::needCache(); |
161 | 161 | $cache = Cache::getInstance(); |
162 | 162 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
163 | 163 | if (false !== $needCache && $this->getStatusCode() === Template::STATUS_OK && null !== $cacheDataName) { |
164 | 164 | Logger::log('Saving output response into cache'); |
165 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
166 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON); |
|
165 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
166 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON); |
|
167 | 167 | } elseif (Request::getInstance()->getMethod() !== 'GET') { |
168 | 168 | $cache->flushCache(); |
169 | 169 | } |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | Logger::log('Close template render'); |
184 | 184 | $uri = Request::requestUri(); |
185 | 185 | Security::getInstance()->setSessionKey("lastRequest", array( |
186 | - "url" => Request::getInstance()->getRootUrl() . $uri, |
|
186 | + "url" => Request::getInstance()->getRootUrl().$uri, |
|
187 | 187 | "ts" => microtime(true), |
188 | 188 | )); |
189 | 189 | Security::getInstance()->updateSession(); |
190 | - Logger::log('End request: ' . $uri, LOG_INFO); |
|
190 | + Logger::log('End request: '.$uri, LOG_INFO); |
|
191 | 191 | exit; |
192 | 192 | } |
193 | 193 | |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | ///////////////////////////////////////////////////////////// |
226 | 226 | // Date in the past sets the value to already have been expired. |
227 | 227 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
228 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
228 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
229 | 229 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
230 | 230 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
231 | 231 | header("Pragma: no-cache"); |
232 | 232 | header("Expires: 0"); |
233 | 233 | header('Content-Transfer-Encoding: binary'); |
234 | - header("Content-type: " . $content); |
|
235 | - header("Content-length: " . strlen($data)); |
|
236 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
234 | + header("Content-type: ".$content); |
|
235 | + header("Content-length: ".strlen($data)); |
|
236 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
237 | 237 | header("Access-Control-Expose-Headers: Filename"); |
238 | - header("Filename: " . $filename); |
|
238 | + header("Filename: ".$filename); |
|
239 | 239 | echo $data; |
240 | 240 | ob_flush(); |
241 | 241 | ob_end_clean(); |