Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Domain/StatusCommand.php
Show All 22 Lines | class StatusCommand extends Command | ||||
/** | /** | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$domain = $this->getDomain($this->argument('domain')); | $domain = $this->getDomain($this->argument('domain'), true); | ||||
if (!$domain) { | if (!$domain) { | ||||
$this->error("Domain not found."); | $this->error("Domain not found."); | ||||
return 1; | return 1; | ||||
} | } | ||||
$statuses = [ | $statuses = [ | ||||
'active' => Domain::STATUS_ACTIVE, | 'active' => Domain::STATUS_ACTIVE, | ||||
'suspended' => Domain::STATUS_SUSPENDED, | 'suspended' => Domain::STATUS_SUSPENDED, | ||||
'deleted' => Domain::STATUS_DELETED, | 'deleted' => Domain::STATUS_DELETED, | ||||
'ldapReady' => Domain::STATUS_LDAP_READY, | |||||
'verified' => Domain::STATUS_VERIFIED, | |||||
'confirmed' => Domain::STATUS_CONFIRMED, | 'confirmed' => Domain::STATUS_CONFIRMED, | ||||
'verified' => Domain::STATUS_VERIFIED, | |||||
'ldapReady' => Domain::STATUS_LDAP_READY, | |||||
]; | ]; | ||||
$domain_state = []; | |||||
foreach ($statuses as $text => $bit) { | foreach ($statuses as $text => $bit) { | ||||
$func = 'is' . \ucfirst($text); | if ($text == 'deleted') { | ||||
$status = $domain->trashed(); | |||||
} else { | |||||
$status = $domain->{'is' . \ucfirst($text)}(); | |||||
} | |||||
$this->info(sprintf("%d %s: %s", $bit, $text, $domain->$func())); | if ($status) { | ||||
$domain_state[] = "$text ($bit)"; | |||||
} | |||||
} | } | ||||
$this->info("In total: {$domain->status}"); | $this->info("Status ({$domain->status}): " . \implode(', ', $domain_state)); | ||||
} | } | ||||
} | } |