Files
breadcrumb-the-shire/lib/Console/Commands/Module/DeactivateCommand.php

55 lines
1.3 KiB
PHP
Raw Normal View History

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
{
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 === '') {
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';
}
$this->requireBinScript('module-deactivate.php');
2026-03-19 19:04:28 +01:00
return moduleDeactivateRun();
}
}