Symfony2:配置 yaml 中的引用字符串或数组 [英] Symfony2: Reference string or an array in config yaml
本文介绍了Symfony2:配置 yaml 中的引用字符串或数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 symfony2 中我使用了下面的配置 yaml:
In symfony2 I used config yaml below:
// config.yml
parameters:
something:
content:
price: 2.30
mainText: 'Some text here.'
redText: 'This is a text here plus price: ' %price%
%price% 错误并给我一个错误,但系统告诉它一个数组,那么如何指向某物['content'][price]?
The %price% is wrong and gives me an error but system tells its an array, so how to point to something['content'][price]?
推荐答案
您可以这样做
parameters:
something.content.price: 2.30
something:
content:
mainText: 'Some text here.'
redText: 'This is a text here plus price: %something.content.price%'
这里我们只有 2 个参数,something.content.price
包含一个浮点数,something
包含一个数组.
Here we only have 2 parameters, something.content.price
that contains a float, and something
that contains an array.
这意味着您只能直接访问 DI 配置中的这两个.
This means you will only be able to access directly those 2, inside the DI configuration.
这篇关于Symfony2:配置 yaml 中的引用字符串或数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文