Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/GroupObserver.php
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | class GroupObserver | ||||
* Handle the group "restoring" event. | * Handle the group "restoring" event. | ||||
* | * | ||||
* @param \App\Group $group The group | * @param \App\Group $group The group | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function restoring(Group $group) | public function restoring(Group $group) | ||||
{ | { | ||||
// Make sure it's not DELETED/LDAP_READY/SUSPENDED anymore | // Reset the status | ||||
if ($group->isDeleted()) { | $group->status = Group::STATUS_NEW; | ||||
$group->status ^= Group::STATUS_DELETED; | |||||
} | |||||
if ($group->isLdapReady()) { | |||||
$group->status ^= Group::STATUS_LDAP_READY; | |||||
} | |||||
if ($group->isSuspended()) { | |||||
$group->status ^= Group::STATUS_SUSPENDED; | |||||
} | |||||
$group->status |= Group::STATUS_ACTIVE; | |||||
// Note: $group->save() is invoked between 'restoring' and 'restored' events | // Note: $group->save() is invoked between 'restoring' and 'restored' events | ||||
} | } | ||||
/** | /** | ||||
* Handle the group "restored" event. | * Handle the group "restored" event. | ||||
* | * | ||||
* @param \App\Group $group The group | * @param \App\Group $group The group | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function restored(Group $group) | public function restored(Group $group) | ||||
{ | { | ||||
\App\Jobs\Group\CreateJob::dispatch($group->id); | \App\Jobs\Group\CreateJob::dispatch($group->id); | ||||
} | } | ||||
} | } |