mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 13:14:05 +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:
parent
198f34f5e1
commit
62c8bb0f67
2 changed files with 26 additions and 5 deletions
15
src/TenancyMailManager.php
Normal file
15
src/TenancyMailManager.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,16 +4,17 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy;
|
namespace Stancl\Tenancy;
|
||||||
|
|
||||||
|
use Illuminate\Mail\MailManager;
|
||||||
|
use Stancl\Tenancy\Enums\LogMode;
|
||||||
use Illuminate\Cache\CacheManager;
|
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\Domain;
|
||||||
use Stancl\Tenancy\Contracts\Tenant;
|
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\Events\Contracts\TenancyEvent;
|
||||||
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
|
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
|
||||||
|
use Illuminate\Database\Console\Migrations\FreshCommand;
|
||||||
|
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
||||||
|
|
||||||
class TenancyServiceProvider extends ServiceProvider
|
class TenancyServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
@ -69,6 +70,11 @@ class TenancyServiceProvider extends ServiceProvider
|
||||||
return new Commands\Seed($app['db']);
|
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) {
|
$this->app->bind('globalCache', function ($app) {
|
||||||
return new CacheManager($app);
|
return new CacheManager($app);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue