【问题标题】:Symfony3 Configuration TreeBuilderSymfony3 配置树构建器
【发布时间】:2017-01-18 20:23:55
【问题描述】:

我在 app/config.yml 中有以下部分:

bp_image:
    types:
        user_avatar:
            width: 200
            height: 200
            upload_path: '%kernel.root_dir%/../web/uploads'

在我的 Bundle 配置文件中:

$rootNode = $treeBuilder->root('bp_image');
    $rootNode
        ->fixXmlConfig('type')
        ->children()
            ->arrayNode('types')
                ->requiresAtLeastOneElement()
                ->useAttributeAsKey('name')
                ->prototype('array')
                    ->children()
                        ->variableNode('width')->end()
                        ->variableNode('height')->end()
                        ->variableNode('upload_path')->end()
                    ->end()
                ->end()
            ->end()
        ->end(); 

当我尝试处理配置时,Symfony 抛出以下异常:

InvalidConfigurationException in ArrayNode.php line 317: 
Unrecognized option "user_avatar" under "bp_image"

任何想法我做错了什么?

【问题讨论】:

    标签: php yaml symfony


    【解决方案1】:

    已解决。问题出在我调用解析器的方式上。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-03
      • 1970-01-01
      • 2016-09-30
      • 2016-09-28
      • 1970-01-01
      • 2015-08-06
      • 1970-01-01
      • 2019-01-05
      相关资源
      最近更新 更多