1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 12:54:05 +00:00

Rename bootstrappers (#40)

* SessionTenancyBootstrapper -> DatabaseSessionBootstrapper

* FortifyRouteTenancyBootstrapper -> FortifyRouteBootstrapper

* BatchTenancyBootstrapper -> JobBatchBootstrapper

* ScoutTenancyBootstrapper -> ScoutPrefixBootstrapper, also fix logic and remove todo

* MailTenancyBootstrapper -> MailConfigBootstrapper

* PrefixCacheTenancyBootstrapper -> CacheTenancyBootstrapper

* remove todo

* improve config file
This commit is contained in:
Samuel Štancl 2024-03-28 03:18:23 +01:00 committed by GitHub
parent 0c11f29c19
commit 9f94505cb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 82 additions and 82 deletions

View file

@ -10,14 +10,11 @@ use Illuminate\Support\Facades\Cache;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
// todo@rename some bootstrappers end in TenancyBootstrapper and others don't - make this consistent or make the difference clear
/**
* todo@name rename?
*
* Separate tenant cache using tagging.
*
* This is the legacy approach. Some things, like dependency injection, won't work properly with this bootstrapper.
* PrefixCacheTenancyBootstrapper is the recommended bootstrapper for cache separation.
* CacheTenancyBootstrapper is the recommended bootstrapper for cache separation.
*/
class CacheTagsBootstrapper implements TenancyBootstrapper
{

View file

@ -12,7 +12,10 @@ use Illuminate\Support\Facades\Cache;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
class PrefixCacheTenancyBootstrapper implements TenancyBootstrapper
/**
* Makes cache tenant-aware by applying a prefix.
*/
class CacheTenancyBootstrapper implements TenancyBootstrapper
{
protected string|null $originalPrefix = null;
public static array $tenantCacheStores = []; // E.g. ['redis']

View file

@ -11,15 +11,13 @@ use Illuminate\Session\SessionManager;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
// todo@rename this should be DB-specific
/**
* This resets the database connection used by the database session driver.
*
* It runs each time tenancy is initialized or ended.
* That way the session driver always uses the current DB connection.
*/
class SessionTenancyBootstrapper implements TenancyBootstrapper
class DatabaseSessionBootstrapper implements TenancyBootstrapper
{
public function __construct(
protected Repository $config,

View file

@ -16,7 +16,7 @@ use Stancl\Tenancy\Resolvers\PathTenantResolver;
*
* Works with path and query string identification.
*/
class FortifyRouteTenancyBootstrapper implements TenancyBootstrapper
class FortifyRouteBootstrapper implements TenancyBootstrapper
{
/**
* Make Fortify actions redirect to custom routes.

View file

@ -8,7 +8,7 @@ use Illuminate\Contracts\Config\Repository;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
class ScoutTenancyBootstrapper implements TenancyBootstrapper
class ScoutPrefixBootstrapper implements TenancyBootstrapper
{
protected ?string $originalScoutPrefix = null;
@ -19,7 +19,7 @@ class ScoutTenancyBootstrapper implements TenancyBootstrapper
public function bootstrap(Tenant $tenant): void
{
if ($this->originalScoutPrefix !== null) {
if ($this->originalScoutPrefix === null) {
$this->originalScoutPrefix = $this->config->get('scout.prefix');
}

View file

@ -10,8 +10,10 @@ use Illuminate\Database\DatabaseManager;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
// todo add docblock
class BatchTenancyBootstrapper implements TenancyBootstrapper
/**
* Adds support for running queued tenant jobs in batches.
*/
class JobBatchBootstrapper implements TenancyBootstrapper
{
/**
* The previous database connection instance.

View file

@ -9,7 +9,7 @@ use Illuminate\Foundation\Application;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
class MailTenancyBootstrapper implements TenancyBootstrapper
class MailConfigBootstrapper implements TenancyBootstrapper
{
/**
* Tenant properties to be mapped to config (similarly to the TenantConfig feature).

View file

@ -44,7 +44,6 @@ class Tenancy
return;
}
// TODO: Remove this (so that runForMultiple() is still performant) and make the FS bootstrapper work either way
if ($this->initialized) {
$this->end();
}