This commit is contained in:
Kavalar 2024-11-08 16:19:11 +03:00
parent 6cf35d5638
commit 44c94689c6
7 changed files with 33 additions and 84 deletions

View File

@ -1,38 +0,0 @@
<?php
namespace app\modules\tag;
use kernel\Module;
use kernel\modules\menu\service\MenuService;
use kernel\services\MigrationService;
class TagModule extends Module
{
public MenuService $menuService;
public MigrationService $migrationService;
public function __construct()
{
$this->menuService = new MenuService();
$this->migrationService = new MigrationService();
}
/**
* @throws \Exception
*/
public function init(): void
{
$this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations");
$this->menuService->createItem([
"label" => "Тэги",
"url" => "/admin/tag",
"slug" => "tag",
]);
}
public function deactivate(): void
{
$this->menuService->removeItemBySlug("tag");
}
}

View File

@ -1,8 +0,0 @@
<?php
namespace app\modules\tag\controllers;
class TagController extends \kernel\app_modules\tag\controllers\TagController
{
}

View File

@ -1,12 +0,0 @@
{
"name": "Tags",
"version": "0.1",
"author": "ITGuild",
"slug": "tag",
"description": "Tags module",
"app_module_path": "{APP}/modules/{slug}",
"module_class": "app\\modules\\tag\\TagModule",
"module_class_file": "{APP}/modules/tag/TagModule.php",
"routs": "routs/tag.php",
"dependence": "menu"
}

View File

@ -1,2 +0,0 @@
<?php
include KERNEL_APP_MODULES_DIR . "/tag/routs/tag.php";

View File

@ -11,7 +11,7 @@ class Files
{
if (is_dir($d1)) {
if (!file_exists($d2)){
$_d2 = mkdir($d2, permissions: 0755, recursive: true);
$_d2 = mkdir($d2, permissions: 0774, recursive: true);
if (!$_d2) {
return;
}
@ -74,6 +74,12 @@ class Files
$zip->close();
}
public static function uploadByUrl(string $url, string $uploadDir = RESOURCES_DIR . "/upload"): void
{
$file_name = basename($url);
file_put_contents($uploadDir . '/' . $file_name, file_get_contents($url));
}
private function recursiveAddFile(ZipArchive $zip, string $dir, string $folder = ''): void
{
$includes = new FilesystemIterator($dir);

View File

@ -7,6 +7,7 @@ use GuzzleHttp\Exception\GuzzleException;
use JetBrains\PhpStorm\NoReturn;
use kernel\AdminController;
use kernel\helpers\Debug;
use kernel\helpers\Files;
use kernel\modules\module_shop_client\services\ModuleShopClientService;
use kernel\Request;
use kernel\services\ModuleService;
@ -71,37 +72,40 @@ class ModuleShopClientController extends AdminController
*/
#[NoReturn] public function actionInstall(): void
{
$request = new Request();
$id = $request->get('id');
$token = $_ENV['MODULE_SHOP_TOKEN'];
Debug::prn(123);
$module = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/install/' . $id, [
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Accept' => 'application/itguild',
'sink' => RESOURCES_DIR . '/tmp/ms/some.itguild'
]
]);
$module = json_decode($module->getBody()->getContents(), true);
// Debug::dd(123);
$this->moduleService->installModule(RESOURCES_DIR . '/tmp/ms/some.igm');
$this->redirect('/admin/module_shop_client', 302);
// $request = new Request();
// $id = $request->get("id");
// $id = $request->get('id');
// $token = $_ENV['MODULE_SHOP_TOKEN'];
// $module_info = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/' . $id, [
// Debug::prn(123);
// $module = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/install/' . $id, [
// 'headers' => [
// 'Authorization' => 'Bearer ' . $token,
// 'Accept' => 'application/itguild',
// 'sink' => RESOURCES_DIR . '/tmp/ms/some.itguild'
// ]
// ]);
// $module_info = json_decode($module_info->getBody()->getContents(), true);
// Debug::dd($_ENV['MODULE_SHOP_URL'] . $module_info['path_to_archive']);
//
// $module = json_decode($module->getBody()->getContents(), true);
//// Debug::dd(123);
// $this->moduleService->installModule(RESOURCES_DIR . '/tmp/ms/some.igm');
// $this->redirect('/admin/module_shop_client', 302);
$request = new Request();
$id = $request->get("id");
$token = $_ENV['MODULE_SHOP_TOKEN'];
$module_info = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/' . $id, [
'headers' => [
'Authorization' => 'Bearer ' . $token,
]
]);
$module_info = json_decode($module_info->getBody()->getContents(), true);
Files::uploadByUrl($_ENV['MODULE_SHOP_URL'] . $module_info['path_to_archive'], RESOURCES_DIR . "/tmp/modules");
$this->moduleService->installModule('/resources/tmp/modules/' . basename($module_info['path_to_archive']));
// Debug::prn($this->moduleService->getErrors());
// Debug::dd(RESOURCES_DIR . '/tmp/modules/' . basename($module_info['path_to_archive']));
$this->moduleService->installModule(RESOURCES_DIR . '/tmp/ms/some.igm');
$this->redirect('/admin/module_shop_client', 302);
}
#[NoReturn] public function actionDelete(): void

View File

@ -421,7 +421,6 @@ class ModuleService
$dirs[] = getConst($p);
}
}
foreach ($dirs as $dir){
foreach (new DirectoryIterator($dir) as $fileInfo) {
if($fileInfo->isDot()) continue;