symfony - Symfony2 treeBuilder new root item -
i have created new root in treebuilder:
class configuration implements configurationinterface { public function getconfigtreebuilder() { $apinode = $treebuilder->root('nieuwname'); $apinode ->children() ->scalarnode('test') ->isrequired() ->end(); } }
then next exception:
the child node "test" @ path "nieuwname" must configured.
oké sounds good.
# config.yml nieuwname: test: "test"
and exception:
there no extension able load configuration "nieuwname"
what do wrong?
you'll need override extension alias have defined root tree.
namespace your\bundlenamebundle\dependencyinjection; class yourbundlenameextension implements extensioninterface { /** * {@inheritdoc} */ public function getalias() { return 'nieuwname'; } }
or change root tree name match alias naming convention, tends inflection of bundle name lowercase , underscores.
so bundle called mywebsitebundle
have alias my_website
$apinode = $treebuilder->root('your_bundle_name');
Comments
Post a Comment