diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php index d43aa2c272..e1dd6bee5e 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php @@ -124,6 +124,26 @@ class NodeBuilder implements NodeParentInterface $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) { $builder = clone $this; $builder->setParent(null); @@ -136,7 +156,7 @@ class NodeBuilder implements NodeParentInterface $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 $class The fully qualified name the node definition class + * + * @return NodeBuilder This node builder */ public function setNodeClass($type, $class) {