Php Symfony 2语义包配置$在扩展类中配置为空
我没有太多的运气尝试得到一个简单的捆绑语义配置示例,用于Symfony 2.5.2 我正在关注这个 我的捆绑包是位于名称空间Tetranz\MyTestBundle的TetranzMyTestBundle 配置包含来自代码生成器的此项Php Symfony 2语义包配置$在扩展类中配置为空,php,symfony,Php,Symfony,我没有太多的运气尝试得到一个简单的捆绑语义配置示例,用于Symfony 2.5.2 我正在关注这个 我的捆绑包是位于名称空间Tetranz\MyTestBundle的TetranzMyTestBundle 配置包含来自代码生成器的此项 public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('tetranz_my_tes
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('tetranz_my_test');
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.
return $treeBuilder;
}
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
}
TetranzMyTestExtension也包含代码生成器中的内容
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('tetranz_my_test');
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.
return $treeBuilder;
}
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
}
app/config/config.yml
包含:
tetranz_my_test:
setting1:value1
如果我正确地阅读了cookbook页面,那么应该可以,但是上面load()方法中的$configs包含一个空数组元素$config是一个空数组
我一定错过了什么明显的东西。我曾尝试在配置类中添加一些结构(Children()等),但没有帮助
谢谢你
我的config.yml中冒号后面没有空格。仅此而已:)