Skip to content

Instantly share code, notes, and snippets.

@gergelypolonkai
Created April 27, 2015 08:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gergelypolonkai/30440e25f7a447730064 to your computer and use it in GitHub Desktop.
Save gergelypolonkai/30440e25f7a447730064 to your computer and use it in GitHub Desktop.
Symfony 2 configuration: array of dynamic associative arrays
acme_demo:
transitions:
- { hc_cba: 180 }
- { cba_hc: -1 }
<?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