class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinitionInterface
This class provides a fluent interface for defining an array node.
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 | |
protected | $performDeepMerging | ||
protected | $ignoreExtraKeys | ||
protected | $removeExtraKeys | ||
protected | $children | ||
protected | $prototype | ||
protected | $atLeastOne | ||
protected | $allowNewKeys | ||
protected | $key | ||
protected | $removeKeyItem | ||
protected | $addDefaults | ||
protected | $addDefaultChildren | ||
protected | $nodeBuilder | ||
protected | $normalizeKeys |
__construct(string|null $name, NodeParentInterface $parent = null) | ||
$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. | |
$this | setPathSeparator(string $separator) Set PathSeparator to use. | from NodeDefinition |
setBuilder(NodeBuilder $builder) Sets a custom children builder. | ||
NodeBuilder | children() Returns a builder to add children nodes. | |
NodeDefinition | prototype(string $type) Sets a prototype for child nodes. | |
VariableNodeDefinition | variablePrototype() | |
ScalarNodeDefinition | scalarPrototype() | |
BooleanNodeDefinition | booleanPrototype() | |
IntegerNodeDefinition | integerPrototype() | |
FloatNodeDefinition | floatPrototype() | |
ArrayNodeDefinition | arrayPrototype() | |
EnumNodeDefinition | enumPrototype() | |
$this | addDefaultsIfNotSet() Adds the default value if the node is not set in the configuration. | |
$this | addDefaultChildrenIfNoneSet(int|string|array|null $children = null) Adds children with a default value when none are defined. | |
$this | requiresAtLeastOneElement() Requires the node to have at least one element. | |
$this | disallowNewKeysInSubsequentConfigs() Disallows adding news keys in a subsequent configuration. | |
$this | fixXmlConfig(string $singular, string $plural = null) Sets a normalization rule for XML configurations. | |
$this | useAttributeAsKey(string $name, bool $removeKeyItem = true) Sets the attribute which value is to be used as key. | |
$this | canBeUnset(bool $allow = true) Sets whether the node can be unset. | |
$this | canBeEnabled() Adds an "enabled" boolean to enable the current section. | |
$this | canBeDisabled() Adds an "enabled" boolean to enable the current section. | |
$this | performNoDeepMerging() Disables the deep merging of the node. | |
$this | ignoreExtraKeys(bool $remove = true) Allows extra config keys to be specified under an array without throwing an exception. | |
$this | normalizeKeys(bool $bool) Sets key normalization. | |
$this | append(NodeDefinition $node) Appends a node definition. | |
NodeBuilder | getNodeBuilder() Returns a node builder to be used to add children and prototype. | |
validateConcreteNode(ArrayNode $node) Validate the configuration of a concrete node. | ||
validatePrototypeNode(PrototypedArrayNode $node) Validate the configuration of a prototype node. | ||
NodeDefinition[] | getChildNodeDefinitions() |
string|null | $name | |
NodeParentInterface | $parent |
Sets the parent node.
NodeParentInterface | $parent |
$this |
Sets info message.
string | $info | The info text |
$this |
Sets example configuration.
string|array | $example |
$this |
Sets an attribute on the node.
string | $key | |
mixed | $value |
$this |
Returns the parent node.
NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null | The builder of the parent node |
Creates the node.
bool | $forceRootNode | Whether to force this node as the root node |
NodeInterface |
Sets the default value.
mixed | $value | The default value |
$this |
Sets the node as required.
$this |
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.
string | $message | Deprecation message |
$this |
Sets the equivalent value used when the node contains null.
mixed | $value |
$this |
Sets the equivalent value used when the node contains true.
mixed | $value |
$this |
Sets the equivalent value used when the node contains false.
mixed | $value |
$this |
Sets null as the default value.
$this |
Sets true as the default value.
$this |
Sets false as the default value.
$this |
Sets an expression to run before the normalization.
ExprBuilder |
Denies the node value being empty.
$this |
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.
ExprBuilder |
Sets whether the node can be overwritten.
bool | $deny | Whether the overwriting is forbidden or not |
$this |
Gets the builder for validation rules.
ValidationBuilder |
Gets the builder for merging rules.
MergeBuilder |
Gets the builder for normalization rules.
NormalizationBuilder |
Instantiate and configure the node according to this definition.
NodeInterface | $node The node instance |
InvalidDefinitionException | When the definition is invalid |
Set PathSeparator to use.
string | $separator |
$this |
Sets a custom children builder.
NodeBuilder | $builder |
Returns a builder to add children nodes.
NodeBuilder |
Sets a prototype for child nodes.
string | $type | The type of node |
NodeDefinition |
VariableNodeDefinition |
ScalarNodeDefinition |
BooleanNodeDefinition |
IntegerNodeDefinition |
FloatNodeDefinition |
ArrayNodeDefinition |
EnumNodeDefinition |
Adds the default value if the node is not set in the configuration.
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.
$this |
Adds children with a default value when none are defined.
This method is applicable to prototype nodes only.
int|string|array|null | $children | The number of children|The child name|The children names to be added |
$this |
Requires the node to have at least one element.
This method is applicable to prototype nodes only.
$this |
Disallows adding news keys in a subsequent configuration.
If used all keys have to be defined in the same configuration file.
$this |
Sets a normalization rule for XML configurations.
string | $singular | The key to remap |
string | $plural | The plural of the key for irregular plurals |
$this |
Sets the attribute which value is to be used as key.
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:
array(
array('id' => 'my_name', 'foo' => 'bar'),
);
becomes
array(
'my_name' => array('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.
string | $name | The name of the key |
bool | $removeKeyItem | Whether or not the key item should be removed |
$this |
Sets whether the node can be unset.
bool | $allow |
$this |
Adds an "enabled" boolean to enable the current section.
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
$this |
Adds an "enabled" boolean to enable the current section.
By default, the section is enabled.
$this |
Disables the deep merging of the node.
$this |
Allows extra config keys to be specified under an array without throwing an exception.
Those config values are simply 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.
bool | $remove | Whether to remove the extra keys |
$this |
Sets key normalization.
bool | $bool | Whether to enable key normalization |
$this |
Appends a node definition.
Usage:
$node = $parentNode
->children()
->scalarNode('foo')->end()
->scalarNode('baz')->end()
->append($this->getBarNodeDefinition())
->end()
;
NodeDefinition | $node |
$this |
Returns a node builder to be used to add children and prototype.
NodeBuilder | The node builder |
Validate the configuration of a concrete node.
ArrayNode | $node |
InvalidDefinitionException |
Validate the configuration of a prototype node.
PrototypedArrayNode | $node |
InvalidDefinitionException |
NodeDefinition[] |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.html