mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:44:02 +00:00
Fire the newly created Tenancy events
This commit is contained in:
parent
b87c0bc9d2
commit
dd44a3406d
3 changed files with 10 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Stancl\Tenancy\Listeners;
|
||||
|
||||
use Stancl\Tenancy\Events\BootstrappingTenancy;
|
||||
use Stancl\Tenancy\Events\TenancyBootstrapped;
|
||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||
|
||||
|
|
@ -9,6 +10,8 @@ class BootstrapTenancy
|
|||
{
|
||||
public function handle(TenancyInitialized $event)
|
||||
{
|
||||
event(new BootstrappingTenancy($event->tenancy));
|
||||
|
||||
foreach ($event->tenancy->getBootstrappers() as $bootstrapper) {
|
||||
$bootstrapper->bootstrap($event->tenancy->tenant);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@
|
|||
namespace Stancl\Tenancy\Listeners;
|
||||
|
||||
use Stancl\Tenancy\Events\RevertedToCentralContext;
|
||||
use Stancl\Tenancy\Events\RevertingToCentralContext;
|
||||
use Stancl\Tenancy\Events\TenancyEnded;
|
||||
|
||||
class RevertToCentralContext
|
||||
{
|
||||
public function handle(TenancyEnded $event)
|
||||
{
|
||||
event(new RevertingToCentralContext($event->tenancy));
|
||||
|
||||
foreach ($event->tenancy->getBootstrappers() as $bootstrapper) {
|
||||
$bootstrapper->revert();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ class Tenancy
|
|||
return;
|
||||
}
|
||||
|
||||
event(new Events\InitializingTenancy($this));
|
||||
|
||||
$this->tenant = $tenant;
|
||||
|
||||
$this->initialized = true;
|
||||
|
|
@ -36,6 +38,8 @@ class Tenancy
|
|||
|
||||
public function end(): void
|
||||
{
|
||||
event(new Events\EndingTenancy($this));
|
||||
|
||||
if (! $this->initialized) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue