@@ -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 | { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | if (!preg_match('/^\@ROOT/i', $domain)) { |
| 35 | 35 | $modules[] = str_replace('/', '', str_replace('@', '', $domain)); |
| 36 | 36 | } |
| 37 | - } catch (\Exception $e) { |
|
| 37 | + }catch (\Exception $e) { |
|
| 38 | 38 | $modules[] = $e->getMessage(); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function extractApiEndpoints($module) |
| 54 | 54 | { |
| 55 | - $module_path = CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "Api"; |
|
| 55 | + $module_path = CORE_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR."Api"; |
|
| 56 | 56 | $endpoints = []; |
| 57 | 57 | if (file_exists($module_path)) { |
| 58 | 58 | $finder = new Finder(); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if (count($finder)) { |
| 61 | 61 | /** @var \SplFileInfo $file */ |
| 62 | 62 | foreach ($finder as $file) { |
| 63 | - $namespace = "\\{$module}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
| 63 | + $namespace = "\\{$module}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
| 64 | 64 | $endpoints[$namespace] = $this->extractApiInfo($namespace); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | if (NULL !== $mInfo) { |
| 90 | 90 | $info[] = $mInfo; |
| 91 | 91 | } |
| 92 | - } catch (\Exception $e) { |
|
| 92 | + }catch (\Exception $e) { |
|
| 93 | 93 | Logger::getInstance()->errorLog($e->getMessage()); |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | protected function extractReturn($model, $comments = '') |
| 238 | 238 | { |
| 239 | - $modelDto = []; |
|
| 239 | + $modelDto = []; |
|
| 240 | 240 | preg_match('/\@return\ (.*)\((.*)\)\n/i', $comments, $returnTypes); |
| 241 | 241 | if (count($returnTypes)) { |
| 242 | 242 | // Extract principal DTO information |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
| 290 | 290 | $payload = $this->extractDtoProperties($namespace); |
| 291 | 291 | } |
| 292 | - } catch (\Exception $e) { |
|
| 292 | + }catch (\Exception $e) { |
|
| 293 | 293 | Logger::getInstance()->errorLog($e->getMessage()); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | if (in_array($methodInfo['method'], ['POST', 'PUT'])) { |
| 326 | 326 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); |
| 327 | 327 | } |
| 328 | - } catch (\Exception $e) { |
|
| 328 | + }catch (\Exception $e) { |
|
| 329 | 329 | jpre($e->getMessage()); |
| 330 | 330 | Logger::getInstance()->errorLog($e->getMessage()); |
| 331 | 331 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public static function translateSwaggerFormats($format) |
| 345 | 345 | { |
| 346 | - switch(strtolower($format)) { |
|
| 346 | + switch (strtolower($format)) { |
|
| 347 | 347 | case 'bool': |
| 348 | 348 | case 'boolean': |
| 349 | 349 | $swaggerType = 'boolean'; |
@@ -404,13 +404,13 @@ discard block |
||
| 404 | 404 | ]]); |
| 405 | 405 | if (array_key_exists($subDtoName, $subDto)) { |
| 406 | 406 | $definitions = $subDto; |
| 407 | - } else { |
|
| 407 | + }else { |
|
| 408 | 408 | $definitions[$subDtoName] = $subDto; |
| 409 | 409 | } |
| 410 | 410 | $dto['properties'][$field] = [ |
| 411 | - '$ref' => "#/definitions/" . $subDtoName, |
|
| 411 | + '$ref' => "#/definitions/".$subDtoName, |
|
| 412 | 412 | ]; |
| 413 | - } else { |
|
| 413 | + }else { |
|
| 414 | 414 | list($type, $format) = self::translateSwaggerFormats($format); |
| 415 | 415 | $dto['properties'][$field] = [ |
| 416 | 416 | "type" => $type, |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | "url" => Router::getInstance()->getRoute(''), |
| 448 | 448 | ] |
| 449 | 449 | ]; |
| 450 | - foreach($endpoints as $model) { |
|
| 450 | + foreach ($endpoints as $model) { |
|
| 451 | 451 | foreach ($model as $endpoint) { |
| 452 | 452 | $dtos += self::extractSwaggerDefinition($endpoint); |
| 453 | 453 | } |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | protected function extractDtoName($dto, $isArray = false) |
| 467 | 467 | { |
| 468 | 468 | $dto = explode('\\', $dto); |
| 469 | - $modelDto = array_pop($dto) . "Dto"; |
|
| 469 | + $modelDto = array_pop($dto)."Dto"; |
|
| 470 | 470 | if ($isArray) { |
| 471 | 471 | $modelDto .= "List"; |
| 472 | 472 | } |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use PSFS\base\Logger; |
| 5 | 5 | use PSFS\base\Service; |
| 6 | - use PSFS\base\Singleton; |
|
| 7 | 6 | use PSFS\base\types\helpers\InjectorHelper; |
| 8 | 7 | use Symfony\Component\Finder\Finder; |
| 9 | 8 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $properties = []; |
| 222 | 222 | $reflector = new \ReflectionClass($class); |
| 223 | 223 | if ($reflector->isSubclassOf(self::DTO_INTERFACE)) { |
| 224 | - $properties = array_merge($properties, InjectorHelper::extractProperties($reflector, \ReflectionMethod::IS_PUBLIC)); |
|
| 224 | + $properties = array_merge($properties, InjectorHelper::extractProperties($reflector, \ReflectionMethod::IS_PUBLIC)); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return $properties; |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | "type" => $type, |
| 418 | 418 | ]; |
| 419 | 419 | if (strlen($format)) { |
| 420 | - $dto['properties'][$field]['format'] = $format; |
|
| 420 | + $dto['properties'][$field]['format'] = $format; |
|
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | } |
@@ -121,6 +121,9 @@ |
||
| 121 | 121 | return self::getInstance()->getHeader($name); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | + /** |
|
| 125 | + * @return string |
|
| 126 | + */ |
|
| 124 | 127 | public function getHeader($name) |
| 125 | 128 | { |
| 126 | 129 | $header = null; |
@@ -8,9 +8,10 @@ discard block |
||
| 8 | 8 | function getallheaders() |
| 9 | 9 | { |
| 10 | 10 | $headers = array(); |
| 11 | - foreach ($_SERVER as $h => $v) |
|
| 12 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
| 11 | + foreach ($_SERVER as $h => $v) { |
|
| 12 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
| 13 | 13 | $headers[$hp[1]] = $v; |
| 14 | + } |
|
| 14 | 15 | return $headers; |
| 15 | 16 | } |
| 16 | 17 | } |
@@ -214,7 +215,9 @@ discard block |
||
| 214 | 215 | */ |
| 215 | 216 | public function redirect($url = null) |
| 216 | 217 | { |
| 217 | - if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
|
| 218 | + if (null === $url) { |
|
| 219 | + $url = $this->getServer('HTTP_ORIGIN'); |
|
| 220 | + } |
|
| 218 | 221 | ob_start(); |
| 219 | 222 | header('Location: ' . $url); |
| 220 | 223 | ob_end_clean(); |
@@ -261,7 +264,9 @@ discard block |
||
| 261 | 264 | $host = $this->getServerName(); |
| 262 | 265 | $protocol = $protocol ? $this->getProtocol() : ''; |
| 263 | 266 | $url = ''; |
| 264 | - if (!empty($host) && !empty($protocol)) $url = $protocol . $host; |
|
| 267 | + if (!empty($host) && !empty($protocol)) { |
|
| 268 | + $url = $protocol . $host; |
|
| 269 | + } |
|
| 265 | 270 | return $url; |
| 266 | 271 | } |
| 267 | 272 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
| 218 | 218 | ob_start(); |
| 219 | - header('Location: ' . $url); |
|
| 219 | + header('Location: '.$url); |
|
| 220 | 220 | ob_end_clean(); |
| 221 | 221 | Security::getInstance()->updateSession(); |
| 222 | 222 | exit(_("Redireccionando...")); |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | $host = $this->getServerName(); |
| 262 | 262 | $protocol = $protocol ? $this->getProtocol() : ''; |
| 263 | 263 | $url = ''; |
| 264 | - if (!empty($host) && !empty($protocol)) $url = $protocol . $host; |
|
| 265 | - if(!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
|
| 266 | - $url .= ':' . $this->getServer('SERVER_PORT'); |
|
| 264 | + if (!empty($host) && !empty($protocol)) $url = $protocol.$host; |
|
| 265 | + if (!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
|
| 266 | + $url .= ':'.$this->getServer('SERVER_PORT'); |
|
| 267 | 267 | } |
| 268 | 268 | return $url; |
| 269 | 269 | } |
@@ -415,7 +415,7 @@ |
||
| 415 | 415 | * @param array $parts |
| 416 | 416 | * @param int $partLength |
| 417 | 417 | * |
| 418 | - * @return array |
|
| 418 | + * @return string[] |
|
| 419 | 419 | */ |
| 420 | 420 | private static function extractTsAndMod(array &$parts, $partLength) |
| 421 | 421 | { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | $this->user = (array_key_exists(self::USER_ID_TOKEN, $this->session)) ? unserialize($this->session[self::USER_ID_TOKEN]) : NULL; |
| 64 | 64 | $this->admin = (array_key_exists(self::ADMIN_ID_TOKEN, $this->session)) ? unserialize($this->session[self::ADMIN_ID_TOKEN]) : NULL; |
| 65 | - if(null === $this->admin) { |
|
| 65 | + if (null === $this->admin) { |
|
| 66 | 66 | $this->checkAdmin(); |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | public static function save($user) |
| 122 | 122 | { |
| 123 | 123 | $admins = array(); |
| 124 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 125 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
| 124 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 125 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
| 126 | 126 | } |
| 127 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
| 127 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
| 128 | 128 | $admins[$user['username']]['profile'] = $user['profile']; |
| 129 | 129 | |
| 130 | - return (FALSE !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
| 130 | + return (FALSE !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | public function getAdmins() |
| 162 | 162 | { |
| 163 | 163 | $admins = array(); |
| 164 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 165 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
| 164 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 165 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | return $admins; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | Logger::log('Checking admin session'); |
| 183 | 183 | if (!$this->authorized && !$this->checked) { |
| 184 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 184 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 185 | 185 | $request = Request::getInstance(); |
| 186 | 186 | $admins = $this->getAdmins(); |
| 187 | 187 | //Sacamos las credenciales de la petición |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | if (!empty($user) && !empty($admins[$user])) { |
| 194 | 194 | $auth = $admins[$user]['hash']; |
| 195 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
| 196 | - if($this->authorized) { |
|
| 195 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
| 196 | + if ($this->authorized) { |
|
| 197 | 197 | $this->admin = array( |
| 198 | 198 | 'alias' => $user, |
| 199 | 199 | 'profile' => $admins[$user]['profile'], |
@@ -416,12 +416,12 @@ discard block |
||
| 416 | 416 | $axis = 0; |
| 417 | 417 | $parts = array(); |
| 418 | 418 | try { |
| 419 | - $partLength = floor(strlen($token) / 10); |
|
| 420 | - for ($i = 0, $ct = ceil(strlen($token) / $partLength); $i < $ct; $i++) { |
|
| 419 | + $partLength = floor(strlen($token)/10); |
|
| 420 | + for ($i = 0, $ct = ceil(strlen($token)/$partLength); $i < $ct; $i++) { |
|
| 421 | 421 | $parts[] = substr($token, $axis, $partLength); |
| 422 | 422 | $axis += $partLength; |
| 423 | 423 | } |
| 424 | - } catch (\Exception $e) { |
|
| 424 | + }catch (\Exception $e) { |
|
| 425 | 425 | $partLength = 0; |
| 426 | 426 | } |
| 427 | 427 | |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | $decoded = NULL; |
| 462 | 462 | list($partLength, $parts) = self::extractTokenParts($token); |
| 463 | 463 | list($ts, $mod) = self::extractTsAndMod($parts, $partLength); |
| 464 | - $hashMod = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
| 464 | + $hashMod = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
| 465 | 465 | if (time() - (integer)$ts < 300 && $hashMod === $mod) { |
| 466 | 466 | $decoded = implode('', $parts); |
| 467 | 467 | } |
@@ -478,16 +478,16 @@ discard block |
||
| 478 | 478 | public static function generateToken($secret, $module = 'PSFS') |
| 479 | 479 | { |
| 480 | 480 | $ts = time(); |
| 481 | - $hashModule = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
| 481 | + $hashModule = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
| 482 | 482 | $hash = hash('sha256', $secret); |
| 483 | - $insert = floor(strlen($hash) / strlen($ts)); |
|
| 483 | + $insert = floor(strlen($hash)/strlen($ts)); |
|
| 484 | 484 | $j = 0; |
| 485 | 485 | $token = ''; |
| 486 | 486 | for ($i = 0, $ct = strlen($ts); $i < $ct; $i++) { |
| 487 | - $token .= substr($ts, $i, 1) . substr($hash, $j, $insert) . substr($hashModule, $i, 2); |
|
| 487 | + $token .= substr($ts, $i, 1).substr($hash, $j, $insert).substr($hashModule, $i, 2); |
|
| 488 | 488 | $j += $insert; |
| 489 | 489 | } |
| 490 | - $token .= substr($hash, ($insert * strlen($ts)), strlen($hash) - ($insert * strlen($ts))); |
|
| 490 | + $token .= substr($hash, ($insert*strlen($ts)), strlen($hash) - ($insert*strlen($ts))); |
|
| 491 | 491 | return $token; |
| 492 | 492 | } |
| 493 | 493 | |
@@ -125,8 +125,8 @@ |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * @param $header |
|
| 129 | - * @param null $content |
|
| 128 | + * @param string $header |
|
| 129 | + * @param string $content |
|
| 130 | 130 | * |
| 131 | 131 | * @return $this |
| 132 | 132 | */ |
@@ -177,7 +177,7 @@ |
||
| 177 | 177 | $this->url = NULL; |
| 178 | 178 | $this->params = array(); |
| 179 | 179 | $this->headers = array(); |
| 180 | - Logger::log("Context service for " . get_called_class() . " cleared!"); |
|
| 180 | + Logger::log("Context service for ".get_called_class()." cleared!"); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -135,9 +135,11 @@ |
||
| 135 | 135 | $cacheService->storeData($cacheFilename, $properties, Cache::JSON); |
| 136 | 136 | } |
| 137 | 137 | /** @var \ReflectionProperty $property */ |
| 138 | - if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { |
|
| 138 | + if (!empty($properties) && is_array($properties)) { |
|
| 139 | + foreach ($properties as $property => $class) { |
|
| 139 | 140 | $this->load($property, true, $class); |
| 140 | 141 | } |
| 142 | + } |
|
| 141 | 143 | $this->setLoaded(); |
| 142 | 144 | } else { |
| 143 | 145 | Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
| 23 | - Logger::log(get_class($this) . ' constructor invoked'); |
|
| 23 | + Logger::log(get_class($this).' constructor invoked'); |
|
| 24 | 24 | $this->init(); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -90,14 +90,14 @@ discard block |
||
| 90 | 90 | $calledClass = get_called_class(); |
| 91 | 91 | try { |
| 92 | 92 | $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
| 93 | - $setter = "set" . ucfirst($variable); |
|
| 93 | + $setter = "set".ucfirst($variable); |
|
| 94 | 94 | if (method_exists($calledClass, $setter)) { |
| 95 | 95 | $this->$setter($instance); |
| 96 | - } else { |
|
| 96 | + }else { |
|
| 97 | 97 | $this->$variable = $instance; |
| 98 | 98 | } |
| 99 | - } catch (\Exception $e) { |
|
| 100 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
| 99 | + }catch (\Exception $e) { |
|
| 100 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
| 101 | 101 | } |
| 102 | 102 | return $this; |
| 103 | 103 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | public function init() |
| 109 | 109 | { |
| 110 | 110 | if (!$this->isLoaded()) { |
| 111 | - $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . sha1(get_class($this)) . ".json"; |
|
| 111 | + $cacheFilename = "reflections".DIRECTORY_SEPARATOR.sha1(get_class($this)).".json"; |
|
| 112 | 112 | /** @var \PSFS\base\Cache $cacheService */ |
| 113 | 113 | $cacheService = Cache::getInstance(); |
| 114 | 114 | /** @var \PSFS\base\config\Config $configService */ |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | $this->load($property, true, $class); |
| 124 | 124 | } |
| 125 | 125 | $this->setLoaded(); |
| 126 | - } else { |
|
| 127 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
| 126 | + }else { |
|
| 127 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | if (!defined("LOG_DIR")) { |
| 16 | - Config::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 17 | - define("LOG_DIR", BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 16 | + Config::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
| 17 | + define("LOG_DIR", BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $config = Config::getInstance(); |
| 44 | 44 | $args = func_get_args(); |
| 45 | 45 | list($logger, $debug, $path) = $this->setup($config, $args); |
| 46 | - $this->stream = fopen($path . DIRECTORY_SEPARATOR . date("Ymd") . ".log", "a+"); |
|
| 46 | + $this->stream = fopen($path.DIRECTORY_SEPARATOR.date("Ymd").".log", "a+"); |
|
| 47 | 47 | $this->addPushLogger($logger, $debug, $config); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | private function createLoggerPath(Config $config) |
| 186 | 186 | { |
| 187 | 187 | $logger = $this->setLoggerName($config); |
| 188 | - $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m'); |
|
| 188 | + $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m'); |
|
| 189 | 189 | Config::createDir($path); |
| 190 | 190 | |
| 191 | 191 | return $path; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param string $msg |
| 89 | 89 | * @param array $context |
| 90 | 90 | * |
| 91 | - * @return bool |
|
| 91 | + * @return boolean|null |
|
| 92 | 92 | */ |
| 93 | 93 | public function debugLog($msg = '', $context = []) |
| 94 | 94 | { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Método que escribe un log de Error |
| 100 | - * @param $msg |
|
| 100 | + * @param string $msg |
|
| 101 | 101 | * @param array $context |
| 102 | 102 | * |
| 103 | 103 | * @return bool |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * Método que escribe un log de Warning |
| 112 | - * @param $msg |
|
| 112 | + * @param string $msg |
|
| 113 | 113 | * @param array $context |
| 114 | 114 | * @return bool |
| 115 | 115 | */ |
@@ -21,11 +21,11 @@ |
||
| 21 | 21 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
| 22 | 22 | |
| 23 | 23 | // filepath |
| 24 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
| 24 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
| 25 | 25 | if (!file_exists($abs_path)) { |
| 26 | - pre('→ ' . $class); |
|
| 27 | - pre('→ ' . $path); |
|
| 28 | - pre('→ ' . $abs_path); |
|
| 26 | + pre('→ '.$class); |
|
| 27 | + pre('→ '.$path); |
|
| 28 | + pre('→ '.$abs_path); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // require the file |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * Método que guarda en fichero los datos pasados |
| 124 | - * @param $path |
|
| 124 | + * @param string $path |
|
| 125 | 125 | * @param $data |
| 126 | 126 | * @param int $transform |
| 127 | 127 | * @param boolean $absolutePath |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * Método estático que revisa si se necesita cachear la respuesta de un servicio o no |
| 159 | - * @return integer|boolean |
|
| 159 | + * @return integer |
|
| 160 | 160 | */ |
| 161 | 161 | public static function needCache() |
| 162 | 162 | { |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | private function saveTextToFile($data, $path, $absolute = false) |
| 31 | 31 | { |
| 32 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
| 32 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
| 33 | 33 | $filename = basename($absolutePath); |
| 34 | 34 | Config::createDir(str_replace($filename, "", $absolutePath)); |
| 35 | 35 | if (false === file_put_contents($absolutePath, $data)) { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false) |
| 49 | 49 | { |
| 50 | 50 | $data = null; |
| 51 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
| 51 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
| 52 | 52 | if (file_exists($absolutePath)) { |
| 53 | 53 | $data = file_get_contents($absolutePath); |
| 54 | 54 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | private function hasExpiredCache($path, $expires = 300, $absolute = false) |
| 66 | 66 | { |
| 67 | - $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path; |
|
| 67 | + $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path; |
|
| 68 | 68 | $lasModificationDate = filemtime($absolutePath); |
| 69 | 69 | return ($lasModificationDate + $expires <= time()); |
| 70 | 70 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | break; |
| 88 | 88 | case Cache::GZIP: |
| 89 | 89 | // TODO implementar |
| 90 | - if(function_exists('gzuncompress')) { |
|
| 90 | + if (function_exists('gzuncompress')) { |
|
| 91 | 91 | $data = gzuncompress($data); |
| 92 | 92 | } |
| 93 | 93 | break; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $data = Cache::transformData($data, Cache::GZIP); |
| 113 | 113 | break; |
| 114 | 114 | case Cache::GZIP: |
| 115 | - if(function_exists('gzcompress')) { |
|
| 115 | + if (function_exists('gzcompress')) { |
|
| 116 | 116 | $data = gzcompress($data); |
| 117 | 117 | } |
| 118 | 118 | break; |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT) |
| 145 | 145 | { |
| 146 | 146 | $data = null; |
| 147 | - if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) { |
|
| 147 | + if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) { |
|
| 148 | 148 | if (null !== $function && $this->hasExpiredCache($path, $expires)) { |
| 149 | 149 | $data = call_user_func($function); |
| 150 | 150 | $this->storeData($path, $data, $transform); |
| 151 | - } else { |
|
| 151 | + }else { |
|
| 152 | 152 | $data = $this->getDataFromFile($path, $transform); |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $hash = ""; |
| 179 | 179 | $action = Security::getInstance()->getSessionKey("__CACHE__"); |
| 180 | 180 | if (null !== $action && $action["cache"] > 0) { |
| 181 | - $hash = $action["http"] . " " . $action["slug"]; |
|
| 181 | + $hash = $action["http"]." ".$action["slug"]; |
|
| 182 | 182 | } |
| 183 | 183 | return sha1($hash); |
| 184 | 184 | } |
@@ -32,18 +32,18 @@ |
||
| 32 | 32 | 'robots' => 'robots.txt', |
| 33 | 33 | ]; |
| 34 | 34 | foreach ($files as $templates => $filename) { |
| 35 | - $text = \PSFS\base\Template::getInstance()->dump("generator/html/". $templates . '.html.twig'); |
|
| 36 | - if(false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) { |
|
| 37 | - $output->writeln('Can\t create the file ' . $filename); |
|
| 38 | - } else { |
|
| 39 | - $output->writeln($filename . ' created successfully'); |
|
| 35 | + $text = \PSFS\base\Template::getInstance()->dump("generator/html/".$templates.'.html.twig'); |
|
| 36 | + if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) { |
|
| 37 | + $output->writeln('Can\t create the file '.$filename); |
|
| 38 | + }else { |
|
| 39 | + $output->writeln($filename.' created successfully'); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | //Export base locale translations |
| 44 | - if(!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
| 44 | + if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
| 45 | 45 | \PSFS\base\config\Config::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
| 46 | - \PSFS\Services\GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 46 | + \PSFS\Services\GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $output->writeln("Document root generado en ".$path); |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | use Symfony\Component\Console\Input\InputInterface; |
| 7 | 7 | use Symfony\Component\Console\Output\OutputInterface; |
| 8 | 8 | |
| 9 | - if (!isset($console)) $console = new Application(); |
|
| 9 | + if (!isset($console)) { |
|
| 10 | + $console = new Application(); |
|
| 11 | + } |
|
| 10 | 12 | $console |
| 11 | 13 | ->register('psfs:create:root') |
| 12 | 14 | ->setDefinition(array( |
@@ -16,7 +18,9 @@ discard block |
||
| 16 | 18 | ->setCode(function(InputInterface $input, OutputInterface $output) { |
| 17 | 19 | // Creates the html path |
| 18 | 20 | $path = $input->getArgument('path'); |
| 19 | - if (empty($path)) $path = WEB_DIR; |
|
| 21 | + if (empty($path)) { |
|
| 22 | + $path = WEB_DIR; |
|
| 23 | + } |
|
| 20 | 24 | \PSFS\base\config\Config::createDir($path); |
| 21 | 25 | $paths = array("js", "css", "img", "media", "font"); |
| 22 | 26 | foreach ($paths as $htmlPath) { |