W3cubDocs

/Symfony 4.1

ScalarNodeDefinition

class ScalarNodeDefinition extends VariableNodeDefinition

This class provides a fluent interface for defining a node.

Properties

protected $name from NodeDefinition
protected $normalization from NodeDefinition
protected $validation from NodeDefinition
protected $defaultValue from NodeDefinition
protected $default from NodeDefinition
protected $required from NodeDefinition
protected $deprecationMessage from NodeDefinition
protected $merge from NodeDefinition
protected $allowEmptyValue from NodeDefinition
protected $nullEquivalent from NodeDefinition
protected $trueEquivalent from NodeDefinition
protected $falseEquivalent from NodeDefinition
protected $pathSeparator from NodeDefinition
protected $parent from NodeDefinition
protected $attributes from NodeDefinition

Methods

__construct(string|null $name, NodeParentInterface $parent = null) from NodeDefinition
$this setParent(NodeParentInterface $parent)

Sets the parent node.

from NodeDefinition
$this info(string $info)

Sets info message.

from NodeDefinition
$this example(string|array $example)

Sets example configuration.

from NodeDefinition
$this attribute(string $key, mixed $value)

Sets an attribute on the node.

from NodeDefinition
NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null end()

Returns the parent node.

from NodeDefinition
NodeInterface getNode(bool $forceRootNode = false)

Creates the node.

from NodeDefinition
$this defaultValue(mixed $value)

Sets the default value.

from NodeDefinition
$this isRequired()

Sets the node as required.

from NodeDefinition
$this setDeprecated(string $message = 'The child node "%node%" at path "%path%" is deprecated.')

Sets the node as deprecated.

from NodeDefinition
$this treatNullLike(mixed $value)

Sets the equivalent value used when the node contains null.

from NodeDefinition
$this treatTrueLike(mixed $value)

Sets the equivalent value used when the node contains true.

from NodeDefinition
$this treatFalseLike(mixed $value)

Sets the equivalent value used when the node contains false.

from NodeDefinition
$this defaultNull()

Sets null as the default value.

from NodeDefinition
$this defaultTrue()

Sets true as the default value.

from NodeDefinition
$this defaultFalse()

Sets false as the default value.

from NodeDefinition
ExprBuilder beforeNormalization()

Sets an expression to run before the normalization.

from NodeDefinition
$this cannotBeEmpty()

Denies the node value being empty.

from NodeDefinition
ExprBuilder validate()

Sets an expression to run for the validation.

from NodeDefinition
$this cannotBeOverwritten(bool $deny = true)

Sets whether the node can be overwritten.

from NodeDefinition
ValidationBuilder validation()

Gets the builder for validation rules.

from NodeDefinition
MergeBuilder merge()

Gets the builder for merging rules.

from NodeDefinition
NormalizationBuilder normalization()

Gets the builder for normalization rules.

from NodeDefinition
NodeInterface createNode()

Instantiate and configure the node according to this definition.

from VariableNodeDefinition
$this setPathSeparator(string $separator)

Set PathSeparator to use.

from NodeDefinition
VariableNode instantiateNode()

Instantiate a Node.

Details

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

Parameters

string|null $name
NodeParentInterface $parent

$this setParent(NodeParentInterface $parent)

Sets the parent node.

Parameters

NodeParentInterface $parent

Return Value

$this

$this info(string $info)

Sets info message.

Parameters

string $info The info text

Return Value

$this

$this example(string|array $example)

Sets example configuration.

Parameters

string|array $example

Return Value

$this

$this attribute(string $key, mixed $value)

Sets an attribute on the node.

Parameters

string $key
mixed $value

Return Value

$this

NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null end()

Returns the parent node.

Return Value

NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null The builder of the parent node

NodeInterface getNode(bool $forceRootNode = false)

Creates the node.

Parameters

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

Return Value

NodeInterface

$this defaultValue(mixed $value)

Sets the default value.

Parameters

mixed $value The default value

Return Value

$this

$this isRequired()

Sets the node as required.

Return Value

$this

$this setDeprecated(string $message = 'The child node "%node%" at path "%path%" is deprecated.')

Sets the node as deprecated.

You can use %node% and %path% placeholders in your message to display, respectively, the node name and its complete path.

Parameters

string $message Deprecation message

Return Value

$this

$this treatNullLike(mixed $value)

Sets the equivalent value used when the node contains null.

Parameters

mixed $value

Return Value

$this

$this treatTrueLike(mixed $value)

Sets the equivalent value used when the node contains true.

Parameters

mixed $value

Return Value

$this

$this treatFalseLike(mixed $value)

Sets the equivalent value used when the node contains false.

Parameters

mixed $value

Return Value

$this

$this defaultNull()

Sets null as the default value.

Return Value

$this

$this defaultTrue()

Sets true as the default value.

Return Value

$this

$this defaultFalse()

Sets false as the default value.

Return Value

$this

ExprBuilder beforeNormalization()

Sets an expression to run before the normalization.

Return Value

ExprBuilder

$this cannotBeEmpty()

Denies the node value being empty.

Return Value

$this

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

$this cannotBeOverwritten(bool $deny = true)

Sets whether the node can be overwritten.

Parameters

bool $deny Whether the overwriting is forbidden or not

Return Value

$this

protected ValidationBuilder validation()

Gets the builder for validation rules.

Return Value

ValidationBuilder

protected MergeBuilder merge()

Gets the builder for merging rules.

Return Value

MergeBuilder

protected NormalizationBuilder normalization()

Gets the builder for normalization rules.

Return Value

NormalizationBuilder

protected NodeInterface createNode()

Instantiate and configure the node according to this definition.

Return Value

NodeInterface $node The node instance

Exceptions

InvalidDefinitionException When the definition is invalid

$this setPathSeparator(string $separator)

Set PathSeparator to use.

Parameters

string $separator

Return Value

$this

protected VariableNode instantiateNode()

Instantiate a Node.

Return Value

VariableNode The node

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