mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 20:54:03 +00:00
remove tenant_unaware_features key and use static function
This commit is contained in:
parent
250f927d33
commit
be6b2f8248
9 changed files with 35 additions and 9 deletions
|
|
@ -8,4 +8,6 @@ namespace Stancl\Tenancy\Contracts;
|
|||
interface Feature
|
||||
{
|
||||
public function bootstrap(): void;
|
||||
|
||||
public static function alwaysBootstrap(): bool;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,9 @@ class CrossDomainRedirect implements Feature
|
|||
return $this;
|
||||
});
|
||||
}
|
||||
|
||||
public static function alwaysBootstrap(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,4 +32,9 @@ class TelescopeTags implements Feature
|
|||
return $tags;
|
||||
});
|
||||
}
|
||||
|
||||
public static function alwaysBootstrap(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,4 +69,9 @@ class TenantConfig implements Feature
|
|||
$this->config->set($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function alwaysBootstrap(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,9 @@ class UniversalRoutes implements Feature
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function alwaysBootstrap(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,4 +50,9 @@ class UserImpersonation implements Feature
|
|||
|
||||
return redirect($token->redirect_url);
|
||||
}
|
||||
|
||||
public static function alwaysBootstrap(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,12 +29,16 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
|
||||
$this->app->resolving(Tenancy::class, function (Tenancy $tenancy, $app) {
|
||||
foreach ($this->app['config']['tenancy.features'] ?? [] as $feature) {
|
||||
$this->app[$feature]->bootstrap();
|
||||
if (! $feature::alwaysBootstrap()) { // avoid bootstrapping already bootstrapped features
|
||||
$this->app[$feature]->bootstrap();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
foreach ($this->app['config']['tenancy.tenant_unaware_features'] ?? [] as $feature) {
|
||||
$this->app[$feature]->bootstrap();
|
||||
foreach ($this->app['config']['tenancy.features'] ?? [] as $feature) {
|
||||
if ($feature::alwaysBootstrap()) {
|
||||
$this->app[$feature]->bootstrap();
|
||||
}
|
||||
}
|
||||
|
||||
// Make it possible to inject the current tenant by typehinting the Tenant contract.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue