Skip to content

Commit ae89dfd

Browse files
committed
Update comments in TenancyUrlGenerator and UrlGeneratorBootstrapper
1 parent 52954d0 commit ae89dfd

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/Bootstrappers/UrlGeneratorBootstrapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* Makes the app use TenancyUrlGenerator (instead of Illuminate\Routing\UrlGenerator) which:
1818
* - prefixes route names with the tenant route name prefix (PathTenantResolver::tenantRouteNamePrefix() by default)
19-
* - passes the tenant parameter to the link generated by route() and temporarySignedRoute() (PathTenantResolver::tenantParameterName() by default).
19+
* - passes the tenant parameter (PathTenantResolver::tenantParameterName() by default) to the link generated by the affected methods like route() and temporarySignedRoute().
2020
*
2121
* Used with path and query string identification.
2222
*

src/Overrides/TenancyUrlGenerator.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
* - Automatically passing ['tenant' => ...] to each route() call -- if TenancyUrlGenerator::$passTenantParameterToRoutes is enabled
2323
* This is a more universal solution since it supports both path identification and query parameter identification.
2424
*
25-
* - Prepends route names passed to route() and URL::temporarySignedRoute()
26-
* with `tenant.` (or the configured prefix) if $prefixRouteNames is enabled.
25+
* - Prepends route names with `tenant.` (or the configured prefix) if $prefixRouteNames is enabled.
2726
* This is primarily useful when using route cloning with path identification.
2827
*
29-
* To bypass this behavior on any single route() call, pass the $bypassParameter as true (['central' => true] by default).
28+
* Affected methods: route(), toRoute(), temporarySignedRoute(), signedRoute() (the last two via the route() override).
29+
*
30+
* To bypass this behavior on any single affected method call, pass the $bypassParameter as true (['central' => true] by default).
3031
*/
3132
class TenancyUrlGenerator extends UrlGenerator
3233
{
3334
/**
34-
* Parameter which works as a flag for bypassing the behavior modification of route() and temporarySignedRoute().
35+
* Parameter which works as a flag for bypassing the behavior modification of the affected methods.
3536
*
3637
* For example, in tenant context:
3738
* Route::get('/', ...)->name('home');
@@ -44,12 +45,12 @@ class TenancyUrlGenerator extends UrlGenerator
4445
* Note: UrlGeneratorBootstrapper::$addTenantParameterToDefaults is not affected by this, though
4546
* it doesn't matter since it doesn't pass any extra parameters when not needed.
4647
*
47-
* @see UrlGeneratorBootstrapper
48+
* @see Stancl\Tenancy\Bootstrappers\UrlGeneratorBootstrapper
4849
*/
4950
public static string $bypassParameter = 'central';
5051

5152
/**
52-
* Should route names passed to route() or temporarySignedRoute()
53+
* Should route names passed to the affected methods
5354
* get prefixed with the tenant route name prefix.
5455
*
5556
* This is useful when using e.g. path identification with third-party packages
@@ -59,12 +60,12 @@ class TenancyUrlGenerator extends UrlGenerator
5960
public static bool $prefixRouteNames = false;
6061

6162
/**
62-
* Should the tenant parameter be passed to route() or temporarySignedRoute() calls.
63+
* Should the tenant parameter be passed to the affected methods.
6364
*
6465
* This is useful with path or query parameter identification. The former can be handled
6566
* more elegantly using UrlGeneratorBootstrapper::$addTenantParameterToDefaults.
6667
*
67-
* @see UrlGeneratorBootstrapper
68+
* @see Stancl\Tenancy\Bootstrappers\UrlGeneratorBootstrapper
6869
*/
6970
public static bool $passTenantParameterToRoutes = false;
7071

@@ -115,6 +116,8 @@ class TenancyUrlGenerator extends UrlGenerator
115116
*
116117
* Only the name is taken from prepareRouteInputs() here — parameter handling
117118
* (adding tenant parameter, removing bypass parameter) is delegated to toRoute().
119+
*
120+
* Affects temporarySignedRoute() and signedRoute() as well since they call route() under the hood.
118121
*/
119122
public function route($name, $parameters = [], $absolute = true)
120123
{
@@ -130,6 +133,8 @@ public function route($name, $parameters = [], $absolute = true)
130133
/**
131134
* Override the toRoute() method so that the route name gets prefixed
132135
* and the tenant parameter gets added when in tenant context.
136+
*
137+
* Also affects route(). Even though route() is overridden separately, it delegates parameter handling to toRoute().
133138
*/
134139
public function toRoute($route, $parameters, $absolute)
135140
{

0 commit comments

Comments
 (0)