virtualize virtualize - 12 days ago 4
YAML Question

Use array from parameters.yml in routing.yml

I got a locales declaration in my

parameters.yml


parameters:
locale: en
locales: [ en, de, fr, it, es, pt, ru, ja, zh ]


and want to reuse the
locales
param in
routing.yml


homepage_locale:
pattern: /{_locale}
defaults: { _controller: SiteBundle:World:index }
requirements: { _locale: %locales% }


But this obviously results in

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


Is there a way to reuse this param or do I really have to write the locales as a string to satisfy this yaml/regex format, like this:

en|de|fr|it|es|pt|ru|ja|zh

Answer

What about it:

parameters:
    locale:            en
    locales:           en|de|fr|it|es|pt|ru|ja|zh
Comments