1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 15:34:04 +00:00

Replace MailManager singleton with an instance of a custom mail manager which always resolves the mailers instead of getting the cached ones

This commit is contained in:
lukinovec 2022-10-31 15:01:58 +01:00
parent 198f34f5e1
commit 62c8bb0f67
2 changed files with 26 additions and 5 deletions

View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy;
use Illuminate\Mail\MailManager;
class TenancyMailManager extends MailManager
{
protected function get($name)
{
return $this->resolve($name);
}
}

View file

@ -4,16 +4,17 @@ declare(strict_types=1);
namespace Stancl\Tenancy;
use Illuminate\Mail\MailManager;
use Stancl\Tenancy\Enums\LogMode;
use Illuminate\Cache\CacheManager;
use Illuminate\Database\Console\Migrations\FreshCommand;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
use Stancl\Tenancy\Contracts\Domain;
use Stancl\Tenancy\Contracts\Tenant;
use Stancl\Tenancy\Enums\LogMode;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Stancl\Tenancy\Events\Contracts\TenancyEvent;
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
use Illuminate\Database\Console\Migrations\FreshCommand;
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
class TenancyServiceProvider extends ServiceProvider
{
@ -69,6 +70,11 @@ class TenancyServiceProvider extends ServiceProvider
return new Commands\Seed($app['db']);
});
// Use custom mail manager that resolves the mailers instead of getting the cached mailers from the $mailers property
$this->app->extend(MailManager::class, function (MailManager $mailManager) {
return new TenancyMailManager($this->app);
});
$this->app->bind('globalCache', function ($app) {
return new CacheManager($app);
});