title: Symfony 4: how to allow dynamic values for array nodes in bundle configuration?
body: <p>In the <code>Configuration</code> of my bundle I have defined the following for example:</p>
  
  
  
  <pre><code>$treeBuilder = new TreeBuilder('foo');
  $treeBuilder
      -&gt;getRootNode()
      -&gt;children()
          -&gt;arrayNode('foobar')
              -&gt;scalarPrototype()-&gt;end()
              -&gt;defaultValue([])
          -&gt;end()
      -&gt;end()
  ;
  </code></pre>
  
  <p>i. e., the bundle expects an array of values in <code>foo.foobar</code>. Now, in the case of my bundle, these values are dependent on the environment the application is run in. Thus it would make sense to provide this configuration value through an environment variable. <a href="https://symfony.com/blog/new-in-symfony-3-4-advanced-environment-variables" rel="nofollow noreferrer">Since Symfony 3.4</a> values of environment variables can be processed. So this array could be stored JSON encoded in the environment variable and then be decoded via <code>%env(json:FOO)%</code>. So instead of having to write</p>
  
  
  
  <pre><code>foo:
      foobar:
          - Lorem
          - Ipsum
          - Dolor
  </code></pre>
  
  <p>one could instead use</p>
  
  
  
  <pre><code>foo:
      foobar: '%env(json:FOO)%'
  </code></pre>
  
  <p>where</p>
  
  <pre><code>FOO=["Lorem","Ipsum","Dolor"]
  </code></pre>
  
  <p>However, when trying to do that Symfony throws the following exception:</p>
  
  <pre><code>A dynamic value is not compatible with a "Symfony\Component\Config\Definition\PrototypedArrayNode" node type at path "foo.foobar".
  </code></pre>
  
  <p>What is the correct way of allowing such dynamic values for array nodes? Do I need to implement my own normalization in the configuration tree for example?</p>