Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/DomainObserver.php
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | class DomainObserver | ||||
* Handle the domain "restoring" event. | * Handle the domain "restoring" event. | ||||
* | * | ||||
* @param \App\Domain $domain The domain. | * @param \App\Domain $domain The domain. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function restoring(Domain $domain) | public function restoring(Domain $domain) | ||||
{ | { | ||||
// Make sure it's not DELETED/LDAP_READY/SUSPENDED | // Reset the status | ||||
if ($domain->isDeleted()) { | $domain->status = Domain::STATUS_NEW; | ||||
$domain->status ^= Domain::STATUS_DELETED; | |||||
} | |||||
if ($domain->isLdapReady()) { | |||||
$domain->status ^= Domain::STATUS_LDAP_READY; | |||||
} | |||||
if ($domain->isSuspended()) { | |||||
$domain->status ^= Domain::STATUS_SUSPENDED; | |||||
} | |||||
if ($domain->isConfirmed() && $domain->isVerified()) { | |||||
$domain->status |= Domain::STATUS_ACTIVE; | |||||
} | |||||
// Note: $domain->save() is invoked between 'restoring' and 'restored' events | // Note: $domain->save() is invoked between 'restoring' and 'restored' events | ||||
mollekopf: So should we perhaps just do a $domain->status = Domain::STATUS_NEW? Or what do we intend to… | |||||
Done Inline ActionsI suppose the initial idea was to preserve CONFIRMED and VERIFIED state, but now I think every restored domain should get NEW state only. This is not a show stopper for this diff. machniak: I suppose the initial idea was to preserve CONFIRMED and VERIFIED state, but now I think every… | |||||
} | } | ||||
/** | /** | ||||
* Handle the domain "restored" event. | * Handle the domain "restored" event. | ||||
* | * | ||||
* @param \App\Domain $domain The domain. | * @param \App\Domain $domain The domain. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function restored(Domain $domain) | public function restored(Domain $domain) | ||||
{ | { | ||||
// Create the domain in LDAP again | // Create the domain in LDAP again | ||||
\App\Jobs\Domain\CreateJob::dispatch($domain->id); | \App\Jobs\Domain\CreateJob::dispatch($domain->id); | ||||
} | } | ||||
} | } |
So should we perhaps just do a $domain->status = Domain::STATUS_NEW? Or what do we intend to preserve?