Documentation

ArrayNodeDefinition extends NodeDefinition
in package
implements ParentNodeDefinitionInterface

This class provides a fluent interface for defining an array node.

Tags
author

Johannes M. Schmitt schmittjoh@gmail.com

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

$pathSeparator

protected mixed $pathSeparator = SymfonyComponentConfigDefinitionBaseNode::DEFAULT_PATH_SEPARATOR

Methods

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

attribute()

Sets an attribute on the node.

public attribute(string $key, mixed $value) : $this
Parameters
$key : string
$value : mixed
Return values
$this

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

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

example()

Sets example configuration.

public example(string|array<string|int, mixed> $example) : $this
Parameters
$example : string|array<string|int, mixed>
Return values
$this

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

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

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

requiresAtLeastOneElement()

Requires the node to have at least one element.

public requiresAtLeastOneElement() : $this

This method is applicable to prototype nodes only.

Return values
$this

setDeprecated()

Sets the node as deprecated.

public setDeprecated() : $this
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

Search results