ArrayNodeDefinition
extends NodeDefinition
in package
implements
ParentNodeDefinitionInterface
This class provides a fluent interface for defining an array node.
Tags
Interfaces, Classes and Traits
- ParentNodeDefinitionInterface
- An interface that must be implemented by nodes which can have children.
Table of Contents
- $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
- __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() : ArrayNodeDefinition
- 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
- {@inheritdoc}
- 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
= SymfonyComponentConfigDefinitionBaseNode::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|null $parent = null ]) : mixed
Parameters
- $name : string|null
- $parent : NodeParentInterface|null = null
Return values
mixed —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
$this —addDefaultsIfNotSet()
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
$this —append()
Appends a node definition.
public
append(NodeDefinition $node) : $this
Parameters
- $node : NodeDefinition
Return values
$this —arrayPrototype()
public
arrayPrototype() : ArrayNodeDefinition
Return values
ArrayNodeDefinition —attribute()
Sets an attribute on the node.
public
attribute(string $key, mixed $value) : $this
Parameters
- $key : string
- $value : mixed
Return values
$this —beforeNormalization()
Sets an expression to run before the normalization.
public
beforeNormalization() : ExprBuilder
Return values
ExprBuilder —booleanPrototype()
public
booleanPrototype() : BooleanNodeDefinition
Return values
BooleanNodeDefinition —canBeDisabled()
Adds an "enabled" boolean to enable the current section.
public
canBeDisabled() : $this
By default, the section is enabled.
Return values
$this —canBeEnabled()
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
$this —canBeUnset()
Sets whether the node can be unset.
public
canBeUnset([bool $allow = true ]) : $this
Parameters
- $allow : bool = true
Return values
$this —cannotBeEmpty()
Denies the node value being empty.
public
cannotBeEmpty() : $this
Return values
$this —cannotBeOverwritten()
Sets whether the node can be overwritten.
public
cannotBeOverwritten([bool $deny = true ]) : $this
Parameters
- $deny : bool = true
Return values
$this —children()
Returns a builder to add children nodes.
public
children() : NodeBuilder
Return values
NodeBuilder —defaultFalse()
Sets false as the default value.
public
defaultFalse() : $this
Return values
$this —defaultNull()
Sets null as the default value.
public
defaultNull() : $this
Return values
$this —defaultTrue()
Sets true as the default value.
public
defaultTrue() : $this
Return values
$this —defaultValue()
Sets the default value.
public
defaultValue(mixed $value) : $this
Parameters
- $value : mixed
-
The default value
Return values
$this —disallowNewKeysInSubsequentConfigs()
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
$this —end()
Returns the parent node.
public
end() : NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null
Return values
NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null —enumPrototype()
public
enumPrototype() : EnumNodeDefinition
Return values
EnumNodeDefinition —example()
Sets example configuration.
public
example(string|array<string|int, mixed> $example) : $this
Parameters
- $example : string|array<string|int, mixed>
Return values
$this —find()
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
NodeDefinition —fixXmlConfig()
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
$this —floatPrototype()
public
floatPrototype() : FloatNodeDefinition
Return values
FloatNodeDefinition —getChildNodeDefinitions()
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
NodeInterface —ignoreExtraKeys()
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
$this —info()
Sets info message.
public
info(string $info) : $this
Parameters
- $info : string
Return values
$this —integerPrototype()
public
integerPrototype() : IntegerNodeDefinition
Return values
IntegerNodeDefinition —isRequired()
Sets the node as required.
public
isRequired() : $this
Return values
$this —normalizeKeys()
Sets whether to enable key normalization.
public
normalizeKeys(bool $bool) : $this
Parameters
- $bool : bool
Return values
$this —performNoDeepMerging()
Disables the deep merging of the node.
public
performNoDeepMerging() : $this
Return values
$this —prototype()
Sets a prototype for child nodes.
public
prototype(string $type) : NodeDefinition
Parameters
- $type : string
Return values
NodeDefinition —requiresAtLeastOneElement()
Requires the node to have at least one element.
public
requiresAtLeastOneElement() : $this
This method is applicable to prototype nodes only.
Return values
$this —scalarPrototype()
public
scalarPrototype() : ScalarNodeDefinition
Return values
ScalarNodeDefinition —setBuilder()
{@inheritdoc}
public
setBuilder(NodeBuilder $builder) : mixed
Parameters
- $builder : NodeBuilder
Return values
mixed —setDeprecated()
Sets the node as deprecated.
public
setDeprecated() : $this
Return values
$this —setParent()
Sets the parent node.
public
setParent(NodeParentInterface $parent) : $this
Parameters
- $parent : NodeParentInterface
Return values
$this —setPathSeparator()
Set PathSeparator to use.
public
setPathSeparator(string $separator) : $this
Parameters
- $separator : string
Return values
$this —treatFalseLike()
Sets the equivalent value used when the node contains false.
public
treatFalseLike(mixed $value) : $this
Parameters
- $value : mixed
Return values
$this —treatNullLike()
Sets the equivalent value used when the node contains null.
public
treatNullLike(mixed $value) : $this
Parameters
- $value : mixed
Return values
$this —treatTrueLike()
Sets the equivalent value used when the node contains true.
public
treatTrueLike(mixed $value) : $this
Parameters
- $value : mixed
Return values
$this —useAttributeAsKey()
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
$this —validate()
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
ExprBuilder —variablePrototype()
public
variablePrototype() : VariableNodeDefinition
Return values
VariableNodeDefinition —createNode()
Instantiate and configure the node according to this definition.
protected
createNode() : NodeInterface
Return values
NodeInterface —getNodeBuilder()
Returns a node builder to be used to add children and prototype.
protected
getNodeBuilder() : NodeBuilder
Return values
NodeBuilder —merge()
Gets the builder for merging rules.
protected
merge() : MergeBuilder
Return values
MergeBuilder —normalization()
Gets the builder for normalization rules.
protected
normalization() : NormalizationBuilder
Return values
NormalizationBuilder —validateConcreteNode()
Validate the configuration of a concrete node.
protected
validateConcreteNode(ArrayNode $node) : mixed
Parameters
- $node : ArrayNode
Tags
Return values
mixed —validatePrototypeNode()
Validate the configuration of a prototype node.
protected
validatePrototypeNode(PrototypedArrayNode $node) : mixed
Parameters
- $node : PrototypedArrayNode
Tags
Return values
mixed —validation()
Gets the builder for validation rules.
protected
validation() : ValidationBuilder