[Config] added append to the node builder
This commit is contained in:
parent
fd380e37a9
commit
fc4e62822c
@ -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)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user