kernel pack some fix
This commit is contained in:
parent
4355651695
commit
bda9b03a9f
0
kernel/CgRouteCollector.php
Executable file → Normal file
0
kernel/CgRouteCollector.php
Executable file → Normal file
0
kernel/Database.php
Executable file → Normal file
0
kernel/Database.php
Executable file → Normal file
0
kernel/Header.php
Executable file → Normal file
0
kernel/Header.php
Executable file → Normal file
0
kernel/ResponseType.php
Executable file → Normal file
0
kernel/ResponseType.php
Executable file → Normal file
0
kernel/console/ConsoleApp.php
Executable file → Normal file
0
kernel/console/ConsoleApp.php
Executable file → Normal file
0
kernel/console/ConsoleController.php
Executable file → Normal file
0
kernel/console/ConsoleController.php
Executable file → Normal file
0
kernel/console/Out.php
Executable file → Normal file
0
kernel/console/Out.php
Executable file → Normal file
@ -69,7 +69,7 @@ class AdminConsoleController extends ConsoleController
|
||||
|
||||
$this->optionService->createFromParams(
|
||||
key: "active_modules",
|
||||
value: "{\"modules\":[\"admin_themes\", \"secure\"]}",
|
||||
value: "{\"modules\":[\"admin_themes\", \"secure\", \"user\"]}",
|
||||
label: "Активные модули"
|
||||
);
|
||||
$this->out->r("create option active_modules", "green");
|
||||
|
@ -4,7 +4,6 @@ namespace kernel\console\controllers;
|
||||
|
||||
use kernel\console\ConsoleController;
|
||||
use kernel\helpers\Files;
|
||||
use kernel\services\KernelService;
|
||||
use ZipArchive;
|
||||
|
||||
class KernelController extends ConsoleController
|
||||
@ -33,7 +32,10 @@ class KernelController extends ConsoleController
|
||||
$fileHelper = new Files();
|
||||
$fileHelper->copy_folder(KERNEL_DIR, $tmpKernelDirFull);
|
||||
|
||||
$fileHelper->pack($tmpKernelDirFull, RESOURCES_DIR . '/tmp/kernel/kernel.itguild');
|
||||
if (!is_dir(RESOURCES_DIR . '/tmp/kernel')) {
|
||||
mkdir(RESOURCES_DIR . '/tmp/kernel');
|
||||
}
|
||||
$fileHelper->pack($tmpKernelDirFull, RESOURCES_DIR . '/tmp/kernel/kernel.igk');
|
||||
|
||||
$fileHelper->recursiveRemoveDir($tmpKernelDirFull);
|
||||
$this->out->r("Ядро заархивировано", 'green');
|
||||
@ -61,6 +63,7 @@ class KernelController extends ConsoleController
|
||||
$tmpKernelDirFull = RESOURCES_DIR . '/tmp/kernel/' . $tmpKernelDir . "/";
|
||||
$zip->extractTo($tmpKernelDirFull);
|
||||
$zip->close();
|
||||
$this->files->recursiveRemoveKernelDir();
|
||||
$this->files->copy_folder($tmpKernelDirFull , ROOT_DIR . "/kernel");
|
||||
$this->files->recursiveRemoveDir($tmpKernelDirFull);
|
||||
$this->out->r('Ядро обновлено.', 'green');
|
||||
|
0
kernel/console/migrations/stubs/blank.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/blank.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/create.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/create.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/migration.create.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/migration.create.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/migration.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/migration.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/migration.update.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/migration.update.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/update.stub
Executable file → Normal file
0
kernel/console/migrations/stubs/update.stub
Executable file → Normal file
@ -43,6 +43,20 @@ class Files
|
||||
rmdir($dir);
|
||||
}
|
||||
|
||||
public function recursiveRemoveKernelDir(): void
|
||||
{
|
||||
$includes = new FilesystemIterator(KERNEL_DIR);
|
||||
foreach ($includes as $include) {
|
||||
if(is_dir($include) && !is_link($include) && $include->getFilename() !== 'app_modules') {
|
||||
$this->recursiveRemoveDir($include);
|
||||
}
|
||||
else {
|
||||
unlink($include);
|
||||
}
|
||||
}
|
||||
rmdir(KERNEL_DIR);
|
||||
}
|
||||
|
||||
public function pack(string $source, string $destination/*, bool $include_source = true*/): void
|
||||
{
|
||||
$zip = new ZipArchive();
|
||||
|
@ -5,8 +5,9 @@ use kernel\modules\admin_themes\controllers\AdminThemeController;
|
||||
use Phroute\Phroute\RouteCollector;
|
||||
|
||||
App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
App::$collector->group(["prefix" => "settings"], function (RouteCollector $router){
|
||||
App::$collector->group(["prefix" => "admin-themes"], function (RouteCollector $router){
|
||||
App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
|
||||
App::$collector->group(["prefix" => "settings"], function (RouteCollector $router) {
|
||||
App::$collector->group(["prefix" => "admin-themes"], function (RouteCollector $router) {
|
||||
App::$collector->get('/', [AdminThemeController::class, 'actionIndex']);
|
||||
App::$collector->get('/activate', [AdminThemeController::class, 'actionActivate']);
|
||||
// App::$collector->get('/create', [\kernel\modules\menu\controllers\MenuController::class, 'actionCreate']);
|
||||
@ -17,4 +18,5 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
// App::$collector->get('/delete/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionDelete']);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -4,6 +4,7 @@ use kernel\App;
|
||||
use Phroute\Phroute\RouteCollector;
|
||||
|
||||
App::$collector->group(["prefix" => "admin"], function (RouteCollector $router) {
|
||||
App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
|
||||
App::$collector->group(["prefix" => "option"], callback: function (RouteCollector $router) {
|
||||
App::$collector->get('/', [\kernel\modules\option\controllers\OptionController::class, 'actionIndex']);
|
||||
App::$collector->get('/page/{page_number}', [\kernel\modules\option\controllers\OptionController::class, 'actionIndex']);
|
||||
@ -14,4 +15,5 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router)
|
||||
App::$collector->any("/edit/{id}", [\kernel\modules\option\controllers\OptionController::class, 'actionEdit']);
|
||||
App::$collector->get('/delete/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionDelete']);
|
||||
});
|
||||
});
|
||||
});
|
@ -6,7 +6,8 @@ use Phroute\Phroute\RouteCollector;
|
||||
|
||||
|
||||
App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
App::$collector->group(["prefix" => "post"], function (RouteCollector $router){
|
||||
App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
|
||||
App::$collector->group(["prefix" => "post"], function (RouteCollector $router) {
|
||||
App::$collector->get('/', [\kernel\modules\post\controllers\PostController::class, 'actionIndex']);
|
||||
App::$collector->get('/page/{page_number}', [\kernel\modules\post\controllers\PostController::class, 'actionIndex']);
|
||||
App::$collector->get('/create', [\kernel\modules\post\controllers\PostController::class, 'actionCreate']);
|
||||
@ -16,6 +17,7 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
App::$collector->any("/edit/{id}", [\kernel\modules\post\controllers\PostController::class, 'actionEdit']);
|
||||
App::$collector->get('/delete/{id}', [\kernel\modules\post\controllers\PostController::class, 'actionDelete']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){
|
||||
|
37
kernel/modules/secure/controllers/SecureRestController.php
Normal file
37
kernel/modules/secure/controllers/SecureRestController.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\modules\secure\controllers;
|
||||
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\modules\user\models\User;
|
||||
use kernel\Request;
|
||||
use kernel\RestController;
|
||||
|
||||
class SecureRestController extends RestController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new User();
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionAuth(): void
|
||||
{
|
||||
$request = new Request();
|
||||
$data = $request->post();
|
||||
$model = $this->model->where(['username', $data['username']])->first();
|
||||
|
||||
$access_token = 123124312313;
|
||||
$access_token_expires_at = time() + 3600;
|
||||
|
||||
$model->{'access_token'} = $access_token;
|
||||
$model->{'access_token_expires_at'} = $access_token_expires_at;
|
||||
foreach ($model->getFillable() as $item){
|
||||
$model->{$item} = $data[$item] ?? null;
|
||||
}
|
||||
|
||||
$model->save();
|
||||
|
||||
$this->renderApi($this->model->toArray());
|
||||
}
|
||||
}
|
@ -4,5 +4,6 @@
|
||||
"author": "ITGuild",
|
||||
"slug": "secure",
|
||||
"description": "Secure module",
|
||||
"routs": "routs/secure.php"
|
||||
"routs": "routs/secure.php",
|
||||
"dependence": "user"
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use kernel\App;
|
||||
use kernel\CgRouteCollector;
|
||||
use Phroute\Phroute\RouteCollector;
|
||||
|
||||
App::$collector->filter("auth", [\kernel\middlewares\AuthMiddleware::class, "handler"]);
|
||||
@ -14,3 +15,8 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
App::$collector->post('/auth', [\kernel\modules\secure\controllers\SecureController::class, 'actionAuth']);
|
||||
});
|
||||
|
||||
App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){
|
||||
$router->rest("secure", [\kernel\modules\secure\controllers\SecureRestController::class]);
|
||||
App::$collector->post('/auth', [\kernel\modules\secure\controllers\SecureRestController::class, 'actionAuth']);
|
||||
});
|
||||
|
||||
|
@ -19,6 +19,8 @@ return new class extends Migration
|
||||
$table->string('email', 255);
|
||||
$table->string('password_hash', 255);
|
||||
$table->integer('role')->default(1);
|
||||
$table->string('access_token', 255)->nullable(true);
|
||||
$table->dateTime('access_token_expires_at')->nullable(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ use Phroute\Phroute\RouteCollector;
|
||||
|
||||
|
||||
App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
App::$collector->group(["prefix" => "user"], callback: function (RouteCollector $router){
|
||||
App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
|
||||
App::$collector->group(["prefix" => "user"], callback: function (RouteCollector $router) {
|
||||
App::$collector->get('/', [\kernel\modules\user\controllers\UserController::class, 'actionIndex']);
|
||||
App::$collector->get('/page/{page_number}', [\kernel\modules\user\controllers\UserController::class, 'actionIndex']);
|
||||
App::$collector->get('/create', [\kernel\modules\user\controllers\UserController::class, 'actionCreate']);
|
||||
@ -17,4 +18,5 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
App::$collector->any("/edit/{id}", [\kernel\modules\user\controllers\UserController::class, 'actionEdit']);
|
||||
App::$collector->get('/delete/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionDelete']);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user