mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 22:54: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
|
class QueueTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
public $tenancyInitialized = false;
|
|
||||||
|
|
||||||
/** @var Repository */
|
/** @var Repository */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
|
@ -47,7 +45,7 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
||||||
$tenantId = $event->job->payload()['tenant_id'] ?? null;
|
$tenantId = $event->job->payload()['tenant_id'] ?? null;
|
||||||
|
|
||||||
// The job is not tenant-aware
|
// The job is not tenant-aware
|
||||||
if (! $tenantId) {
|
if (!$tenantId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +64,7 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
$bootstrapper = &$this;
|
$bootstrapper = &$this;
|
||||||
|
|
||||||
if (! $this->queue instanceof QueueFake) {
|
if (!$this->queue instanceof QueueFake) {
|
||||||
$this->queue->createPayloadUsing(function ($connection) use (&$bootstrapper) {
|
$this->queue->createPayloadUsing(function ($connection) use (&$bootstrapper) {
|
||||||
return $bootstrapper->getPayload($connection);
|
return $bootstrapper->getPayload($connection);
|
||||||
});
|
});
|
||||||
|
|
@ -75,17 +73,17 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
||||||
|
|
||||||
public function bootstrap(Tenant $tenant)
|
public function bootstrap(Tenant $tenant)
|
||||||
{
|
{
|
||||||
$this->tenancyInitialized = true;
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
public function revert()
|
public function revert()
|
||||||
{
|
{
|
||||||
$this->tenancyInitialized = false;
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPayload(string $connection)
|
public function getPayload(string $connection)
|
||||||
{
|
{
|
||||||
if (! $this->tenancyInitialized) {
|
if (! tenancy()->initialized) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue