LocaleBundle icon indicating copy to clipboard operation
LocaleBundle copied to clipboard

Use allowed_locales in routing.yml

Open ghost opened this issue 10 years ago • 5 comments

Any idea how to get this working?

resource: "@ExampleBundle/Resources/config/routing.yml"
prefix:   /{_locale}
requirements:
  _locale: %lunetics_locale.allowed_locales%

Error:

 The container parameter "lunetics_locale.allowed_locales", used in the route configuration value "%lunetics_locale.allowed_locales%", must be a string or numeric, but it is of type array.

ghost avatar Apr 24 '15 07:04 ghost

maybe with the expression language, if you are on symfony 2.4 or higher?

dbu avatar Apr 24 '15 09:04 dbu

You could add another variable with _regex% suffix and transform it into a regex string in the configurations Am 24.04.2015 09:11 schrieb "JHGitty" [email protected]:

Any idea how to get this working?

resource: "@ExampleBundle/Resources/config/routing.yml" prefix: /{_locale} requirements: _locale: %lunetics_locale.allowed_locales%

Error:

The container parameter "lunetics_locale.allowed_locales", used in the route configuration value "%lunetics_locale.allowed_locales%", must be a string or numeric, but it is of type array.

— Reply to this email directly or view it on GitHub https://github.com/lunetics/LocaleBundle/issues/148.

lunetics avatar Apr 24 '15 14:04 lunetics

Is there any other way to add the prefix?

ghost avatar Apr 26 '15 17:04 ghost

@JHGitty those 2 methods seem to me the most obvious ones, can't think of others. you would need to make the implode function available for expressions and use that.

dbu avatar Apr 26 '15 19:04 dbu

I think it would be great if the documentation would contain an example for this. There is already an example for subdomains.

ghost avatar Apr 26 '15 20:04 ghost