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

assign value to Route $path protected property #192

Closed
ghost opened this issue Sep 14, 2018 · 1 comment
Closed

assign value to Route $path protected property #192

ghost opened this issue Sep 14, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 14, 2018

Hi,
is there any chance you implement a setter method for a protected property '$path' in Route class?

I would like to implement a route path localization based on desired language, but I cannot override protected property path (ie. en path "/en/home" .... sl path: "/sl/domov")? All route data stays the same (name, callable, ... ) except for a path, which I would like to change dynamically.

Please help me with a better approach or if it makes sense I can prepare PR?

Br, K

@ghost ghost changed the title asign value to Route $path protected property assign value to Route $path protected property Sep 14, 2018
@philipobenito
Copy link
Member

I still don't think that solves your problem.

If your route paths were the same but only the locale was changing I'd suggest a wildcard.

$route->get('/{locale}/home', 'Controller::method');

Then you could determine the locale in your controller or some type of abstraction.

But because the language of the path also changes, I'd suggest defining multiple routes that point to the same controller.

$route->get('/en/home', 'Controller::method');
$route->get('/sl/domov', 'Controller::method');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant