mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 16:34:04 +00:00
Update MailConfigBootstrapper.php
while running in queue:work previosly it was not working made this changes now it is working fine
This commit is contained in:
parent
62624275cc
commit
0d83ba28d5
1 changed files with 22 additions and 2 deletions
|
|
@ -43,9 +43,19 @@ class MailConfigBootstrapper implements TenancyBootstrapper
|
|||
static::$credentialsMap = array_merge(static::$credentialsMap, static::$mapPresets[static::$mailer] ?? []);
|
||||
}
|
||||
|
||||
public function bootstrap(Tenant $tenant): void
|
||||
public function bootstrap(Tenant $tenant): void
|
||||
{
|
||||
// Forget the mail manager instance to clear the cached mailers
|
||||
// Clear the mail manager and its cached mailers
|
||||
if ($this->app->bound('mail.manager')) {
|
||||
$mailManager = $this->app->make('mail.manager');
|
||||
|
||||
// Clear all cached mailer instances
|
||||
$reflection = new \ReflectionClass($mailManager);
|
||||
$mailersProperty = $reflection->getProperty('mailers');
|
||||
$mailersProperty->setAccessible(true);
|
||||
$mailersProperty->setValue($mailManager, []);
|
||||
}
|
||||
|
||||
$this->app->forgetInstance('mail.manager');
|
||||
|
||||
$this->setConfig($tenant);
|
||||
|
|
@ -55,6 +65,16 @@ class MailConfigBootstrapper implements TenancyBootstrapper
|
|||
{
|
||||
$this->unsetConfig();
|
||||
|
||||
// Clear cached mailers again
|
||||
if ($this->app->bound('mail.manager')) {
|
||||
$mailManager = $this->app->make('mail.manager');
|
||||
|
||||
$reflection = new \ReflectionClass($mailManager);
|
||||
$mailersProperty = $reflection->getProperty('mailers');
|
||||
$mailersProperty->setAccessible(true);
|
||||
$mailersProperty->setValue($mailManager, []);
|
||||
}
|
||||
|
||||
$this->app->forgetInstance('mail.manager');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue