Created
April 27, 2015 08:22
-
-
Save gergelypolonkai/30440e25f7a447730064 to your computer and use it in GitHub Desktop.
Symfony 2 configuration: array of dynamic associative arrays
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
acme_demo: | |
transitions: | |
- { hc_cba: 180 } | |
- { cba_hc: -1 } |
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
<?php | |
$rootNode | |
->children() | |
->arrayNode('state_machine') | |
->requiresAtLeastOneElement() | |
->beforeNormalization() | |
->ifArray() | |
->then(function($values) { | |
$ret = array(); | |
foreach ($values as $value) { | |
foreach ($value as $transition => $time) { | |
$ret[] = array('transition' => $transition, 'time' => e); | |
} | |
} | |
return $ret; | |
}) | |
->end() | |
->prototype('array') | |
->children() | |
->scalarNode('transition')->end() | |
->scalarNode('time')->end() | |
->end() | |
->end() | |
->end() | |
->end() | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment