[Config] added append to the node builder

This commit is contained in:
Thomas Adam 2011-11-02 10:59:34 +01:00
parent fd380e37a9
commit fc4e62822c

View File

@ -124,6 +124,26 @@ class NodeBuilder implements NodeParentInterface
$node = new $class($name); $node = new $class($name);
$this->append($node);
return $node;
}
/**
* Append a node definition.
*
* $node = new ArrayNodeDefinition('name')
* ->children()
* ->scalarNode('foo')
* ->scalarNode('baz')
* ->append($this->getBarNodeDefinition())
* ->end()
* ;
*
* @return NodeBuilder This node builder
*/
public function append(NodeDefinition $node)
{
if ($node instanceof ParentNodeDefinitionInterface) { if ($node instanceof ParentNodeDefinitionInterface) {
$builder = clone $this; $builder = clone $this;
$builder->setParent(null); $builder->setParent(null);
@ -136,7 +156,7 @@ class NodeBuilder implements NodeParentInterface
$node->setParent($this); $node->setParent($this);
} }
return $node; return $this;
} }
/** /**
@ -144,6 +164,8 @@ class NodeBuilder implements NodeParentInterface
* *
* @param string $type The name of the type * @param string $type The name of the type
* @param string $class The fully qualified name the node definition class * @param string $class The fully qualified name the node definition class
*
* @return NodeBuilder This node builder
*/ */
public function setNodeClass($type, $class) public function setNodeClass($type, $class)
{ {