mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 20:34:03 +00:00
Queue bootstrapper use tenancy() state
This commit is contained in:
parent
057ddcbbae
commit
34d3189d61
1 changed files with 5 additions and 7 deletions
|
|
@ -15,8 +15,6 @@ use Stancl\Tenancy\Contracts\Tenant;
|
|||
|
||||
class QueueTenancyBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
public $tenancyInitialized = false;
|
||||
|
||||
/** @var Repository */
|
||||
protected $config;
|
||||
|
||||
|
|
@ -47,7 +45,7 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
|||
$tenantId = $event->job->payload()['tenant_id'] ?? null;
|
||||
|
||||
// The job is not tenant-aware
|
||||
if (! $tenantId) {
|
||||
if (!$tenantId) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +64,7 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
|||
{
|
||||
$bootstrapper = &$this;
|
||||
|
||||
if (! $this->queue instanceof QueueFake) {
|
||||
if (!$this->queue instanceof QueueFake) {
|
||||
$this->queue->createPayloadUsing(function ($connection) use (&$bootstrapper) {
|
||||
return $bootstrapper->getPayload($connection);
|
||||
});
|
||||
|
|
@ -75,17 +73,17 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
|||
|
||||
public function bootstrap(Tenant $tenant)
|
||||
{
|
||||
$this->tenancyInitialized = true;
|
||||
//
|
||||
}
|
||||
|
||||
public function revert()
|
||||
{
|
||||
$this->tenancyInitialized = false;
|
||||
//
|
||||
}
|
||||
|
||||
public function getPayload(string $connection)
|
||||
{
|
||||
if (! $this->tenancyInitialized) {
|
||||
if (! tenancy()->initialized) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue