laravel-localization icon indicating copy to clipboard operation
laravel-localization copied to clipboard

Extract should redirect logic to method on base middleware

Open standaniels opened this issue 3 years ago • 0 comments

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
  • Domain example.be
    • Has locales:
      • fr
      • nl
    • Default locale: fr
    • Hide default locale: false

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?

standaniels avatar Jul 08 '21 08:07 standaniels