Symfony2 API
Class

Symfony\Component\Config\Definition\Builder\NodeDefinition

abstract class NodeDefinition implements NodeParentInterface

This class provides a fluent interface for defining a node.

Methods

__construct(string $name, NodeParentInterface $parent = null)

Constructor

NodeDefinition setParent(NodeParentInterface $parent)

Sets the parent node.

NodeDefinition info(string $info)

Sets info message.

NodeDefinition example(string|array $example)

Sets example configuration.

NodeDefinition attribute(string $key, mixed $value)

Sets an attribute on the node.

NodeParentInterface|null end()

Returns the parent node.

NodeInterface getNode(bool $forceRootNode = false)

Creates the node.

NodeDefinition defaultValue(mixed $value)

Sets the default value.

NodeDefinition isRequired()

Sets the node as required.

NodeDefinition treatNullLike(mixed $value)

Sets the equivalent value used when the node contains null.

NodeDefinition treatTrueLike(mixed $value)

Sets the equivalent value used when the node contains true.

NodeDefinition treatFalseLike(mixed $value)

Sets the equivalent value used when the node contains false.

NodeDefinition defaultNull()

Sets null as the default value.

NodeDefinition defaultTrue()

Sets true as the default value.

NodeDefinition defaultFalse()

Sets false as the default value.

ExprBuilder beforeNormalization()

Sets an expression to run before the normalization.

NodeDefinition cannotBeEmpty()

Denies the node value being empty.

ExprBuilder validate()

Sets an expression to run for the validation.

NodeDefinition cannotBeOverwritten(bool $deny = true)

Sets whether the node can be overwritten.

Details

at line 48
public __construct(string $name, NodeParentInterface $parent = null)

Constructor

Parameters

string $name The name of the node
NodeParentInterface $parent The parent

at line 61
public NodeDefinition setParent(NodeParentInterface $parent)

Sets the parent node.

Parameters

NodeParentInterface $parent The parent

Return Value

NodeDefinition

at line 75
public NodeDefinition info(string $info)

Sets info message.

Parameters

string $info The info text

Return Value

NodeDefinition

at line 87
public NodeDefinition example(string|array $example)

Sets example configuration.

Parameters

string|array $example

Return Value

NodeDefinition

at line 100
public NodeDefinition attribute(string $key, mixed $value)

Sets an attribute on the node.

Parameters

string $key
mixed $value

Return Value

NodeDefinition

at line 112
public NodeParentInterface|null end()

Returns the parent node.

Return Value

NodeParentInterface|null The builder of the parent node

at line 124
public NodeInterface getNode(bool $forceRootNode = false)

Creates the node.

Parameters

bool $forceRootNode Whether to force this node as the root node

Return Value

NodeInterface

at line 151
public NodeDefinition defaultValue(mixed $value)

Sets the default value.

Parameters

mixed $value The default value

Return Value

NodeDefinition

at line 164
public NodeDefinition isRequired()

Sets the node as required.

Return Value

NodeDefinition

at line 178
public NodeDefinition treatNullLike(mixed $value)

Sets the equivalent value used when the node contains null.

Parameters

mixed $value

Return Value

NodeDefinition

at line 192
public NodeDefinition treatTrueLike(mixed $value)

Sets the equivalent value used when the node contains true.

Parameters

mixed $value

Return Value

NodeDefinition

at line 206
public NodeDefinition treatFalseLike(mixed $value)

Sets the equivalent value used when the node contains false.

Parameters

mixed $value

Return Value

NodeDefinition

at line 218
public NodeDefinition defaultNull()

Sets null as the default value.

Return Value

NodeDefinition

at line 228
public NodeDefinition defaultTrue()

Sets true as the default value.

Return Value

NodeDefinition

at line 238
public NodeDefinition defaultFalse()

Sets false as the default value.

Return Value

NodeDefinition

at line 248
public ExprBuilder beforeNormalization()

Sets an expression to run before the normalization.

Return Value

ExprBuilder

at line 258
public NodeDefinition cannotBeEmpty()

Denies the node value being empty.

Return Value

NodeDefinition

at line 274
public ExprBuilder validate()

Sets an expression to run for the validation.

The expression receives the value of the node and must return it. It can modify it. An exception should be thrown when the node is not valid.

Return Value

ExprBuilder

at line 286
public NodeDefinition cannotBeOverwritten(bool $deny = true)

Sets whether the node can be overwritten.

Parameters

bool $deny Whether the overwriting is forbidden or not

Return Value

NodeDefinition