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

Make the routes config dynamically #17

Merged
merged 2 commits into from May 29, 2017
Merged

Conversation

Konafets
Copy link
Contributor

@Konafets Konafets commented May 4, 2017

In the config/laravel-impersonate.php the take_redirect_to and leave_redirect_to are hard coded urls. This is fine as long as you don't construct your routes dynamically.

In our case we hook into the RouteServiceProvider to add a language prefix de or en, depending on the user settings.

Since route() in a config file leads to a "Route not defined" error, because Laravel loads the configuration before the routes are registered, the only way to tackle this is to expect a route name.

The PR supports the old behavior and adds the new behavior on top.

In the `config/laravel-impersonate.php` the `take_redirect_to` and `leave_redirect_to` are hard coded urls. This is fine as long as you don't construct your routes dynamically.

In our case we hook into the `RouteServiceProvider` to add a language prefix `de` or `en`, depending on the user settings.

Since `route()` in a config file leads to a "Route not defined" error, because Laravel loads the configuration before the routes are registered, the only way to tackle this is to expect a route name.

The current implemenation is a BC break. A better implementation would could detect a url and a route and decide this on its own. This is just a first draft to see if you are interested in such a change.
@MarceauKa
Copy link
Member

Hi @Konafets and thank you for that.
Can you continue without BC?

@Konafets
Copy link
Contributor Author

Konafets commented May 4, 2017

Now it works with named routes and plain url in the config file.

@drbyte
Copy link
Contributor

drbyte commented May 13, 2017

I like it. 👍

There weren't any tests for these before this PR. Not sure if there are plans to have any.

@drbyte
Copy link
Contributor

drbyte commented May 13, 2017

And since it's not BC anymore, maybe remove "BC" from the PR title?

@Konafets Konafets changed the title BC: Make the routes config dynamically Make the routes config dynamically May 13, 2017
@MarceauKa MarceauKa merged commit 20c6e99 into 404labfr:master May 29, 2017
@MarceauKa
Copy link
Member

Merged and tagged 1.1.1. Thank you!

@Konafets Konafets deleted the patch-1 branch September 1, 2017 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants