Compare commits
No commits in common. "11cb001cfda1bd5417340b53e267f231a610cd3c" and "378f27970e6a79f26f272d55f562a965fea06698" have entirely different histories.
11cb001cfd
...
378f27970e
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,4 +4,3 @@ vendor
|
||||
views_cache
|
||||
resources/upload
|
||||
resources/tmp
|
||||
composer.lock
|
3294
composer.lock
generated
Normal file
3294
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -46,16 +46,8 @@ class CgRouteCollector extends RouteCollector
|
||||
//TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $route
|
||||
* @param $handler
|
||||
* @param array $filters
|
||||
* @param array $additionalInfo
|
||||
* @return void
|
||||
*/
|
||||
public function console($route, $handler, array $filters = [], array $additionalInfo = []): void
|
||||
public function console($route, $handler, array $filters = []): void
|
||||
{
|
||||
$additionalInfo['type'] = "console";
|
||||
$this->addRoute(Route::GET, $route, $handler, $filters, $additionalInfo);
|
||||
$this->addRoute(Route::GET, $route, $handler, $filters);
|
||||
}
|
||||
}
|
@ -30,7 +30,8 @@ class TagModule extends Module
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
$this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations");
|
||||
$this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations/tag");
|
||||
$this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations/tag_entity");
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Тэги",
|
||||
@ -48,17 +49,11 @@ class TagModule extends Module
|
||||
OptionService::createFromParams("entity_tag_list", "{}", "Список тегов");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->menuService->removeItemBySlug("tag");
|
||||
$this->menuService->removeItemBySlug("tag_settings");
|
||||
|
||||
OptionService::removeOptionByKey("entity_tag_list");
|
||||
|
||||
$this->migrationService->rollbackAtPath("{KERNEL_APP_MODULES}/tag/migrations");
|
||||
}
|
||||
|
||||
public function formInputs(string $entity, Model $model = null): void
|
||||
|
@ -6,7 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public string $migration;
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@ -29,5 +28,4 @@ return new class extends Migration
|
||||
{
|
||||
\kernel\App::$db->schema->dropIfExists('tag');
|
||||
}
|
||||
|
||||
};
|
@ -6,8 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public string $migration;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
@ -64,11 +64,6 @@ class Out
|
||||
echo $this->get($string, $foreground_color, $background_color) . "\n";
|
||||
}
|
||||
|
||||
public function inLine($string, $foreground_color = null, $background_color = null): void
|
||||
{
|
||||
echo $this->get($string, $foreground_color, $background_color) ;
|
||||
}
|
||||
|
||||
// Returns all foreground color names
|
||||
public function getForegroundColors()
|
||||
{
|
||||
|
@ -16,23 +16,10 @@ class MainController extends ConsoleController
|
||||
|
||||
public function actionHelp(): void
|
||||
{
|
||||
$routs = App::$collector->getData()->getStaticRoutes();
|
||||
foreach ($routs as $rout => $data){
|
||||
$additionalInfo = $data['GET'][3];
|
||||
if (isset($additionalInfo['description']) and $additionalInfo['type'] === "console"){
|
||||
$this->out->inLine($rout . " - ", "green");
|
||||
$this->out->inLine($additionalInfo['description'], 'yellow');
|
||||
$this->out->r("");
|
||||
if (isset($additionalInfo['params'])){
|
||||
foreach ($additionalInfo['params'] as $key => $param){
|
||||
$this->out->inLine($key . " - ", "green");
|
||||
$this->out->inLine($param, 'yellow');
|
||||
$this->out->r("");
|
||||
}
|
||||
}
|
||||
$this->out->r("");
|
||||
}
|
||||
}
|
||||
// Debug::dd(App::$collector->getData());
|
||||
// foreach (App::$collector->getDescriptions() as $description){
|
||||
// $this->out->r($description, "green");
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public string $migration;
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
|
@ -1,26 +1,16 @@
|
||||
<?php
|
||||
|
||||
use kernel\App;
|
||||
use kernel\console\controllers\MigrationController;
|
||||
use Phroute\Phroute\RouteCollector;
|
||||
|
||||
App::$collector->console("hello", [\kernel\console\controllers\MainController::class, "indexAction"]);
|
||||
App::$collector->console("help", [\kernel\console\controllers\MainController::class, "actionHelp"]);
|
||||
|
||||
App::$collector->group(["prefix" => "migration"], callback: function (RouteCollector $router){
|
||||
App::$collector->console('run',
|
||||
[MigrationController::class, 'actionRun'],
|
||||
additionalInfo: ['description' => 'Запуск существующих миграций']
|
||||
);
|
||||
App::$collector->console('init',
|
||||
[MigrationController::class, 'actionCreateMigrationTable'],
|
||||
additionalInfo: ['description' => 'Инициализация миграций']
|
||||
);
|
||||
App::$collector->console('create',
|
||||
[MigrationController::class, 'actionCreate'],
|
||||
additionalInfo: ['description' => 'Создание миграции', 'params' => ['--name' => 'Название миграции', '--path' => 'Путь по которому будет создана миграция']]
|
||||
);
|
||||
App::$collector->console('rollback', [MigrationController::class, 'actionRollback']);
|
||||
App::$collector->console('run', [\kernel\console\controllers\MigrationController::class, 'actionRun']);
|
||||
App::$collector->console('init', [\kernel\console\controllers\MigrationController::class, 'actionCreateMigrationTable']);
|
||||
App::$collector->console('create', [\kernel\console\controllers\MigrationController::class, 'actionCreate']);
|
||||
App::$collector->console('rollback', [\kernel\console\controllers\MigrationController::class, 'actionRollback']);
|
||||
});
|
||||
|
||||
App::$collector->group(["prefix" => "admin-theme"], callback: function (RouteCollector $router){
|
||||
|
@ -12,7 +12,6 @@ use kernel\models\Option;
|
||||
use kernel\modules\module_shop_client\services\ModuleShopClientService;
|
||||
use kernel\modules\user\service\UserService;
|
||||
use kernel\Request;
|
||||
use kernel\services\MigrationService;
|
||||
use kernel\services\ModuleService;
|
||||
|
||||
class ModuleController extends AdminController
|
||||
|
@ -5,22 +5,17 @@ namespace kernel\modules\post;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\Module;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
use kernel\services\MigrationService;
|
||||
|
||||
class PostModule extends Module
|
||||
{
|
||||
public MenuService $menuService;
|
||||
public MigrationService $migrationService;
|
||||
public function __construct()
|
||||
{
|
||||
$this->menuService = new MenuService();
|
||||
$this->migrationService = new MigrationService();
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
$this->migrationService->runAtPath("{KERNEL_MODULES}/post/migrations");
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Посты",
|
||||
"url" => "/admin/post",
|
||||
@ -31,6 +26,5 @@ class PostModule extends Module
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->menuService->removeItemBySlug("post");
|
||||
$this->migrationService->rollbackAtPath("{KERNEL_MODULES}/post/migrations");
|
||||
}
|
||||
}
|
@ -6,8 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public string $migration;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
|
@ -36,25 +36,4 @@ class MigrationService
|
||||
}
|
||||
}
|
||||
|
||||
public function rollbackAtPath(string $path): void
|
||||
{
|
||||
$path = getConst($path);
|
||||
try {
|
||||
$filesystem = new Filesystem();
|
||||
$dmr = new DatabaseMigrationRepository(App::$db->capsule->getDatabaseManager(), 'migration');
|
||||
|
||||
$m = new Migrator($dmr, App::$db->capsule->getDatabaseManager(), $filesystem);
|
||||
|
||||
$migrationFiles = $m->getMigrationFiles($path);
|
||||
foreach ($migrationFiles as $name => $migrationFile){
|
||||
$migrationInstance = $filesystem->getRequire($migrationFile);
|
||||
$migrationInstance->migration = $name;
|
||||
$migrationInstance->down();
|
||||
$dmr->delete($migrationInstance);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception('Не удалось откатить миграции');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user