title: Making configuration node support both string and array in Symfony 2 configuration?
body: <p>Can my configuration node <code>source</code> support both <code>string</code> and <code>array</code> values?</p>
  
  <p>Sourcing from <code>string</code>:</p>
  
  <pre class="lang-none prettyprint-override"><code># Valid configuration 1
  my_bundle:
      source: %kernel.root_dir%/../Resources/config/source.json
  </code></pre>
  
  <p>Sourcing from <code>array</code>:</p>
  
  <pre class="lang-none prettyprint-override"><code># Valid configuration 2
  my_bundle:
      source:
          operations: []
          commands: []
  </code></pre>
  
  <p>The extension class would be able to distinguish between them:</p>
  
  <pre class="lang-php prettyprint-override"><code>if (is_array($config['source']) {
      // Bootstrap from array
  } else {
      // Bootstrap from file
  }
  </code></pre>
  
  <p>I might use something like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>$rootNode-&gt;children()
      -&gt;variableNode('source')
          -&gt;validate()
              -&gt;ifTrue(function ($v) { return !is_string($v) &amp;&amp; !is_array($v); })
              -&gt;thenInvalid('Configuration value must be either string or array.')
          -&gt;end()
      -&gt;end()
  -&gt;end();
  </code></pre>
  
  <p>But how ca I add constraints on the structure of <code>source</code> (operations, commands, etc...) to the variable node (that should only be enforced when its value is of type <code>array</code>)?</p>