kernel version 0.1.4
This commit is contained in:
parent
64dad0aaf9
commit
3e178f6633
@ -7,6 +7,7 @@ namespace kernel;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\modules\user\models\User;
|
||||
use kernel\services\ModuleService;
|
||||
use kernel\services\ThemeService;
|
||||
use Phroute\Phroute\Dispatcher;
|
||||
|
||||
class App
|
||||
@ -24,6 +25,8 @@ class App
|
||||
|
||||
public ModuleService $moduleService;
|
||||
|
||||
public ThemeService $themeService;
|
||||
|
||||
public static Database $db;
|
||||
|
||||
public function run(): void
|
||||
@ -39,6 +42,7 @@ class App
|
||||
public function load(): static
|
||||
{
|
||||
$this->moduleService = new ModuleService();
|
||||
$this->themeService = new ThemeService();
|
||||
App::$collector = new CgRouteCollector();
|
||||
$this->setRouting();
|
||||
|
||||
@ -53,6 +57,10 @@ class App
|
||||
foreach ($modules_routs as $rout){
|
||||
include "$rout";
|
||||
}
|
||||
$activeTheme = getConst($this->themeService->getActiveTheme());
|
||||
if (!empty($activeTheme)){
|
||||
include $activeTheme . "/" . $this->themeService->getThemeRout($activeTheme);
|
||||
}
|
||||
}
|
||||
|
||||
public static function create(): App
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace kernel;
|
||||
|
||||
use kernel\helpers\Debug;
|
||||
|
||||
class CgView
|
||||
{
|
||||
public string $viewPath = '';
|
||||
@ -61,6 +63,13 @@ class CgView
|
||||
private function createContent(string $viewFile, array $data = []): false|string
|
||||
{
|
||||
ob_start();
|
||||
|
||||
if ($this->varToLayout){
|
||||
foreach ($this->varToLayout as $key => $datum) {
|
||||
${"$key"} = $datum;
|
||||
}
|
||||
}
|
||||
|
||||
$view = $this;
|
||||
foreach ($data as $key => $datum) {
|
||||
${"$key"} = $datum;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Kernel",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.4",
|
||||
"author": "ITGuild",
|
||||
"slug": "kernel",
|
||||
"type": "kernel",
|
||||
|
41
kernel/services/ThemeService.php
Normal file
41
kernel/services/ThemeService.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\services;
|
||||
|
||||
use kernel\models\Option;
|
||||
|
||||
class ThemeService
|
||||
{
|
||||
protected Option $option;
|
||||
protected string $active_theme = "";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->option = new Option();
|
||||
$this->findActiveAdminTheme();
|
||||
}
|
||||
|
||||
public function findActiveAdminTheme(): void
|
||||
{
|
||||
$model = $this->option::where("key", "active_theme")->first();
|
||||
$this->active_theme = $model->value;
|
||||
}
|
||||
|
||||
public function getActiveTheme(): string
|
||||
{
|
||||
return $this->active_theme;
|
||||
}
|
||||
|
||||
public function getThemeRout(string $path)
|
||||
{
|
||||
if (file_exists($path . "/manifest.json")){
|
||||
$manifest = json_decode(file_get_contents($path . "/manifest.json"), true);
|
||||
if ($manifest['routs']) {
|
||||
return $manifest['routs'];
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user