Split detail page contracts

This commit is contained in:
2026-03-19 19:04:28 +01:00
parent f6046c9168
commit 522705dd33
21 changed files with 729 additions and 121 deletions

43
bin/console Executable file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
* CoreCore CLI — single entry point for all commands.
*
* Usage:
* php bin/console <command> [arguments] [options]
* php bin/console list
*
* Examples:
* php bin/console module:sync
* php bin/console module:deactivate addressbook --confirm
* php bin/console scheduler:run
* php bin/console doctor
*/
require_once __DIR__ . '/../vendor/autoload.php';
use MintyPHP\Console\ConsoleApplication;
use MintyPHP\Console\Commands\DoctorCommand;
use MintyPHP\Console\Commands\Module\AssetsSyncCommand;
use MintyPHP\Console\Commands\Module\BuildCommand;
use MintyPHP\Console\Commands\Module\DeactivateCommand;
use MintyPHP\Console\Commands\Module\MigrateCommand;
use MintyPHP\Console\Commands\Module\PermissionsSyncCommand;
use MintyPHP\Console\Commands\Module\RuntimeSyncCommand;
use MintyPHP\Console\Commands\Scheduler\RunCommand;
$app = new ConsoleApplication();
$app->register(new RuntimeSyncCommand());
$app->register(new MigrateCommand());
$app->register(new PermissionsSyncCommand());
$app->register(new BuildCommand());
$app->register(new AssetsSyncCommand());
$app->register(new DeactivateCommand());
$app->register(new RunCommand());
$app->register(new DoctorCommand());
exit($app->run($argv));

View File

@@ -15,70 +15,75 @@ declare(strict_types=1);
require_once __DIR__ . '/module-cli-bootstrap.php';
$exitCode = moduleCliRunStep('module-deactivate', static function (): int {
global $argv;
function moduleDeactivateRun(): int
{
return moduleCliRunStep('module-deactivate', static function (): int {
global $argv;
$moduleId = $argv[1] ?? '';
$flags = array_slice($argv, 2);
$moduleId = $argv[1] ?? '';
$flags = array_slice($argv, 2);
if ($moduleId === '' || $moduleId === '--help') {
fwrite(STDOUT, "Usage: php bin/module-deactivate.php <module-id> --confirm|--dry-run\n");
return $moduleId === '--help' ? 0 : 1;
}
if ($moduleId === '' || $moduleId === '--help') {
fwrite(STDOUT, "Usage: php bin/module-deactivate.php <module-id> --confirm|--dry-run\n");
return $moduleId === '--help' ? 0 : 1;
}
$confirm = in_array('--confirm', $flags, true);
$dryRun = in_array('--dry-run', $flags, true);
$confirm = in_array('--confirm', $flags, true);
$dryRun = in_array('--dry-run', $flags, true);
if (!$confirm && !$dryRun) {
fwrite(STDERR, "Error: must pass --confirm to execute or --dry-run to validate.\n");
return 1;
}
if (!$confirm && !$dryRun) {
fwrite(STDERR, "Error: must pass --confirm to execute or --dry-run to validate.\n");
return 1;
}
$projectRoot = moduleCliProjectRoot();
$manifestFile = $projectRoot . '/modules/' . $moduleId . '/module.php';
$projectRoot = moduleCliProjectRoot();
$manifestFile = $projectRoot . '/modules/' . $moduleId . '/module.php';
if (!is_file($manifestFile)) {
fwrite(STDERR, "Error: module manifest not found at {$manifestFile}\n");
return 1;
}
if (!is_file($manifestFile)) {
fwrite(STDERR, "Error: module manifest not found at {$manifestFile}\n");
return 1;
}
$raw = require $manifestFile;
if (!is_array($raw)) {
fwrite(STDERR, "Error: manifest must return an array.\n");
return 1;
}
$raw = require $manifestFile;
if (!is_array($raw)) {
fwrite(STDERR, "Error: manifest must return an array.\n");
return 1;
}
$manifest = \MintyPHP\App\Module\ModuleManifest::fromArray($raw, dirname($manifestFile));
$manifest = \MintyPHP\App\Module\ModuleManifest::fromArray($raw, dirname($manifestFile));
$handlerClass = $manifest->deactivationHandler;
if ($handlerClass === null) {
fwrite(STDOUT, "Module '{$moduleId}' has no deactivation_handler declared — nothing to do.\n");
$handlerClass = $manifest->deactivationHandler;
if ($handlerClass === null) {
fwrite(STDOUT, "Module '{$moduleId}' has no deactivation_handler declared — nothing to do.\n");
return 0;
}
if (!class_exists($handlerClass)) {
fwrite(STDERR, "Error: deactivation handler class '{$handlerClass}' not found.\n");
return 1;
}
$handler = new $handlerClass();
if (!$handler instanceof \MintyPHP\App\Module\Contracts\ModuleDeactivationHandler) {
fwrite(STDERR, "Error: '{$handlerClass}' does not implement ModuleDeactivationHandler.\n");
return 1;
}
if ($dryRun) {
fwrite(STDOUT, "Dry-run: handler '{$handlerClass}' found and valid for module '{$moduleId}'.\n");
return 0;
}
fwrite(STDOUT, "Running deactivation handler for module '{$moduleId}'...\n");
$container = app();
$handler->deactivate($container);
fwrite(STDOUT, "Deactivation handler for module '{$moduleId}' completed.\n");
return 0;
}
});
}
if (!class_exists($handlerClass)) {
fwrite(STDERR, "Error: deactivation handler class '{$handlerClass}' not found.\n");
return 1;
}
$handler = new $handlerClass();
if (!$handler instanceof \MintyPHP\App\Module\Contracts\ModuleDeactivationHandler) {
fwrite(STDERR, "Error: '{$handlerClass}' does not implement ModuleDeactivationHandler.\n");
return 1;
}
if ($dryRun) {
fwrite(STDOUT, "Dry-run: handler '{$handlerClass}' found and valid for module '{$moduleId}'.\n");
return 0;
}
fwrite(STDOUT, "Running deactivation handler for module '{$moduleId}'...\n");
$container = app();
$handler->deactivate($container);
fwrite(STDOUT, "Deactivation handler for module '{$moduleId}' completed.\n");
return 0;
});
exit($exitCode);
if (PHP_SAPI === 'cli' && realpath((string) ($_SERVER['SCRIPT_FILENAME'] ?? '')) === __FILE__) {
exit(moduleDeactivateRun());
}