ArrayNodeDefinition
extends NodeDefinition
in package
implements
ParentNodeDefinitionInterface
This class provides a fluent interface for defining an array node.
Tags
Table of Contents
Interfaces
- ParentNodeDefinitionInterface
- An interface that must be implemented by nodes which can have children.
Properties
- $addDefaultChildren : int|string|array<string|int, mixed>|false|null
- $addDefaults : bool
- $allowedTypes : array<int, ExprBuilder::TYPE_*>|null
- $allowEmptyValue : bool
- $allowNewKeys : bool
- $atLeastOne : bool
- $attributes : array<string|int, mixed>
- $children : array<string|int, NodeDefinition<string|int, $this>>
- $default : bool
- $defaultValue : mixed
- $deprecation : array<string|int, mixed>
- $falseEquivalent : mixed
- $ignoreExtraKeys : bool
- $key : string|null
- $merge : MergeBuilder<string|int, $this>
- $name : string|null
- $nodeBuilder : NodeBuilder<string|int, static>
- $normalization : NormalizationBuilder<string|int, $this>
- $normalizeKeys : bool
- $nullEquivalent : mixed
- $parent : TParent|NodeInterface
- $pathSeparator : string
- $performDeepMerging : bool
- $prototype : NodeDefinition<string|int, $this>
- $removeExtraKeys : bool
- $removeKeyItem : bool
- $required : bool
- $trueEquivalent : mixed
- $validation : ValidationBuilder<string|int, $this>
Methods
- __construct() : mixed
- acceptAndWrap() : $this
- Allows alternative types and wraps them into arrays.
- addDefaultChildrenIfNoneSet() : $this
- Adds children with a default value when none are defined.
- addDefaultsIfNotSet() : $this
- Adds the default value if the node is not set in the configuration.
- append() : $this
- Appends a node definition.
- arrayPrototype() : self<$this>
- attribute() : $this
- Sets an attribute on the node.
- beforeNormalization() : ExprBuilder<string|int, $this>
- Sets an expression to run before the normalization.
- booleanPrototype() : BooleanNodeDefinition<string|int, $this>
- canBeDisabled() : $this
- Adds an "enabled" boolean to enable the current section.
- canBeEnabled() : $this
- Adds an "enabled" boolean to enable the current section.
- canBeUnset() : $this
- Sets whether the node can be unset.
- cannotBeEmpty() : $this
- Denies the node value being empty.
- cannotBeOverwritten() : $this
- Sets whether the node can be overwritten.
- children() : NodeBuilder<string|int, static>
- Returns a builder to add children nodes.
- defaultFalse() : $this
- Sets false as the default value.
- defaultNull() : $this
- Sets null as the default value.
- defaultTrue() : $this
- Sets true as the default value.
- defaultValue() : $this
- Sets the default value.
- disallowNewKeysInSubsequentConfigs() : $this
- Disallows adding news keys in a subsequent configuration.
- docUrl() : $this
- Sets the documentation URI, as usually put in the "@see" tag of a doc block. This can either be a URL or a file path. You can use the placeholders {package}, {version:major} and {version:minor} in the URI.
- end() : TParent
- Returns the parent node.
- enumPrototype() : EnumNodeDefinition<string|int, $this>
- example() : $this
- Sets example configuration.
- find() : NodeDefinition
- Finds a node defined by the given $nodePath.
- fixXmlConfig() : $this
- Sets a normalization rule for XML configurations.
- floatPrototype() : FloatNodeDefinition<string|int, $this>
- getChildNodeDefinitions() : array<string|int, NodeDefinition<string|int, $this>>
- Gets the child node definitions.
- getNode() : NodeInterface
- Creates the node.
- ignoreExtraKeys() : $this
- Allows extra config keys to be specified under an array without throwing an exception.
- info() : $this
- Sets info message.
- integerPrototype() : IntegerNodeDefinition<string|int, $this>
- isRequired() : $this
- Sets the node as required.
- normalizeKeys() : $this
- Sets whether to enable key normalization.
- performNoDeepMerging() : $this
- Disables the deep merging of the node.
- prototype() : : (\Symfony\Component\Config\Definition\Builder\T is "variable" ? \Symfony\Component\Config\Definition\Builder\VariableNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "scalar" ? \Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "string" ? \Symfony\Component\Config\Definition\Builder\StringNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "boolean" ? \Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "integer" ? \Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "float" ? \Symfony\Component\Config\Definition\Builder\FloatNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "enum" ? \Symfony\Component\Config\Definition\Builder\EnumNodeDefinition<$this> : \Symfony\Component\Config\Definition\Builder\NodeDefinition<$this>))))))))">NodeDefinition<$this>))))))))
- Sets a prototype for child nodes.
- requiresAtLeastOneElement() : $this
- Requires the node to have at least one element.
- scalarPrototype() : ScalarNodeDefinition<string|int, $this>
- setBuilder() : void
- Sets a custom children builder.
- setDeprecated() : $this
- Sets the node as deprecated.
- setParent() : $this
- Sets the parent node.
- setPathSeparator() : $this
- Set PathSeparator to use.
- stringPrototype() : StringNodeDefinition<string|int, $this>
- treatFalseLike() : $this
- Sets the equivalent value used when the node contains false.
- treatNullLike() : $this
- Sets the equivalent value used when the node contains null.
- treatTrueLike() : $this
- Sets the equivalent value used when the node contains true.
- useAttributeAsKey() : $this
- Sets the attribute which value is to be used as key.
- validate() : ExprBuilder<string|int, $this>
- Sets an expression to run for the validation.
- variablePrototype() : VariableNodeDefinition<string|int, $this>
- createNode() : NodeInterface
- Instantiate and configure the node according to this definition.
- getNodeBuilder() : NodeBuilder<string|int, static>
- Returns a node builder to be used to add children and prototype.
- merge() : MergeBuilder<string|int, $this>
- Gets the builder for merging rules.
- normalization() : NormalizationBuilder<string|int, $this>
- Gets the builder for normalization rules.
- validateConcreteNode() : void
- Validate the configuration of a concrete node.
- validatePrototypeNode() : void
- Validate the configuration of a prototype node.
- validation() : ValidationBuilder<string|int, $this>
- Gets the builder for validation rules.
Properties
$addDefaultChildren
protected
int|string|array<string|int, mixed>|false|null
$addDefaultChildren
= false
$addDefaults
protected
bool
$addDefaults
= false
$allowedTypes
protected
array<int, ExprBuilder::TYPE_*>|null
$allowedTypes
= null
$allowEmptyValue
protected
bool
$allowEmptyValue
= true
$allowNewKeys
protected
bool
$allowNewKeys
= true
$atLeastOne
protected
bool
$atLeastOne
= false
$attributes
protected
array<string|int, mixed>
$attributes
= []
$children
protected
array<string|int, NodeDefinition<string|int, $this>>
$children
= []
$default
protected
bool
$default
= false
$defaultValue
protected
mixed
$defaultValue
$deprecation
protected
array<string|int, mixed>
$deprecation
= []
$falseEquivalent
protected
mixed
$falseEquivalent
= false
$ignoreExtraKeys
protected
bool
$ignoreExtraKeys
= false
$key
protected
string|null
$key
= null
$merge
protected
MergeBuilder<string|int, $this>
$merge
$name
protected
string|null
$name
= null
$nodeBuilder
protected
NodeBuilder<string|int, static>
$nodeBuilder
$normalization
protected
NormalizationBuilder<string|int, $this>
$normalization
$normalizeKeys
protected
bool
$normalizeKeys
= true
$nullEquivalent
protected
mixed
$nullEquivalent
= null
$parent
protected
TParent|NodeInterface
$parent
$pathSeparator
protected
string
$pathSeparator
= \Symfony\Component\Config\Definition\BaseNode::DEFAULT_PATH_SEPARATOR
$performDeepMerging
protected
bool
$performDeepMerging
= true
$prototype
protected
NodeDefinition<string|int, $this>
$prototype
$removeExtraKeys
protected
bool
$removeExtraKeys
= true
$removeKeyItem
protected
bool
$removeKeyItem
= false
$required
protected
bool
$required
= false
$trueEquivalent
protected
mixed
$trueEquivalent
= true
$validation
protected
ValidationBuilder<string|int, $this>
$validation
Methods
__construct()
public
__construct(string|null $name[, TParent $parent = null ]) : mixed
Parameters
- $name : string|null
- $parent : TParent = null
acceptAndWrap()
Allows alternative types and wraps them into arrays.
public
acceptAndWrap(array<int, ExprBuilder::TYPE_INT|ExprBuilder::TYPE_STRING|ExprBuilder::TYPE_BOOL|ExprBuilder::TYPE_NULL|ExprBuilder::TYPE_BACKED_ENUM> $allowedTypes[, string|null $key = null ]) : $this
Parameters
- $allowedTypes : array<int, ExprBuilder::TYPE_INT|ExprBuilder::TYPE_STRING|ExprBuilder::TYPE_BOOL|ExprBuilder::TYPE_NULL|ExprBuilder::TYPE_BACKED_ENUM>
- $key : string|null = null
-
The key to wrap the value in
Return values
$thisaddDefaultChildrenIfNoneSet()
Adds children with a default value when none are defined.
public
addDefaultChildrenIfNoneSet([int|string|array<string|int, mixed>|null $children = null ]) : $this
This method is applicable to prototype nodes only.
Parameters
- $children : int|string|array<string|int, mixed>|null = null
-
The number of children|The child name|The children names to be added
Return values
$thisaddDefaultsIfNotSet()
Adds the default value if the node is not set in the configuration.
public
addDefaultsIfNotSet() : $this
This method is applicable to concrete nodes only (not to prototype nodes). If this function has been called and the node is not set during the finalization phase, it's default value will be derived from its children default values.
Return values
$thisappend()
Appends a node definition.
public
append(NodeDefinition $node) : $this
Usage:
$node = $parentNode ->children() ->scalarNode('foo')->end() ->scalarNode('baz')->end() ->append($this->getBarNodeDefinition()) ->end() ;
Parameters
- $node : NodeDefinition
Return values
$thisarrayPrototype()
public
arrayPrototype() : self<$this>
Return values
self<$this>attribute()
Sets an attribute on the node.
public
attribute(string $key, mixed $value) : $this
Parameters
- $key : string
- $value : mixed
Return values
$thisbeforeNormalization()
Sets an expression to run before the normalization.
public
beforeNormalization() : ExprBuilder<string|int, $this>
Return values
ExprBuilder<string|int, $this>booleanPrototype()
public
booleanPrototype() : BooleanNodeDefinition<string|int, $this>
Return values
BooleanNodeDefinition<string|int, $this>canBeDisabled()
Adds an "enabled" boolean to enable the current section.
public
canBeDisabled() : $this
By default, the section is enabled.
Return values
$thiscanBeEnabled()
Adds an "enabled" boolean to enable the current section.
public
canBeEnabled() : $this
By default, the section is disabled. If any configuration is specified then the node will be automatically enabled:
enableableArrayNode: {enabled: true, ...} # The config is enabled & default values get overridden enableableArrayNode: ~ # The config is enabled & use the default values enableableArrayNode: true # The config is enabled & use the default values enableableArrayNode: {other: value, ...} # The config is enabled & default values get overridden enableableArrayNode: {enabled: false, ...} # The config is disabled enableableArrayNode: false # The config is disabled
Return values
$thiscanBeUnset()
Sets whether the node can be unset.
public
canBeUnset([bool $allow = true ]) : $this
Parameters
- $allow : bool = true
Return values
$thiscannotBeEmpty()
Denies the node value being empty.
public
cannotBeEmpty() : $this
Return values
$thiscannotBeOverwritten()
Sets whether the node can be overwritten.
public
cannotBeOverwritten([bool $deny = true ]) : $this
Parameters
- $deny : bool = true
Return values
$thischildren()
Returns a builder to add children nodes.
public
children() : NodeBuilder<string|int, static>
Return values
NodeBuilder<string|int, static>defaultFalse()
Sets false as the default value.
public
defaultFalse() : $this
Return values
$thisdefaultNull()
Sets null as the default value.
public
defaultNull() : $this
Return values
$thisdefaultTrue()
Sets true as the default value.
public
defaultTrue() : $this
Return values
$thisdefaultValue()
Sets the default value.
public
defaultValue(mixed $value) : $this
Parameters
- $value : mixed
Return values
$thisdisallowNewKeysInSubsequentConfigs()
Disallows adding news keys in a subsequent configuration.
public
disallowNewKeysInSubsequentConfigs() : $this
If used all keys have to be defined in the same configuration file.
Return values
$thisdocUrl()
Sets the documentation URI, as usually put in the "@see" tag of a doc block. This can either be a URL or a file path. You can use the placeholders {package}, {version:major} and {version:minor} in the URI.
public
docUrl(string $uri[, string|null $package = null ]) : $this
Parameters
- $uri : string
- $package : string|null = null
Return values
$thisend()
Returns the parent node.
public
end() : TParent
Return values
TParentenumPrototype()
public
enumPrototype() : EnumNodeDefinition<string|int, $this>
Return values
EnumNodeDefinition<string|int, $this>example()
Sets example configuration.
public
example(string|array<string|int, mixed> $example) : $this
Parameters
- $example : string|array<string|int, mixed>
Return values
$thisfind()
Finds a node defined by the given $nodePath.
public
find(string $nodePath) : NodeDefinition
Parameters
- $nodePath : string
-
The path of the node to find. e.g "doctrine.orm.mappings"
Return values
NodeDefinitionfixXmlConfig()
Sets a normalization rule for XML configurations.
public
fixXmlConfig(string $singular[, string|null $plural = null ]) : $this
Parameters
- $singular : string
-
The key to remap
- $plural : string|null = null
-
The plural of the key for irregular plurals
Return values
$thisfloatPrototype()
public
floatPrototype() : FloatNodeDefinition<string|int, $this>
Return values
FloatNodeDefinition<string|int, $this>getChildNodeDefinitions()
Gets the child node definitions.
public
getChildNodeDefinitions() : array<string|int, NodeDefinition<string|int, $this>>
Return values
array<string|int, NodeDefinition<string|int, $this>>getNode()
Creates the node.
public
getNode([bool $forceRootNode = false ]) : NodeInterface
Parameters
- $forceRootNode : bool = false
Return values
NodeInterfaceignoreExtraKeys()
Allows extra config keys to be specified under an array without throwing an exception.
public
ignoreExtraKeys([bool $remove = true ]) : $this
Those config values are ignored and removed from the resulting array. This should be used only in special cases where you want to send an entire configuration array through a special tree that processes only part of the array.
Parameters
- $remove : bool = true
-
Whether to remove the extra keys
Return values
$thisinfo()
Sets info message.
public
info(string $info) : $this
Parameters
- $info : string
Return values
$thisintegerPrototype()
public
integerPrototype() : IntegerNodeDefinition<string|int, $this>
Return values
IntegerNodeDefinition<string|int, $this>isRequired()
Sets the node as required.
public
isRequired() : $this
Return values
$thisnormalizeKeys()
Sets whether to enable key normalization.
public
normalizeKeys(bool $bool) : $this
Parameters
- $bool : bool
Return values
$thisperformNoDeepMerging()
Disables the deep merging of the node.
public
performNoDeepMerging() : $this
Return values
$thisprototype()
Sets a prototype for child nodes.
public
prototype(T $type) : : (\Symfony\Component\Config\Definition\Builder\T is "variable" ? \Symfony\Component\Config\Definition\Builder\VariableNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "scalar" ? \Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "string" ? \Symfony\Component\Config\Definition\Builder\StringNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "boolean" ? \Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "integer" ? \Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "float" ? \Symfony\Component\Config\Definition\Builder\FloatNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "enum" ? \Symfony\Component\Config\Definition\Builder\EnumNodeDefinition<$this> : \Symfony\Component\Config\Definition\Builder\NodeDefinition<$this>))))))))">NodeDefinition<$this>))))))))
Parameters
- $type : T
Tags
Return values
: (\Symfony\Component\Config\Definition\Builder\T is "variable" ? \Symfony\Component\Config\Definition\Builder\VariableNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "scalar" ? \Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "string" ? \Symfony\Component\Config\Definition\Builder\StringNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "boolean" ? \Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "integer" ? \Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "float" ? \Symfony\Component\Config\Definition\Builder\FloatNodeDefinition<$this> : (\Symfony\Component\Config\Definition\Builder\T is "enum" ? \Symfony\Component\Config\Definition\Builder\EnumNodeDefinition<$this> : \Symfony\Component\Config\Definition\Builder\NodeDefinition<$this>))))))))">NodeDefinition<$this>))))))))requiresAtLeastOneElement()
Requires the node to have at least one element.
public
requiresAtLeastOneElement() : $this
This method is applicable to prototype nodes only.
Return values
$thisscalarPrototype()
public
scalarPrototype() : ScalarNodeDefinition<string|int, $this>
Return values
ScalarNodeDefinition<string|int, $this>setBuilder()
Sets a custom children builder.
public
setBuilder(NodeBuilder<string|int, static> $builder) : void
Parameters
- $builder : NodeBuilder<string|int, static>
setDeprecated()
Sets the node as deprecated.
public
setDeprecated(string $package, string $version[, string $message = 'The child node "%node%" at path "%path%" is deprecated.' ]) : $this
Parameters
- $package : string
-
The name of the composer package that is triggering the deprecation
- $version : string
-
The version of the package that introduced the deprecation
- $message : string = 'The child node "%node%" at path "%path%" is deprecated.'
-
the deprecation message to use
You can use %node% and %path% placeholders in your message to display, respectively, the node name and its complete path
Return values
$thissetParent()
Sets the parent node.
public
setParent(NodeParentInterface $parent) : $this
Parameters
- $parent : NodeParentInterface
Tags
Return values
$thissetPathSeparator()
Set PathSeparator to use.
public
setPathSeparator(string $separator) : $this
Parameters
- $separator : string
Return values
$thisstringPrototype()
public
stringPrototype() : StringNodeDefinition<string|int, $this>
Return values
StringNodeDefinition<string|int, $this>treatFalseLike()
Sets the equivalent value used when the node contains false.
public
treatFalseLike(mixed $value) : $this
Parameters
- $value : mixed
Return values
$thistreatNullLike()
Sets the equivalent value used when the node contains null.
public
treatNullLike(mixed $value) : $this
Parameters
- $value : mixed
Return values
$thistreatTrueLike()
Sets the equivalent value used when the node contains true.
public
treatTrueLike(mixed $value) : $this
Parameters
- $value : mixed
Return values
$thisuseAttributeAsKey()
Sets the attribute which value is to be used as key.
public
useAttributeAsKey(string $name[, bool $removeKeyItem = true ]) : $this
This is useful when you have an indexed array that should be an associative array. You can select an item from within the array to be the key of the particular item. For example, if "id" is the "key", then:
[
['id' => 'my_name', 'foo' => 'bar'],
];
becomes
[
'my_name' => ['foo' => 'bar'],
];
If you'd like "'id' => 'my_name'" to still be present in the resulting array, then you can set the second argument of this method to false.
This method is applicable to prototype nodes only.
Parameters
- $name : string
-
The name of the key
- $removeKeyItem : bool = true
-
Whether or not the key item should be removed
Return values
$thisvalidate()
Sets an expression to run for the validation.
public
validate() : ExprBuilder<string|int, $this>
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 values
ExprBuilder<string|int, $this>variablePrototype()
public
variablePrototype() : VariableNodeDefinition<string|int, $this>
Return values
VariableNodeDefinition<string|int, $this>createNode()
Instantiate and configure the node according to this definition.
protected
createNode() : NodeInterface
Return values
NodeInterfacegetNodeBuilder()
Returns a node builder to be used to add children and prototype.
protected
getNodeBuilder() : NodeBuilder<string|int, static>
Return values
NodeBuilder<string|int, static>merge()
Gets the builder for merging rules.
protected
merge() : MergeBuilder<string|int, $this>
Return values
MergeBuilder<string|int, $this>normalization()
Gets the builder for normalization rules.
protected
normalization() : NormalizationBuilder<string|int, $this>
Return values
NormalizationBuilder<string|int, $this>validateConcreteNode()
Validate the configuration of a concrete node.
protected
validateConcreteNode(ArrayNode $node) : void
Parameters
- $node : ArrayNode
Tags
validatePrototypeNode()
Validate the configuration of a prototype node.
protected
validatePrototypeNode(PrototypedArrayNode $node) : void
Parameters
- $node : PrototypedArrayNode
Tags
validation()
Gets the builder for validation rules.
protected
validation() : ValidationBuilder<string|int, $this>