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 : mixed
- $addDefaults : mixed
- $allowEmptyValue : mixed
- $allowNewKeys : mixed
- $atLeastOne : mixed
- $attributes : mixed
- $children : mixed
- $default : mixed
- $defaultValue : mixed
- $deprecation : mixed
- $falseEquivalent : mixed
- $ignoreExtraKeys : mixed
- $key : mixed
- $merge : mixed
- $name : mixed
- $nodeBuilder : mixed
- $normalization : mixed
- $normalizeKeys : mixed
- $nullEquivalent : mixed
- $parent : mixed
- $pathSeparator : mixed
- $performDeepMerging : mixed
- $prototype : mixed
- $removeExtraKeys : mixed
- $removeKeyItem : mixed
- $required : mixed
- $trueEquivalent : mixed
- $validation : mixed
Methods
- __construct() : mixed
- 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
- attribute() : $this
- Sets an attribute on the node.
- beforeNormalization() : ExprBuilder
- Sets an expression to run before the normalization.
- booleanPrototype() : BooleanNodeDefinition
- 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
- 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.
- end() : NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null
- Returns the parent node.
- enumPrototype() : EnumNodeDefinition
- 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
- getChildNodeDefinitions() : array<string|int, NodeDefinition>
- 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
- 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() : NodeDefinition
- Sets a prototype for child nodes.
- requiresAtLeastOneElement() : $this
- Requires the node to have at least one element.
- scalarPrototype() : ScalarNodeDefinition
- setBuilder() : mixed
- Sets a custom children builder.
- setDeprecated() : $this
- Sets the node as deprecated.
- setParent() : $this
- Sets the parent node.
- setPathSeparator() : $this
- Set PathSeparator to use.
- 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
- Sets an expression to run for the validation.
- variablePrototype() : VariableNodeDefinition
- createNode() : NodeInterface
- Instantiate and configure the node according to this definition.
- getNodeBuilder() : NodeBuilder
- Returns a node builder to be used to add children and prototype.
- merge() : MergeBuilder
- Gets the builder for merging rules.
- normalization() : NormalizationBuilder
- Gets the builder for normalization rules.
- validateConcreteNode() : mixed
- Validate the configuration of a concrete node.
- validatePrototypeNode() : mixed
- Validate the configuration of a prototype node.
- validation() : ValidationBuilder
- Gets the builder for validation rules.
Properties
$addDefaultChildren
protected
mixed
$addDefaultChildren
= false
$addDefaults
protected
mixed
$addDefaults
= false
$allowEmptyValue
protected
mixed
$allowEmptyValue
= true
$allowNewKeys
protected
mixed
$allowNewKeys
= true
$atLeastOne
protected
mixed
$atLeastOne
= false
$attributes
protected
mixed
$attributes
= []
$children
protected
mixed
$children
= []
$default
protected
mixed
$default
= false
$defaultValue
protected
mixed
$defaultValue
$deprecation
protected
mixed
$deprecation
= []
$falseEquivalent
protected
mixed
$falseEquivalent
= false
$ignoreExtraKeys
protected
mixed
$ignoreExtraKeys
= false
$key
protected
mixed
$key
$merge
protected
mixed
$merge
$name
protected
mixed
$name
$nodeBuilder
protected
mixed
$nodeBuilder
$normalization
protected
mixed
$normalization
$normalizeKeys
protected
mixed
$normalizeKeys
= true
$nullEquivalent
protected
mixed
$nullEquivalent
$parent
protected
mixed
$parent
$pathSeparator
protected
mixed
$pathSeparator
= \Symfony\Component\Config\Definition\BaseNode::DEFAULT_PATH_SEPARATOR
$performDeepMerging
protected
mixed
$performDeepMerging
= true
$prototype
protected
mixed
$prototype
$removeExtraKeys
protected
mixed
$removeExtraKeys
= true
$removeKeyItem
protected
mixed
$removeKeyItem
$required
protected
mixed
$required
= false
$trueEquivalent
protected
mixed
$trueEquivalent
= true
$validation
protected
mixed
$validation
Methods
__construct()
public
__construct(string|null $name[, NodeParentInterface $parent = null ]) : mixed
Parameters
- $name : string|null
- $parent : NodeParentInterface = null
addDefaultChildrenIfNoneSet()
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
Parameters
- $node : NodeDefinition
Return values
$thisarrayPrototype()
public
arrayPrototype() : self
Return values
selfattribute()
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
Return values
ExprBuilderbooleanPrototype()
public
booleanPrototype() : BooleanNodeDefinition
Return values
BooleanNodeDefinitioncanBeDisabled()
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
Return values
NodeBuilderdefaultFalse()
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
$thisend()
Returns the parent node.
public
end() : NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null
Return values
NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|nullenumPrototype()
public
enumPrototype() : EnumNodeDefinition
Return values
EnumNodeDefinitionexample()
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
Return values
FloatNodeDefinitiongetChildNodeDefinitions()
Gets the child node definitions.
public
getChildNodeDefinitions() : array<string|int, NodeDefinition>
Return values
array<string|int, NodeDefinition>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
Return values
IntegerNodeDefinitionisRequired()
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(string $type) : NodeDefinition
Parameters
- $type : string
Return values
NodeDefinitionrequiresAtLeastOneElement()
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
Return values
ScalarNodeDefinitionsetBuilder()
Sets a custom children builder.
public
setBuilder(NodeBuilder $builder) : mixed
Parameters
- $builder : NodeBuilder
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
Return values
$thissetPathSeparator()
Set PathSeparator to use.
public
setPathSeparator(string $separator) : $this
Parameters
- $separator : string
Return values
$thistreatFalseLike()
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
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
ExprBuildervariablePrototype()
public
variablePrototype() : VariableNodeDefinition
Return values
VariableNodeDefinitioncreateNode()
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
Return values
NodeBuildermerge()
Gets the builder for merging rules.
protected
merge() : MergeBuilder
Return values
MergeBuildernormalization()
Gets the builder for normalization rules.
protected
normalization() : NormalizationBuilder
Return values
NormalizationBuildervalidateConcreteNode()
Validate the configuration of a concrete node.
protected
validateConcreteNode(ArrayNode $node) : mixed
Parameters
- $node : ArrayNode
Tags
validatePrototypeNode()
Validate the configuration of a prototype node.
protected
validatePrototypeNode(PrototypedArrayNode $node) : mixed
Parameters
- $node : PrototypedArrayNode
Tags
validation()
Gets the builder for validation rules.
protected
validation() : ValidationBuilder