@@ -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']; |
@@ -39,8 +39,8 @@ |
||
39 | 39 | "domain" => $this->getDomain(), |
40 | 40 | "listLabel" => Api::API_LIST_NAME_FIELD, |
41 | 41 | 'modelId' => Api::API_MODEL_KEY_FIELD, |
42 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
43 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
42 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
43 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
44 | 44 | ), [], ''); |
45 | 45 | } |
46 | 46 |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | public function render($template, array $vars = array(), $cookies = array(), $domain = null) |
42 | 42 | { |
43 | 43 | $vars['__menu__'] = $this->getMenu(); |
44 | - if(Config::getParam('profiling.enable')) { |
|
44 | + if (Config::getParam('profiling.enable')) { |
|
45 | 45 | $vars['__profiling__'] = Inspector::getStats(); |
46 | 46 | } |
47 | 47 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
48 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
48 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $vars['__menu__'] = $this->getMenu(); |
78 | 78 | $domain = $domain ?: $this->getDomain(); |
79 | - return $this->tpl->dump($domain . $template, $vars); |
|
79 | + return $this->tpl->dump($domain.$template, $vars); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function readFile($path) { |
25 | 25 | $data = false; |
26 | - if(file_exists($path)) { |
|
26 | + if (file_exists($path)) { |
|
27 | 27 | $data = @file_get_contents($path); |
28 | 28 | } |
29 | 29 | return $data; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @return string |
37 | 37 | */ |
38 | 38 | public static function generateHashFilename($verb, $slug, array $query = []) { |
39 | - return sha1(strtolower($verb) . ' ' . $slug . ' ' . strtolower(http_build_query($query))); |
|
39 | + return sha1(strtolower($verb).' '.$slug.' '.strtolower(http_build_query($query))); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | public static function generateCachePath(array $action, array $query = []) { |
48 | 48 | $class = GeneratorHelper::extractClassFromNamespace($action['class']); |
49 | 49 | $filename = self::generateHashFilename($action['http'], $action['slug'], $query); |
50 | - $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2); |
|
51 | - return $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR; |
|
50 | + $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2); |
|
51 | + return $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -29,7 +29,9 @@ |
||
29 | 29 | public static function load() { |
30 | 30 | if(!self::$loaded) { |
31 | 31 | defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true); |
32 | - if(class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
32 | + if(class_exists("\\PSFS\\base\\Logger")) { |
|
33 | + \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
34 | + } |
|
33 | 35 | self::$loaded = true; |
34 | 36 | } |
35 | 37 | } |
@@ -7,26 +7,26 @@ discard block |
||
7 | 7 | defined('JSON_THROW_ON_ERROR') or define('JSON_THROW_ON_ERROR', 4194304); |
8 | 8 | defined('JSON_INVALID_UTF8_SUBSTITUTE') or define('JSON_INVALID_UTF8_SUBSTITUTE', 2097152); |
9 | 9 | |
10 | -if(defined('PSFS_PHAR_DIR') && file_exists(PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php')) { |
|
11 | - @require_once PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php'; |
|
10 | +if (defined('PSFS_PHAR_DIR') && file_exists(PSFS_PHAR_DIR.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'environment.php')) { |
|
11 | + @require_once PSFS_PHAR_DIR.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'environment.php'; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | defined('SOURCE_DIR') or define('SOURCE_DIR', __DIR__); |
15 | 15 | if (preg_match('/vendor/', SOURCE_DIR)) { |
16 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
17 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
18 | -} else { |
|
19 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
20 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
16 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
17 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
18 | +}else { |
|
19 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
20 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
21 | 21 | } |
22 | -defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
23 | -defined('LOG_DIR') or define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
24 | -defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
25 | -defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
26 | -defined('WEB_DIR') or define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
27 | -defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
22 | +defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor'); |
|
23 | +defined('LOG_DIR') or define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
24 | +defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
25 | +defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
26 | +defined('WEB_DIR') or define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
27 | +defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
28 | 28 | |
29 | -if(!class_exists(bootstrap::class)) { |
|
29 | +if (!class_exists(bootstrap::class)) { |
|
30 | 30 | /** |
31 | 31 | * Class Bootstrap |
32 | 32 | * @package PSFS |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | class bootstrap { |
35 | 35 | protected static $loaded = false; |
36 | 36 | public static function load() { |
37 | - if(!self::$loaded) { |
|
37 | + if (!self::$loaded) { |
|
38 | 38 | defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true); |
39 | - if(class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
39 | + if (class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
40 | 40 | self::$loaded = true; |
41 | 41 | } |
42 | 42 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $this->success = $result; |
44 | 44 | $this->total = $total ?: (is_array($data) ? count($data) : 0); |
45 | 45 | $this->pages = $pages; |
46 | - if(null !== $message) { |
|
46 | + if (null !== $message) { |
|
47 | 47 | $this->message = $message; |
48 | 48 | } |
49 | 49 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | */ |
41 | 41 | public static function dropInstance() { |
42 | 42 | $class = static::class; |
43 | - if(isset(self::$instance[$class])) { |
|
43 | + if (isset(self::$instance[$class])) { |
|
44 | 44 | self::$instance[$class] = null; |
45 | 45 | } |
46 | 46 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function init() |
14 | 14 | { |
15 | - if(!Security::getInstance()->isLogged()) { |
|
15 | + if (!Security::getInstance()->isLogged()) { |
|
16 | 16 | throw new ApiException(t('Resource not authorized'), 401); |
17 | 17 | } |
18 | 18 | parent::init(); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | $this->con = Propel::getConnection($tableMap::DATABASE_NAME); |
34 | 34 | $this->con->beginTransaction(); |
35 | - if(method_exists($this->con, 'useDebug')) { |
|
35 | + if (method_exists($this->con, 'useDebug')) { |
|
36 | 36 | Logger::log('Enabling debug queries mode', LOG_INFO); |
37 | 37 | $this->con->useDebug(Config::getParam('debug')); |
38 | 38 | } |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected function closeTransaction($status) |
47 | 47 | { |
48 | - if(null !== $this->con) { |
|
48 | + if (null !== $this->con) { |
|
49 | 49 | $this->traceDebugQuery(); |
50 | 50 | if (null !== $this->con && $this->con->inTransaction()) { |
51 | 51 | if ($status === 200) { |
52 | 52 | $this->con->commit(); |
53 | - } else { |
|
53 | + }else { |
|
54 | 54 | $this->con->rollBack(); |
55 | 55 | } |
56 | 56 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | protected function traceDebugQuery() |
65 | 65 | { |
66 | 66 | if (Config::getParam('debug')) { |
67 | - Logger::log($this->con->getLastExecutedQuery()?: 'Empty Query', LOG_DEBUG); |
|
67 | + Logger::log($this->con->getLastExecutedQuery() ?: 'Empty Query', LOG_DEBUG); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | * Checks if the connection has a transaction initialized |
73 | 73 | */ |
74 | 74 | protected function checkTransaction() { |
75 | - if(null !== $this->con && !$this->con->inTransaction()) { |
|
75 | + if (null !== $this->con && !$this->con->inTransaction()) { |
|
76 | 76 | $this->con->beginTransaction(); |
77 | 77 | } |
78 | - if(null !== $this->con && $this->con->inTransaction()) { |
|
78 | + if (null !== $this->con && $this->con->inTransaction()) { |
|
79 | 79 | $this->items++; |
80 | 80 | } |
81 | - if($this->items >= Config::getParam('api.block.limit', 1000)) { |
|
81 | + if ($this->items >= Config::getParam('api.block.limit', 1000)) { |
|
82 | 82 | $this->con->commit(); |
83 | 83 | $this->items = 0; |
84 | 84 | } |