开发者

Is it possible to define array as constant in with Symfony Framework?

Constants are defined in YAML format in the config/app.yaml file. However, when I 开发者_运维问答try to define an array as

const_arr: ['one', 'two', 'three', 'four', 'five']

and use sfConfig::get('app_const_arr'), I don't getting anything back. What am I doing wrong?


Try:

app:
   my_array:
       values: [foo, bar]


sfConfig::get('app_my_array_values');


+1'd to Darmen's answer. If you wanted to stick with your original YAML, you can add a dummy layer in the YAML - precede it with a period (.). For example, in apps/yourapp/config.yml:

all:
  .dummy_layer_here:
    const_arr: ['one', 'two', 'three', 'four', 'five']

which should allow you to do sfConfig::get('app_const_arr').

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜