Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a tenanted route URL generator #77

Merged
merged 2 commits into from
Dec 15, 2024

Conversation

ollieread
Copy link
Member

@ollieread ollieread commented Dec 15, 2024

This PR adds a helper method for generating URLs using Laravel's route helper, but for tenanted routes. Completes #76

This can be called on an instance of Sprout\Sprout, like so:

sprout()->route('my.route.name', $myTenant);

The signature of the method is as follows:

public function route(string $name, Tenant $tenant, ?string $resolver = null, ?string $tenancy = null, array $parameters = [], bool $absolute = true): string

Resolving the tenancy follows this process:

  • Retrieve a tenancy for the name if one is provided
  • If one isn't provided, use the current tenancy
  • If there is no current tenancy, get the default one

Resolving the identity resolver follows this process:

  • Retrieve an identity resolver for the name if one is provided
  • If one isn't provided, use the resolver currently linked to the tenancy
  • If there is no resolver linked to the tenancy, get the default one

Internally, this method proxies a call to IdentityResolver::route() which has the following signature:

public function route(string $name, Tenancy $tenancy, Tenant $tenant, array $parameters = [], bool $absolute = true): string;

@ollieread ollieread added type: feat New feature status: accepted The issue has been accepted/acknowledged and is being actioned or will be labels Dec 15, 2024
@ollieread ollieread self-assigned this Dec 15, 2024
Copy link

codecov bot commented Dec 15, 2024

❌ 6 Tests Failed:

Tests completed Failed Passed Skipped
118 6 112 0
View the top 3 failed tests by shortest run time
Http.Resolvers.SessionResolverTest::resolvesFromRoute
Stack Traces | 0.0118s run time
No failure message available
Http.Resolvers.SessionResolverTest::throwsExceptionIfSessionOverrideIsEnabled
Stack Traces | 0.0124s run time
No failure message available
Sprout.Tests.Overrides.CookieOverrideTest::setsTheCookiePathWhenUsingThePathIdentityResolver
Stack Traces | 0.0167s run time
Sprout\Tests\Overrides\CookieOverrideTest::setsTheCookiePathWhenUsingThePathIdentityResolver
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'minus-quia-eum-necessitatibus-autem-alias-officiis-qui-tempore'
+'/minus-quia-eum-necessitatibus-autem-alias-officiis-qui-tempore'

.../tests/Overrides/CookieOverrideTest.php:125

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@ollieread ollieread merged commit ccc081d into main Dec 15, 2024
0 of 2 checks passed
@ollieread ollieread deleted the feat/route-generator-helper branch December 15, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted The issue has been accepted/acknowledged and is being actioned or will be type: feat New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate a better way of calling route() outside of multitenanted context
1 participant