2026-03-19 19:04:28 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MintyPHP\Console\Commands\Module;
|
|
|
|
|
|
|
|
|
|
use MintyPHP\Console\Command;
|
|
|
|
|
|
|
|
|
|
final class DeactivateCommand extends Command
|
|
|
|
|
{
|
|
|
|
|
public function name(): string
|
|
|
|
|
{
|
|
|
|
|
return 'module:deactivate';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function description(): string
|
|
|
|
|
{
|
2026-03-19 19:16:36 +01:00
|
|
|
return 'Run a module\'s deactivation handler';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function usage(): string
|
|
|
|
|
{
|
|
|
|
|
return <<<'USAGE'
|
|
|
|
|
Usage: php bin/console module:deactivate <module-id> [options]
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
--confirm Execute the deactivation handler
|
|
|
|
|
--dry-run Validate the handler without executing
|
|
|
|
|
|
|
|
|
|
The module does not need to be in the enabled list.
|
|
|
|
|
USAGE;
|
2026-03-19 19:04:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute(array $args, array $options): int
|
|
|
|
|
{
|
|
|
|
|
$moduleId = $args[0] ?? '';
|
|
|
|
|
if ($moduleId === '') {
|
2026-03-19 19:16:36 +01:00
|
|
|
fwrite(STDERR, $this->usage() . "\n");
|
2026-03-19 19:04:28 +01:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rebuild global argv for the underlying script
|
|
|
|
|
global $argv;
|
|
|
|
|
$argv = ['module-deactivate.php', $moduleId];
|
|
|
|
|
if ($options['confirm'] ?? false) {
|
|
|
|
|
$argv[] = '--confirm';
|
|
|
|
|
}
|
|
|
|
|
if ($options['dry-run'] ?? false) {
|
|
|
|
|
$argv[] = '--dry-run';
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-19 19:16:36 +01:00
|
|
|
$this->requireBinScript('module-deactivate.php');
|
2026-03-19 19:04:28 +01:00
|
|
|
|
|
|
|
|
return moduleDeactivateRun();
|
|
|
|
|
}
|
|
|
|
|
}
|