laravel-localization
laravel-localization copied to clipboard
Extract should redirect logic to method on base middleware
In some cases the hideDefaultLocaleInURL
isn't a static value and reading the config wouldn't suffice. For example:
- Domain
example.nl
- Has locales:
-
nl
-
- Default locale:
nl
- Hide default locale:
true
- Has locales:
- Domain
example.be
- Has locales:
-
fr
-
nl
-
- Default locale:
fr
- Hide default locale:
false
- Has locales:
This PR extracts the logic to determine whether the request should be redirected to the (non-) localized URL or not to a method on the base middleware class, so a user could write their own middleware, but are able to extend the package middleware; they only need to overwrite the shouldRedirectToLocalizedUrl
and shouldRedirectToNonLocalizedUrl
methods.
What do you think?