Skip to content

Commit

Permalink
[Config] implements feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Feb 20, 2012
1 parent bc122bd commit 4feba09
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Expand Up @@ -217,7 +217,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->fixXmlConfig('resource')
->children()
->arrayNode('resources')
->addDefaultChildrenWhenNoneSet()
->addDefaultChildrenIfNoneSet()
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
->validate()
->ifTrue(function($v) {return !in_array('FrameworkBundle:Form', $v); })
Expand Down
Expand Up @@ -54,7 +54,7 @@ private function addFormSection(ArrayNodeDefinition $rootNode)
->fixXmlConfig('resource')
->children()
->arrayNode('resources')
->addDefaultChildrenWhenNoneSet()
->addDefaultChildrenIfNoneSet()
->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()
->setExample(array('MyBundle::form.html.twig'))
->validate()
Expand Down
Expand Up @@ -109,7 +109,7 @@ public function addDefaultsIfNotSet()
*
* @return ArrayNodeDefinition
*/
public function addDefaultChildrenWhenNoneSet($children = null)
public function addDefaultChildrenIfNoneSet($children = null)
{
$this->addDefaultChildren = null === $children ? 'defaults' : $children;

Expand Down Expand Up @@ -369,6 +369,12 @@ protected function validateConcreteNode(ArrayNode $node)
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)
);
}
}

/**
Expand Down
Expand Up @@ -49,6 +49,7 @@ public function providePrototypeNodeSpecificCalls()
{
return array(
array('defaultValue', array(array())),
array('addDefaultChildrenIfNoneSet', array()),
array('requiresAtLeastOneElement', array()),
array('useAttributeAsKey', array('foo'))
);
Expand All @@ -72,7 +73,7 @@ public function testPrototypeNodesCantHaveADefaultValueWhenUsingDefaulChildren()
$node = new ArrayNodeDefinition('root');
$node
->defaultValue(array())
->addDefaultChildrenWhenNoneSet('foo')
->addDefaultChildrenIfNoneSet('foo')
->prototype('array')
;
$node->getNode();
Expand All @@ -82,7 +83,7 @@ public function testArrayNodeDefaultWhenUsingDefaultChildren()
{
$node = new ArrayNodeDefinition('root');
$node
->addDefaultChildrenWhenNoneSet()
->addDefaultChildrenIfNoneSet()
->prototype('array')
;
$tree = $node->getNode();
Expand All @@ -93,7 +94,7 @@ public function testNestedPrototypedArrayNodes()
{
$node = new ArrayNodeDefinition('root');
$node
->addDefaultChildrenWhenNoneSet()
->addDefaultChildrenIfNoneSet()
->prototype('array')
->prototype('array')
;
Expand Down

0 comments on commit 4feba09

Please sign in to comment.