Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/ResourceObserver.php
Show All 9 Lines | class ResourceObserver | ||||
* Handle the resource "creating" event. | * Handle the resource "creating" event. | ||||
* | * | ||||
* @param \App\Resource $resource The resource | * @param \App\Resource $resource The resource | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function creating(Resource $resource): void | public function creating(Resource $resource): void | ||||
{ | { | ||||
$resource->status |= Resource::STATUS_NEW | Resource::STATUS_ACTIVE; | $resource->status |= Resource::STATUS_NEW; | ||||
} | } | ||||
/** | /** | ||||
* Handle the resource "created" event. | * Handle the resource "created" event. | ||||
* | * | ||||
* @param \App\Resource $resource The resource | * @param \App\Resource $resource The resource | ||||
* | * | ||||
* @return void | * @return void | ||||
Show All 13 Lines | public function created(Resource $resource) | ||||
'resource_id' => $resource->id, | 'resource_id' => $resource->id, | ||||
]; | ]; | ||||
} | } | ||||
// Note: Don't use setSettings() here to bypass ResourceSetting observers | // Note: Don't use setSettings() here to bypass ResourceSetting observers | ||||
// Note: This is a single multi-insert query | // Note: This is a single multi-insert query | ||||
$resource->settings()->insert(array_values($settings)); | $resource->settings()->insert(array_values($settings)); | ||||
// Create resource record in LDAP, then check if it is created in IMAP | // Create the resource in the backend (LDAP and IMAP) | ||||
$chain = [ | \App\Jobs\Resource\CreateJob::dispatch($resource->id); | ||||
new \App\Jobs\Resource\VerifyJob($resource->id), | |||||
]; | |||||
\App\Jobs\Resource\CreateJob::withChain($chain)->dispatch($resource->id); | |||||
} | } | ||||
/** | /** | ||||
* Handle the resource "deleted" event. | * Handle the resource "deleted" event. | ||||
* | * | ||||
* @param \App\Resource $resource The resource | * @param \App\Resource $resource The resource | ||||
* | * | ||||
* @return void | * @return void | ||||
Show All 31 Lines |