Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/DomainsController.php
Show First 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | class DomainsController extends RelationController | ||||
} | } | ||||
/** | /** | ||||
* Execute (synchronously) specified step in a domain setup process. | * Execute (synchronously) specified step in a domain setup process. | ||||
* | * | ||||
* @param \App\Domain $domain Domain object | * @param \App\Domain $domain Domain object | ||||
* @param string $step Step identifier (as in self::statusInfo()) | * @param string $step Step identifier (as in self::statusInfo()) | ||||
* | * | ||||
* @return bool True if the execution succeeded, False otherwise | * @return bool|null True if the execution succeeded, False if not, Null when | ||||
* the job has been sent to the worker (result unknown) | |||||
*/ | */ | ||||
public static function execProcessStep(Domain $domain, string $step): bool | public static function execProcessStep(Domain $domain, string $step): ?bool | ||||
{ | { | ||||
try { | try { | ||||
switch ($step) { | switch ($step) { | ||||
case 'domain-ldap-ready': | case 'domain-ldap-ready': | ||||
// Domain not in LDAP, create it | // Use worker to do the job | ||||
if (!$domain->isLdapReady()) { | \App\Jobs\Domain\CreateJob::dispatch($domain->id); | ||||
LDAP::createDomain($domain); | return null; | ||||
$domain->status |= Domain::STATUS_LDAP_READY; | |||||
$domain->save(); | |||||
} | |||||
return $domain->isLdapReady(); | |||||
case 'domain-verified': | case 'domain-verified': | ||||
// Domain existence not verified | // Domain existence not verified | ||||
$domain->verify(); | $domain->verify(); | ||||
return $domain->isVerified(); | return $domain->isVerified(); | ||||
case 'domain-confirmed': | case 'domain-confirmed': | ||||
// Domain ownership confirmation | // Domain ownership confirmation | ||||
Show All 10 Lines |