mirror of
https://github.com/archtechx/tenancy.git
synced 2026-03-22 02:04:04 +00:00
[4.x] Make URL::temporarySignedRoute() respect the bypass parameter (#1438)
Using `URL::temporarySignedRoute()` in tenant context with `UrlGeneratorBootstrapper` enabled doesn't work the same as `route()`. The bypass parameter doesn't actually bypass the route name prefixing. `route()` is called in the `parent::temporarySignedRoute()` call, and because the bypass parameter is removed before calling `parent::temporarySignedRoute()`, the underlying `route()` call doesn't get the bypass parameter and it ends up attempting to generate URL for a route with the name prefixed with 'tenant.'. This PR adds the bypass parameter back after `prepareRouteInputs()`, so that `parent::temporarySignedRoute()` receives it, and the underlying `route()` call respects it. Also added basic tests for the `URL::temporarySignedRoute()` behavior (the new bypass parameter test works as a regression test).
This commit is contained in:
parent
37b2a91aa9
commit
16861d2599
2 changed files with 51 additions and 1 deletions
|
|
@ -129,7 +129,15 @@ class TenancyUrlGenerator extends UrlGenerator
|
|||
throw new InvalidArgumentException('Attribute [name] expects a string backed enum.');
|
||||
}
|
||||
|
||||
[$name, $parameters] = $this->prepareRouteInputs($name, Arr::wrap($parameters)); // @phpstan-ignore argument.type
|
||||
$wrappedParameters = Arr::wrap($parameters);
|
||||
|
||||
[$name, $parameters] = $this->prepareRouteInputs($name, $wrappedParameters); // @phpstan-ignore argument.type
|
||||
|
||||
if (isset($wrappedParameters[static::$bypassParameter])) {
|
||||
// If the bypass parameter was passed, we need to add it back to the parameters after prepareRouteInputs() removes it,
|
||||
// so that the underlying route() call in parent::temporarySignedRoute() can bypass the behavior modification as well.
|
||||
$parameters[static::$bypassParameter] = $wrappedParameters[static::$bypassParameter];
|
||||
}
|
||||
|
||||
return parent::temporarySignedRoute($name, $expiration, $parameters, $absolute);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue