mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 18:44:04 +00:00
Update bootstrapper
This commit is contained in:
parent
7666e23b8f
commit
0c60cc309d
1 changed files with 19 additions and 4 deletions
|
|
@ -24,6 +24,17 @@ use Stancl\Tenancy\Resolvers\PathTenantResolver;
|
||||||
*/
|
*/
|
||||||
class UrlGeneratorBootstrapper implements TenancyBootstrapper
|
class UrlGeneratorBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the tenant route parameter should get added to the defaults of the TenancyUrlGenerator.
|
||||||
|
*
|
||||||
|
* This is preferrable with path identification since the tenant parameter is passed to the tenant routes automatically,
|
||||||
|
* even with integrations like the Ziggy route() helper.
|
||||||
|
*
|
||||||
|
* With query strig identification, this essentialy has no effect because URL::defaults() works only for route paramaters,
|
||||||
|
* not for query strings.
|
||||||
|
*/
|
||||||
|
public static bool $addTenantParameterToDefaults = true;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected Application $app,
|
protected Application $app,
|
||||||
protected UrlGenerator $originalUrlGenerator,
|
protected UrlGenerator $originalUrlGenerator,
|
||||||
|
|
@ -54,10 +65,14 @@ class UrlGeneratorBootstrapper implements TenancyBootstrapper
|
||||||
$this->app['config']->get('app.asset_url'),
|
$this->app['config']->get('app.asset_url'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$defaultParameters = array_merge(
|
$defaultParameters = $this->originalUrlGenerator->getDefaultParameters();
|
||||||
$this->originalUrlGenerator->getDefaultParameters(),
|
|
||||||
[PathTenantResolver::tenantParameterName() => $tenant->getTenantKey()]
|
if (static::$addTenantParameterToDefaults) {
|
||||||
);
|
$defaultParameters = array_merge(
|
||||||
|
$defaultParameters,
|
||||||
|
[PathTenantResolver::tenantParameterName() => $tenant->getTenantKey()]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$newGenerator->defaults($defaultParameters);
|
$newGenerator->defaults($defaultParameters);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue