This commit is contained in:
as2252258@163.com
2021-04-04 03:01:12 +08:00
parent 59a8974672
commit c7e059f104
14 changed files with 1230 additions and 1230 deletions
+2 -2
View File
@@ -71,7 +71,7 @@ class DatabasesProviders extends Providers
*/
public function createPool()
{
$databases = Config::get('databases', false, []);
$databases = Config::get('databases', []);
if (empty($databases)) {
return;
}
@@ -101,7 +101,7 @@ class DatabasesProviders extends Providers
*/
public function getConfig($name): mixed
{
return Config::get('databases.' . $name, true);
return Config::get('databases.' . $name,null, true);
}
+3 -3
View File
@@ -42,7 +42,7 @@ abstract class Callback extends HttpService
$this->eventNotify($message);
} catch (\Throwable $exception) {
$this->addError($exception,'throwable');
$this->addError($exception, 'throwable');
}
}
@@ -108,7 +108,7 @@ abstract class Callback extends HttpService
protected function system_mail($message)
{
try {
if (!Config::get('email.enable', false, false)) {
if (!Config::get('email.enable', false)) {
return;
}
$mail = $this->createEmail();
@@ -137,7 +137,7 @@ abstract class Callback extends HttpService
*/
protected function clearMysqlClient()
{
$databases = Config::get('databases', false, []);
$databases = Config::get('databases', []);
if (empty($databases)) {
return;
}
+1 -1
View File
@@ -535,7 +535,7 @@ class Request extends HttpService
$port = $sRequest->clientInfo['server_port'];
$rpc = Config::get('rpc.port', false, []);
$rpc = Config::get('rpc.port', []);
if ($rpc !== $port) {
$sRequest->headers->replace('request_uri', 'add-port-listen/port_' . $port);
$sRequest->headers->replace('request_method', 'listen');
+1 -1
View File
@@ -61,7 +61,7 @@ class Router extends HttpService implements RouterInterface
*/
public function init()
{
$this->dir = Config::get('http.namespace', false, $this->dir);
$this->dir = Config::get('http.namespace', $this->dir);
}
+3 -3
View File
@@ -125,7 +125,7 @@ class Server extends HttpService
*/
public function start(): string
{
$configs = Config::get('servers', true);
$configs = Config::get('servers', [], true);
$baseServer = $this->initCore($configs);
if (!$baseServer) {
@@ -295,7 +295,7 @@ class Server extends HttpService
*/
private function create($config): mixed
{
$settings = Config::get('settings', false, []);
$settings = Config::get('settings', []);
if (!isset($this->server[$config['type']])) {
throw new Exception('Unknown server type(' . $config['type'] . ').');
}
@@ -372,7 +372,7 @@ class Server extends HttpService
*/
private function startRpcService(): Packet|Websocket|Receive|Http|null
{
$rpcService = Config::get('rpc.enable', false, []);
$rpcService = Config::get('rpc.enable', []);
if ($rpcService === true) {
/** @var Service $service */
$service = Snowflake::app()->get('rpc-service');
+1 -1
View File
@@ -36,7 +36,7 @@ class KafkaProviders extends Providers
return;
}
$kafkaServers = Config::get('kafka.servers', false, []);
$kafkaServers = Config::get('kafka.servers', []);
if (empty($kafkaServers)) {
return;
}
+1 -1
View File
@@ -156,7 +156,7 @@ abstract class BaseApplication extends Service
foreach ($config as $key => $value) {
Config::set($key, $value);
}
if ($storage = Config::get('storage', false, 'storage')) {
if ($storage = Config::get('storage', 'storage')) {
if (!str_contains($storage, APP_PATH)) {
$storage = APP_PATH . $storage . '/';
}
+1 -1
View File
@@ -53,7 +53,7 @@ class Config extends Component
* @return mixed
* @throws
*/
public static function get($key, $try = FALSE, $default = null): mixed
public static function get($key, $default = null, $try = FALSE): mixed
{
$instance = Snowflake::app()->getConfig()->getData();
if (!str_contains($key, '.')) {
+2 -2
View File
@@ -40,8 +40,8 @@ abstract class Pool extends Component
*/
private function getClearTime(): array
{
$firstClear = Config::get('pool.clear.start', false, 600);
$lastClear = Config::get('pool.clear.end', false, 300);
$firstClear = Config::get('pool.clear.start', 600);
$lastClear = Config::get('pool.clear.end', 300);
return [$firstClear, $lastClear];
}
+1 -1
View File
@@ -112,7 +112,7 @@ class Logger extends Component
*/
public function print_r($message, $method = '')
{
$debug = Config::get('debug', false, ['enable' => false]);
$debug = Config::get('debug', ['enable' => false]);
if ((bool)$debug['enable'] === true) {
if (!is_callable($debug['callback'] ?? null, true)) {
return;
+3 -3
View File
@@ -86,9 +86,9 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY=
if (!Config::has('ssl.public') || !Config::has('ssl.private')) {
return;
}
$this->public = Config::get('ssl.public', false, $this->public);
$this->private = Config::get('ssl.private', false, $this->private);
$this->timeout = Config::get('ssl.timeout', false, 7200);
$this->public = Config::get('ssl.public', $this->public);
$this->private = Config::get('ssl.private', $this->private);
$this->timeout = Config::get('ssl.timeout', 7200);
}
+1 -1
View File
@@ -41,7 +41,7 @@ class ServerInotify extends Process
public function onHandler(\Swoole\Process $process): void
{
set_error_handler([$this, 'onErrorHandler']);
$this->dirs = Config::get('inotify', false, [APP_PATH]);
$this->dirs = Config::get('inotify', [APP_PATH]);
if (extension_loaded('inotify')) {
$this->inotify = inotify_init();
$this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE;
+1 -1
View File
@@ -172,7 +172,7 @@ class Snowflake
public static function getStoragePath(): string
{
$default = APP_PATH . 'storage' . DIRECTORY_SEPARATOR;
$path = Config::get('storage', false, $default);
$path = Config::get('storage', $default);
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
+1 -1
View File
@@ -616,7 +616,7 @@ if (!function_exists('name')) {
return;
}
$name = Config::get('id', false, 'system') . '[' . $pid . ']';
$name = Config::get('id', 'system') . '[' . $pid . ']';
if (!empty($prefix)) {
$name .= '.' . $prefix;
}