@@ -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(); |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | $array['fields'][] = $field->__toArray(); |
| 27 | 27 | } |
| 28 | 28 | $array['actions'] = []; |
| 29 | - foreach($this->actions as $action) { |
|
| 29 | + foreach ($this->actions as $action) { |
|
| 30 | 30 | $array['actions'][] = $action->__toArray(); |
| 31 | 31 | } |
| 32 | 32 | return $array; |
@@ -1,14 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace PSFS\base\types; |
| 3 | 3 | |
| 4 | -use PSFS\base\exception\RouterException; |
|
| 5 | -use PSFS\base\Request; |
|
| 6 | -use PSFS\base\Router; |
|
| 7 | 4 | use PSFS\base\Singleton; |
| 8 | 5 | use PSFS\base\types\helpers\GeneratorHelper; |
| 9 | 6 | use PSFS\base\types\interfaces\ControllerInterface; |
| 10 | 7 | use PSFS\base\types\traits\JsonTrait; |
| 11 | -use PSFS\base\types\traits\OutputTrait; |
|
| 12 | 8 | use PSFS\base\types\traits\RouteTrait; |
| 13 | 9 | |
| 14 | 10 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $vars['__menu__'] = $this->getMenu(); |
| 42 | 42 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
| 43 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
| 43 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $vars['__menu__'] = $this->getMenu(); |
| 73 | 73 | $domain = $domain ?: $this->getDomain(); |
| 74 | - return $this->tpl->dump($domain . $template, $vars); |
|
| 74 | + return $this->tpl->dump($domain.$template, $vars); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -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 | } |
@@ -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 |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $use /= 1024; |
| 36 | 36 | break; |
| 37 | 37 | case "MBytes": |
| 38 | - $use /= (1024 * 1024); |
|
| 38 | + $use /= (1024*1024); |
|
| 39 | 39 | break; |
| 40 | 40 | case "Bytes": |
| 41 | 41 | default: |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | Logger::log('Added handlers for errors'); |
| 62 | 62 | //Warning & Notice handler |
| 63 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
| 63 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
| 64 | 64 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]); |
| 65 | 65 | return true; |
| 66 | 66 | }, E_ALL | E_STRICT); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | Logger::log('Initializing stats (mem + ts)'); |
| 75 | 75 | if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) { |
| 76 | 76 | $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT']; |
| 77 | - } else { |
|
| 77 | + }else { |
|
| 78 | 78 | $this->ts = Request::getInstance()->getTs(); |
| 79 | 79 | } |
| 80 | 80 | $this->mem = memory_get_usage(); |
@@ -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 | } |
@@ -69,16 +69,16 @@ |
||
| 69 | 69 | if (!Request::getInstance()->isFile()) { |
| 70 | 70 | return $this->router->execute($this->actualUri); |
| 71 | 71 | } |
| 72 | - } else { |
|
| 72 | + }else { |
|
| 73 | 73 | return ConfigController::getInstance()->config(); |
| 74 | 74 | } |
| 75 | - } catch (AdminCredentialsException $a) { |
|
| 75 | + }catch (AdminCredentialsException $a) { |
|
| 76 | 76 | return UserController::showAdminManager(); |
| 77 | - } catch (SecurityException $s) { |
|
| 77 | + }catch (SecurityException $s) { |
|
| 78 | 78 | return $this->security->notAuthorized($this->actualUri); |
| 79 | - } catch (RouterException $r) { |
|
| 79 | + }catch (RouterException $r) { |
|
| 80 | 80 | return $this->router->httpNotFound($r); |
| 81 | - } catch (\Exception $e) { |
|
| 81 | + }catch (\Exception $e) { |
|
| 82 | 82 | return $this->dumpException($e); |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $dump = ''; |
| 105 | 105 | try { |
| 106 | 106 | $dump = $this->tpl->render($tpl, $vars); |
| 107 | - } catch (\Exception $e) { |
|
| 107 | + }catch (\Exception $e) { |
|
| 108 | 108 | Logger::log($e->getMessage(), LOG_ERR); |
| 109 | 109 | } |
| 110 | 110 | return $dump; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | public function regenerateTemplates() |
| 132 | 132 | { |
| 133 | 133 | $this->generateTemplatesCache(); |
| 134 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true); |
|
| 134 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true); |
|
| 135 | 135 | $translations = []; |
| 136 | 136 | if (is_array($domains)) { |
| 137 | 137 | $translations = $this->parsePathTranslations($domains); |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | // force compilation |
| 154 | 154 | if ($file->isFile()) { |
| 155 | 155 | try { |
| 156 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
| 157 | - } catch (\Exception $e) { |
|
| 156 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
| 157 | + }catch (\Exception $e) { |
|
| 158 | 158 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | 'existsFlash' => TemplateFunctions::EXISTS_FLASH_FUNCTION, |
| 215 | 215 | 'getFlash' => TemplateFunctions::GET_FLASH_FUNCTION, |
| 216 | 216 | ]; |
| 217 | - foreach($functions as $name => $function) { |
|
| 217 | + foreach ($functions as $name => $function) { |
|
| 218 | 218 | $this->addTemplateFunction($name, $function); |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | private function loadDomains() |
| 235 | 235 | { |
| 236 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
| 236 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
| 237 | 237 | if (null !== $domains) { |
| 238 | 238 | foreach ($domains as $domain => $paths) { |
| 239 | 239 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | { |
| 249 | 249 | $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath()); |
| 250 | 250 | $this->tpl = new \Twig_Environment($loader, array( |
| 251 | - 'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig', |
|
| 251 | + 'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig', |
|
| 252 | 252 | 'debug' => (bool)$this->debug, |
| 253 | 253 | 'auto_reload' => Config::getParam('twig.auto_reload', TRUE), |
| 254 | 254 | )); |