Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Symfony2 array options config.yml parsing
my_root:
payment_providers:
- { payment_provider: 'abcd', name: 'Paypal' }
- { payment_provider: 'xyzt', name: 'Authorize.net' }
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('my_root');
$rootNode
->children()
->arrayNode('payment_providers')
->prototype('array')
->children()
->scalarNode('payment_provider')->end()
->scalarNode('name')->end()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
}
Array
(
[payment_providers] => Array
(
[0] => Array
(
[payment_provider] => abcd
[name] => Paypal
)
[1] => Array
(
[payment_provider] => xyzt
[name] => Authorize.net
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.