merge framework and kernel

This commit is contained in:
sunxyw
2023-03-07 23:07:52 +08:00
parent 8f43012a5c
commit 772288b517
19 changed files with 153 additions and 176 deletions

View File

@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace ZM\Bootstrap;
use ZM\Kernel;
use ZM\HasRuntimeInfo;
interface Bootstrapper
{
public function bootstrap(Kernel $kernel): void;
public function bootstrap(HasRuntimeInfo $runtime_info): void;
}

View File

@@ -6,11 +6,11 @@ namespace ZM\Bootstrap;
use OneBot\Exception\ExceptionHandler;
use ZM\Exception\Handler;
use ZM\Kernel;
use ZM\HasRuntimeInfo;
class HandleExceptions implements Bootstrapper
{
public function bootstrap(Kernel $kernel): void
public function bootstrap(HasRuntimeInfo $runtime_info): void
{
// 注册全局错误处理器
set_error_handler(function ($error_no, $error_msg, $error_file, $error_line) {

View File

@@ -8,11 +8,11 @@ use Dotenv\Dotenv;
use ZM\Config\Environment;
use ZM\Config\EnvironmentInterface;
use ZM\Config\ZMConfig;
use ZM\Kernel;
use ZM\HasRuntimeInfo;
class LoadConfiguration implements Bootstrapper
{
public function bootstrap(Kernel $kernel): void
public function bootstrap(HasRuntimeInfo $runtime_info): void
{
// TODO: 重新思考容器绑定的加载方式,从而在此处使用 interface
$env = resolve(Environment::class);
@@ -20,7 +20,7 @@ class LoadConfiguration implements Bootstrapper
new ZMConfig([
'source' => [
'paths' => [$kernel->getConfigDir()],
'paths' => [$runtime_info->getConfigDir()],
],
]);
}

View File

@@ -4,11 +4,11 @@ declare(strict_types=1);
namespace ZM\Bootstrap;
use ZM\Kernel;
use ZM\HasRuntimeInfo;
class LoadGlobalDefines implements Bootstrapper
{
public function bootstrap(Kernel $kernel): void
public function bootstrap(HasRuntimeInfo $runtime_info): void
{
require FRAMEWORK_ROOT_DIR . '/src/Globals/global_defines_framework.php';
}

View File

@@ -4,12 +4,12 @@ declare(strict_types=1);
namespace ZM\Bootstrap;
use ZM\Kernel;
use ZM\HasRuntimeInfo;
use ZM\Plugin\PluginManager;
class LoadPlugins implements Bootstrapper
{
public function bootstrap(Kernel $kernel): void
public function bootstrap(HasRuntimeInfo $runtime_info): void
{
// 先遍历下插件目录下是否有这个插件,没有这个插件则不能打包
$plugin_dir = config('global.plugin.load_dir', SOURCE_ROOT_DIR . '/plugins');

View File

@@ -5,11 +5,11 @@ declare(strict_types=1);
namespace ZM\Bootstrap;
use ZM\Event\EventProvider;
use ZM\Kernel;
use ZM\HasRuntimeInfo;
class RegisterEventProvider implements Bootstrapper
{
public function bootstrap(Kernel $kernel): void
public function bootstrap(HasRuntimeInfo $runtime_info): void
{
global $ob_event_provider;
$ob_event_provider = EventProvider::getInstance();

View File

@@ -4,17 +4,17 @@ declare(strict_types=1);
namespace ZM\Bootstrap;
use ZM\Kernel;
use ZM\HasRuntimeInfo;
use ZM\Logger\ConsoleLogger;
class RegisterLogger implements Bootstrapper
{
public function bootstrap(Kernel $kernel): void
public function bootstrap(HasRuntimeInfo $runtime_info): void
{
// 初始化 Logger
if (!ob_logger_registered()) {
// 如果没有注册过 Logger那么就初始化一个在启动框架前注册的话就不会初始化了可替换为其他 Logger
$logger = new ConsoleLogger($kernel->getLogLevel());
$logger = new ConsoleLogger($runtime_info->getLogLevel());
ob_logger_register($logger);
}
}

View File

@@ -4,11 +4,11 @@ declare(strict_types=1);
namespace ZM\Bootstrap;
use ZM\Kernel;
use ZM\HasRuntimeInfo;
class SetInternalTimezone implements Bootstrapper
{
public function bootstrap(Kernel $kernel): void
public function bootstrap(HasRuntimeInfo $runtime_info): void
{
date_default_timezone_set(config('global.runtime.timezone', 'UTC'));
}