mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:44:04 +00:00
[4.x] Update ForgetTenantParameter-related comments (#1375)
* Update ForgetTenantParameter-related comments * Improve path id mw config docblock * improve docblocks --------- Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
parent
16ed2bcc8f
commit
81fff15afe
3 changed files with 31 additions and 16 deletions
|
|
@ -20,6 +20,8 @@ use Stancl\Tenancy\Resolvers\DomainTenantResolver;
|
|||
class TenancyServiceProvider extends ServiceProvider
|
||||
{
|
||||
public static Closure|null $configure = null;
|
||||
public static bool $registerForgetTenantParameterListener = true;
|
||||
public static bool $migrateFreshOverride = true;
|
||||
|
||||
/* Register services. */
|
||||
public function register(): void
|
||||
|
|
@ -104,9 +106,11 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
Commands\CreateUserWithRLSPolicies::class,
|
||||
]);
|
||||
|
||||
$this->app->extend(FreshCommand::class, function ($_, $app) {
|
||||
return new Commands\MigrateFreshOverride($app['migrator']);
|
||||
});
|
||||
if (static::$migrateFreshOverride) {
|
||||
$this->app->extend(FreshCommand::class, function ($_, $app) {
|
||||
return new Commands\MigrateFreshOverride($app['migrator']);
|
||||
});
|
||||
}
|
||||
|
||||
$this->publishes([
|
||||
__DIR__ . '/../assets/config.php' => config_path('tenancy.php'),
|
||||
|
|
@ -152,6 +156,14 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
Route::middlewareGroup('tenant', []);
|
||||
Route::middlewareGroup('central', []);
|
||||
|
||||
Event::listen(RouteMatched::class, ForgetTenantParameter::class);
|
||||
if (static::$registerForgetTenantParameterListener) {
|
||||
// Ideally, this listener would only be registered when kernel-level
|
||||
// path identification is used, however doing that check reliably
|
||||
// at this point in the lifecycle isn't feasible. For that reason,
|
||||
// rather than doing an "outer" check, we do an "inner" check within
|
||||
// that listener. That also means the listener needs to be registered
|
||||
// always. We allow for this to be controlled using a static property.
|
||||
Event::listen(RouteMatched::class, ForgetTenantParameter::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue