[Config] implements feedback
This commit is contained in:
parent
bc122bdb2d
commit
4feba09aa9
@ -217,7 +217,7 @@ class Configuration implements ConfigurationInterface
|
||||
->fixXmlConfig('resource')
|
||||
->children()
|
||||
->arrayNode('resources')
|
||||
->addDefaultChildrenWhenNoneSet()
|
||||
->addDefaultChildrenIfNoneSet()
|
||||
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
|
||||
->validate()
|
||||
->ifTrue(function($v) {return !in_array('FrameworkBundle:Form', $v); })
|
||||
|
@ -54,7 +54,7 @@ class Configuration implements ConfigurationInterface
|
||||
->fixXmlConfig('resource')
|
||||
->children()
|
||||
->arrayNode('resources')
|
||||
->addDefaultChildrenWhenNoneSet()
|
||||
->addDefaultChildrenIfNoneSet()
|
||||
->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()
|
||||
->setExample(array('MyBundle::form.html.twig'))
|
||||
->validate()
|
||||
|
@ -109,7 +109,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function addDefaultChildrenWhenNoneSet($children = null)
|
||||
public function addDefaultChildrenIfNoneSet($children = null)
|
||||
{
|
||||
$this->addDefaultChildren = null === $children ? 'defaults' : $children;
|
||||
|
||||
@ -369,6 +369,12 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
sprintf('->defaultValue() is not applicable to concrete nodes at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
throw new InvalidDefinitionException(
|
||||
sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s"', $path)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,6 +49,7 @@ class ArrayNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array('defaultValue', array(array())),
|
||||
array('addDefaultChildrenIfNoneSet', array()),
|
||||
array('requiresAtLeastOneElement', array()),
|
||||
array('useAttributeAsKey', array('foo'))
|
||||
);
|
||||
@ -72,7 +73,7 @@ class ArrayNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node
|
||||
->defaultValue(array())
|
||||
->addDefaultChildrenWhenNoneSet('foo')
|
||||
->addDefaultChildrenIfNoneSet('foo')
|
||||
->prototype('array')
|
||||
;
|
||||
$node->getNode();
|
||||
@ -82,7 +83,7 @@ class ArrayNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node
|
||||
->addDefaultChildrenWhenNoneSet()
|
||||
->addDefaultChildrenIfNoneSet()
|
||||
->prototype('array')
|
||||
;
|
||||
$tree = $node->getNode();
|
||||
@ -93,7 +94,7 @@ class ArrayNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node
|
||||
->addDefaultChildrenWhenNoneSet()
|
||||
->addDefaultChildrenIfNoneSet()
|
||||
->prototype('array')
|
||||
->prototype('array')
|
||||
;
|
||||
|
Reference in New Issue
Block a user