Symfony2: There is no extension able to load the configuration for

后端 未结 1 564
[愿得一人]
[愿得一人] 2021-01-22 08:53

I am building an extension to load config files from all installed bundles.

my Extension looks like this:

namespace Acme\\MenuBundle\\DependencyInjection;
         


        
相关标签:
1条回答
  • 2021-01-22 09:12

    That's because your code:

    $rootNode = $treeBuilder->root('mw_menu'); 
    
    $rootNode
        ->children()
        ->scalarNode('mw_menu')->defaultValue('')->end()
        ->end();
    

    means that the config file should look like this:

    mw_menu: 
        mw_menu: "some teststring" 
    

    An example:

    To be more specific, you need to adapt your code to whatever node you want. In general, people use a general root, like mw_menu, and then secondary value like database_driver in the following example:

    $rootNode = $treeBuilder->root('mw_menu'); 
    
    $rootNode
        ->children()
        ->scalarNode('database_driver')->defaultValue('orm')->end()
        ->end();
    

    Which would then look like this in config file:

    mw_menu: 
        database_driver: mongo_db
    
    0 讨论(0)
提交回复
热议问题