1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 14:14:04 +00:00

Add more events

This commit is contained in:
Samuel Štancl 2020-05-17 17:42:09 +02:00
parent ed96aee669
commit b87c0bc9d2
22 changed files with 165 additions and 52 deletions

View file

@ -6,6 +6,9 @@ use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Stancl\JobPipeline\JobPipeline;
use Stancl\Tenancy\Events\BootstrappingTenancy;
use Stancl\Tenancy\Events\CreatingDomain;
use Stancl\Tenancy\Events\CreatingTenant;
use Stancl\Tenancy\Listeners\BootstrapTenancy;
use Stancl\Tenancy\Listeners\RevertToCentralContext;
use Stancl\Tenancy\Events\DatabaseCreated;
@ -13,11 +16,18 @@ use Stancl\Tenancy\Events\DatabaseDeleted;
use Stancl\Tenancy\Events\DatabaseMigrated;
use Stancl\Tenancy\Events\DatabaseRolledBack;
use Stancl\Tenancy\Events\DatabaseSeeded;
use Stancl\Tenancy\Events\DeletingDomain;
use Stancl\Tenancy\Events\DeletingTenant;
use Stancl\Tenancy\Events\DomainCreated;
use Stancl\Tenancy\Events\DomainDeleted;
use Stancl\Tenancy\Events\DomainSaved;
use Stancl\Tenancy\Events\DomainUpdated;
use Stancl\Tenancy\Events\EndingTenancy;
use Stancl\Tenancy\Events\InitializingTenancy;
use Stancl\Tenancy\Events\RevertedToCentralContext;
use Stancl\Tenancy\Events\RevertingToCentralContext;
use Stancl\Tenancy\Events\SavingDomain;
use Stancl\Tenancy\Events\SavingTenant;
use Stancl\Tenancy\Events\TenancyBootstrapped;
use Stancl\Tenancy\Events\TenancyEnded;
use Stancl\Tenancy\Events\TenancyInitialized;
@ -25,6 +35,8 @@ use Stancl\Tenancy\Events\TenantCreated;
use Stancl\Tenancy\Events\TenantDeleted;
use Stancl\Tenancy\Events\TenantSaved;
use Stancl\Tenancy\Events\TenantUpdated;
use Stancl\Tenancy\Events\UpdatingDomain;
use Stancl\Tenancy\Events\UpdatingTenant;
use Stancl\Tenancy\Jobs\CreateDatabase;
use Stancl\Tenancy\Jobs\DeleteDatabase;
use Stancl\Tenancy\Jobs\MigrateDatabase;
@ -35,6 +47,9 @@ class TenancyServiceProvider extends ServiceProvider
public function events()
{
return [
// Tenant events
CreatingTenant::class => [],
TenantCreated::class => [
JobPipeline::make([
CreateDatabase::class,
@ -48,8 +63,11 @@ class TenancyServiceProvider extends ServiceProvider
return $event->tenant;
})->shouldBeQueued(false), // `false` by default, but you probably want to make this `true` for production.
],
SavingTenant::class => [],
TenantSaved::class => [],
UpdatingTenant::class => [],
TenantUpdated::class => [],
DeletingTenant::class => [],
TenantDeleted::class => [
JobPipeline::make([
DeleteDatabase::class,
@ -58,26 +76,39 @@ class TenancyServiceProvider extends ServiceProvider
})->shouldBeQueued(false), // `false` by default, but you probably want to make this `true` for production.
],
// Domain events
CreatingDomain::class => [],
DomainCreated::class => [],
SavingDomain::class => [],
DomainSaved::class => [],
UpdatingDomain::class => [],
DomainUpdated::class => [],
DeletingDomain::class => [],
DomainDeleted::class => [],
// Database events
// todo: let -ing events cacnel the operations
DatabaseCreated::class => [],
DatabaseMigrated::class => [],
DatabaseSeeded::class => [],
DatabaseRolledBack::class => [],
DatabaseDeleted::class => [],
// Tenancy events
// todo: let -ing events cacnel the operations
InitializingTenancy::class => [],
TenancyInitialized::class => [
BootstrapTenancy::class,
],
EndingTenancy::class => [],
TenancyEnded::class => [
RevertToCentralContext::class,
],
BootstrappingTenancy::class => [],
TenancyBootstrapped::class => [],
RevertingToCentralContext::class => [],
RevertedToCentralContext::class => [],
];
}