Created
July 27, 2012 10:19
-
-
Save abdev/3187292 to your computer and use it in GitHub Desktop.
Symfony2 array options config.yml parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_root: | |
payment_providers: | |
- { payment_provider: 'abcd', name: 'Paypal' } | |
- { payment_provider: 'xyzt', name: 'Authorize.net' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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