W3cubDocs

/Symfony 4.1

NodeBuilder

class NodeBuilder implements NodeParentInterface

This class provides a fluent interface for building a node.

Properties

protected $parent
protected $nodeMapping

Methods

__construct()
$this setParent(ParentNodeDefinitionInterface $parent = null)

Set the parent node.

ArrayNodeDefinition arrayNode(string $name)

Creates a child array node.

ScalarNodeDefinition scalarNode(string $name)

Creates a child scalar node.

BooleanNodeDefinition booleanNode(string $name)

Creates a child Boolean node.

IntegerNodeDefinition integerNode(string $name)

Creates a child integer node.

FloatNodeDefinition floatNode(string $name)

Creates a child float node.

EnumNodeDefinition enumNode(string $name)

Creates a child EnumNode.

VariableNodeDefinition variableNode(string $name)

Creates a child variable node.

ParentNodeDefinitionInterface|NodeDefinition end()

Returns the parent node.

NodeDefinition node(string|null $name, string $type)

Creates a child node.

$this append(NodeDefinition $node)

Appends a node definition.

$this setNodeClass(string $type, string $class)

Adds or overrides a node Type.

string getNodeClass(string $type)

Returns the class name of the node definition.

Details

__construct()

$this setParent(ParentNodeDefinitionInterface $parent = null)

Set the parent node.

Parameters

ParentNodeDefinitionInterface $parent

Return Value

$this

ArrayNodeDefinition arrayNode(string $name)

Creates a child array node.

Parameters

string $name The name of the node

Return Value

ArrayNodeDefinition The child node

ScalarNodeDefinition scalarNode(string $name)

Creates a child scalar node.

Parameters

string $name The name of the node

Return Value

ScalarNodeDefinition The child node

BooleanNodeDefinition booleanNode(string $name)

Creates a child Boolean node.

Parameters

string $name The name of the node

Return Value

BooleanNodeDefinition The child node

IntegerNodeDefinition integerNode(string $name)

Creates a child integer node.

Parameters

string $name The name of the node

Return Value

IntegerNodeDefinition The child node

FloatNodeDefinition floatNode(string $name)

Creates a child float node.

Parameters

string $name The name of the node

Return Value

FloatNodeDefinition The child node

EnumNodeDefinition enumNode(string $name)

Creates a child EnumNode.

Parameters

string $name

Return Value

EnumNodeDefinition

VariableNodeDefinition variableNode(string $name)

Creates a child variable node.

Parameters

string $name The name of the node

Return Value

VariableNodeDefinition The builder of the child node

ParentNodeDefinitionInterface|NodeDefinition end()

Returns the parent node.

Return Value

ParentNodeDefinitionInterface|NodeDefinition The parent node

NodeDefinition node(string|null $name, string $type)

Creates a child node.

Parameters

string|null $name The name of the node
string $type The type of the node

Return Value

NodeDefinition The child node

Exceptions

RuntimeException When the node type is not registered
RuntimeException When the node class is not found

$this append(NodeDefinition $node)

Appends a node definition.

Usage:

$node = new ArrayNodeDefinition('name')
    ->children()
        ->scalarNode('foo')->end()
        ->scalarNode('baz')->end()
        ->append($this->getBarNodeDefinition())
    ->end()
;

Parameters

NodeDefinition $node

Return Value

$this

$this setNodeClass(string $type, string $class)

Adds or overrides a node Type.

Parameters

string $type The name of the type
string $class The fully qualified name the node definition class

Return Value

$this

protected string getNodeClass(string $type)

Returns the class name of the node definition.

Parameters

string $type The node type

Return Value

string The node definition class name

Exceptions

RuntimeException When the node type is not registered
RuntimeException When the node class is not found

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Config/Definition/Builder/NodeBuilder.html