Using the Symfony2 configuration class, how do I define an array node whose children don't have keys?

Viewed 5921

Using the configuration class, how do I define an array node without numeric keys? The children of the array do not represent further configuration options. Rather, they will be a list that will not be able to be overwritten selectively, only as a whole.

So far I have:

public function getConfigTreeBuilder()
{
    $treeBuilder = new TreeBuilder;
    $root = $treeBuilder->root('acme_base');

    $root
        ->children()
            ->arrayNode('entities')

                // Unfortunately, this doesn't work
                ->defaultValue(array(
                    'Acme\BaseBundle\Entity\DefaultEntity1',
                    'Acme\BaseBundle\Entity\DefaultEntity2',
                ))

            ->end()
        ->end();

    return $treeBuilder;
}

In app/config.yml, I want to be able to overwrite it like this:

acme_base:
  entities:
    - 'Acme\BaseBundle\Entity\AnotherEntity1'
    - 'Acme\BaseBundle\Entity\AnotherEntity2'
    - 'Acme\BaseBundle\Entity\AnotherEntity3'
    - 'Acme\BaseBundle\Entity\AnotherEntity4'
1 Answers
Related