mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 08:35:35 +08:00
merge framework and kernel
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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()],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user