简体   繁体   English

基于数据库条目的Symfony2 Bundle配置

[英]Symfony2 Bundle configuration based on database entries

I'm using JMSI18nRoutingBundle. 我正在使用JMSI18nRoutingBundle。 I need to create function, which will allow administrator to create new languages from CMS The problem is, how can I get available languages from database(stored in "locale" table), and use them in JMS bundle configuration. 我需要创建功能,该功能将允许管理员从CMS创建新语言。问题是,如何从数据库(存储在“语言环境”表中)中获取可用语言,并在JMS捆绑包配置中使用它们。 Eg: I have three locales in DB(EN, FR, PL), and i should get result similar to this(but fetched from DB): 例如:我在数据库中有三个语言环境(EN,FR,PL),我应该得到与此类似的结果(但从数据库中获取):

jms_i18n_routing:
    default_locale: en
    locales: [en, fr, pl] <--
    strategy: prefix

How can i achieve that? 我该如何实现?

Ok. 好。 It seems, that Symfony doesn't provide any tool to create bundle configuration based on database entries. 看来,Symfony没有提供任何工具来基于数据库条目创建捆绑包配置。 We created a little "work-around" - we have created an .yml file that contains just one parameter(which we are using to configure available languages) and when entries in Locale table are changed, we just rewrite this file with new parameter value. 我们创建了一个“替代方法”-我们创建了一个.yml文件,其中仅包含一个参数(用于配置可用的语言),并且更改了Locale表中的条目时,我们只是使用新的参数值重写了此文件。 Simple. 简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM