update rm deadcode
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Whmcs;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SyncAllCommand extends Command
|
||||
{
|
||||
protected $signature = 'whmcs:sync-all {--with-domain-sync : Also run domain:sync before whmcs:sync-domains}';
|
||||
|
||||
protected $description = 'Run every whmcs:sync-* command in dependency order (clients, products, orders, order-items, invoices, services, domains)';
|
||||
|
||||
private const STEPS = [
|
||||
['command' => 'whmcs:sync-clients', 'forceSync' => true],
|
||||
['command' => 'whmcs:sync-products', 'forceSync' => false],
|
||||
['command' => 'whmcs:sync-orders', 'forceSync' => true],
|
||||
['command' => 'whmcs:sync-order-items', 'forceSync' => false],
|
||||
['command' => 'whmcs:sync-invoices', 'forceSync' => true],
|
||||
['command' => 'whmcs:sync-services', 'forceSync' => false],
|
||||
['command' => 'whmcs:sync-domains', 'forceSync' => false],
|
||||
];
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
if ($this->option('with-domain-sync')) {
|
||||
$exitCode = $this->runStep('domain:sync', []);
|
||||
if ($exitCode !== self::SUCCESS) {
|
||||
return $exitCode;
|
||||
}
|
||||
} else {
|
||||
$this->warn('Skipping domain:sync — whmcs:sync-domains expects it to already be up to date. Pass --with-domain-sync to run it here.');
|
||||
}
|
||||
|
||||
foreach (self::STEPS as $step) {
|
||||
$arguments = $step['forceSync'] ? ['--sync' => true] : [];
|
||||
$exitCode = $this->runStep($step['command'], $arguments);
|
||||
|
||||
if ($exitCode !== self::SUCCESS) {
|
||||
return $exitCode;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('whmcs:sync-all completed successfully.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function runStep(string $command, array $arguments): int
|
||||
{
|
||||
$this->newLine();
|
||||
$this->info("==> {$command}");
|
||||
|
||||
$exitCode = $this->call($command, $arguments);
|
||||
|
||||
if ($exitCode !== self::SUCCESS) {
|
||||
$this->error("{$command} failed with exit code {$exitCode}; stopping.");
|
||||
}
|
||||
|
||||
return $exitCode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user