class PrototypedArrayNode extends ArrayNode

Represents a prototyped Array node in the config tree.

Properties

protected $name from BaseNode
protected $parent from BaseNode
protected $normalizationClosures from BaseNode
protected $finalValidationClosures from BaseNode
protected $allowOverwrite from BaseNode
protected $required from BaseNode
protected $equivalentValues from BaseNode
protected $attributes from BaseNode
protected $xmlRemappings from ArrayNode
protected $children from ArrayNode
protected $allowFalse from ArrayNode
protected $allowNewKeys from ArrayNode
protected $addIfNotSet from ArrayNode
protected $performDeepMerging from ArrayNode
protected $ignoreExtraKeys from ArrayNode
protected $removeExtraKeys from ArrayNode
protected $normalizeKeys from ArrayNode
protected $prototype
protected $keyAttribute
protected $removeKeyAttribute
protected $minNumberOfElements
protected $defaultValue
protected $defaultChildren

Methods

__construct(string|null $name, NodeInterface $parent = null)

No description

from BaseNode
setAttribute($key, $value)

No description

from BaseNode
getAttribute($key, $default = null)

No description

from BaseNode
hasAttribute($key)

No description

from BaseNode
getAttributes()

No description

from BaseNode
setAttributes(array $attributes)

No description

from BaseNode
removeAttribute($key)

No description

from BaseNode
setInfo(string $info)

Sets an info message.

from BaseNode
string
getInfo()

Returns info message.

from BaseNode
setExample(string|array $example)

Sets the example configuration for this node.

from BaseNode
string|array
getExample()

Retrieves the example configuration for this node.

from BaseNode
addEquivalentValue(mixed $originalValue, mixed $equivalentValue)

Adds an equivalent value.

from BaseNode
setRequired(bool $boolean)

Set this node as required.

from BaseNode
setAllowOverwrite(bool $allow)

Sets if this node can be overridden.

from BaseNode
setNormalizationClosures(array $closures)

Sets the closures used for normalization.

from BaseNode
setFinalValidationClosures(array $closures)

Sets the closures used for final validation.

from BaseNode
bool
isRequired()

Returns true when the node is required.

from BaseNode
string
getName()

Returns the name of the node.

from BaseNode
string
getPath()

Returns the path of the node.

from BaseNode
mixed
merge(mixed $leftSide, mixed $rightSide)

Merges two values together.

from BaseNode
mixed
normalize(mixed $value)

Normalizes a value.

from BaseNode
$value
preNormalize($value)

Normalizes keys between the different configuration formats.

from ArrayNode
getParent()

Returns parent node for this node.

from BaseNode
mixed
finalize(mixed $value)

Finalizes a value.

from BaseNode
validateType(mixed $value)

Validates the type of the value.

from ArrayNode
mixed
normalizeValue(mixed $value)

Normalizes the value.

mixed
mergeValues(mixed $leftSide, mixed $rightSide)

Merges values together.

mixed
finalizeValue(mixed $value)

Finalizes the value of this node.

setNormalizeKeys($normalizeKeys)

No description

from ArrayNode
array
getChildren()

Retrieves the children of this node.

from ArrayNode
setXmlRemappings(array $remappings)

Sets the xml remappings that should be performed.

from ArrayNode
array
getXmlRemappings()

Gets the xml remappings that should be performed.

from ArrayNode
setAddIfNotSet(bool $boolean)

Sets whether to add default values for this array if it has not been defined in any of the configuration files.

from ArrayNode
setAllowFalse(bool $allow)

Sets whether false is allowed as value indicating that the array should be unset.

from ArrayNode
setAllowNewKeys(bool $allow)

Sets whether new keys can be defined in subsequent configurations.

from ArrayNode
setPerformDeepMerging(bool $boolean)

Sets if deep merging should occur.

from ArrayNode
setIgnoreExtraKeys(bool $boolean, bool $remove = true)

Whether extra keys should just be ignore without an exception.

from ArrayNode
setName(string $name)

Sets the name of the node.

from ArrayNode
bool
hasDefaultValue()

Returns true when the node has a default value.

mixed
getDefaultValue()

Returns the default value of the node.

addChild(NodeInterface $node)

Disable adding concrete children for prototyped nodes.

array
remapXml(array $value)

Remaps multiple singular values to a single plural value.

from ArrayNode
setMinNumberOfElements(int $number)

Sets the minimum number of elements that a prototype based node must contain. By default this is zero, meaning no elements.

setKeyAttribute(string $attribute, bool $remove = true)

Sets the attribute which value is to be used as key.

string
getKeyAttribute()

Retrieves the name of the attribute which value should be used as key.

setDefaultValue(string $value)

Sets the default value of this node.

setAddChildrenIfNoneSet(int|string|array|null $children = array('defaults'))

Adds default children when none are set.

setPrototype(PrototypeNodeInterface $node)

Sets the node prototype.

getPrototype()

Retrieves the prototype.

Details

in BaseNode at line 41
__construct(string|null $name, NodeInterface $parent = null)

Parameters

string|null $name The name of the node
NodeInterface $parent The parent of this node

Exceptions

InvalidArgumentException if the name contains a period

in BaseNode at line 51
setAttribute($key, $value)

Parameters

$key
$value

in BaseNode at line 56
getAttribute($key, $default = null)

Parameters

$key
$default

in BaseNode at line 61
hasAttribute($key)

Parameters

$key

in BaseNode at line 66
getAttributes()

in BaseNode at line 71
setAttributes(array $attributes)

Parameters

array $attributes

in BaseNode at line 76
removeAttribute($key)

Parameters

$key

in BaseNode at line 86
setInfo(string $info)

Sets an info message.

Parameters

string $info

in BaseNode at line 96
string getInfo()

Returns info message.

Return Value

string The info text

in BaseNode at line 106
setExample(string|array $example)

Sets the example configuration for this node.

Parameters

string|array $example

in BaseNode at line 116
string|array getExample()

Retrieves the example configuration for this node.

Return Value

string|array The example

in BaseNode at line 127
addEquivalentValue(mixed $originalValue, mixed $equivalentValue)

Adds an equivalent value.

Parameters

mixed $originalValue
mixed $equivalentValue

in BaseNode at line 137
setRequired(bool $boolean)

Set this node as required.

Parameters

bool $boolean Required node

in BaseNode at line 147
setAllowOverwrite(bool $allow)

Sets if this node can be overridden.

Parameters

bool $allow

in BaseNode at line 157
setNormalizationClosures(array $closures)

Sets the closures used for normalization.

Parameters

array $closures An array of Closures used for normalization

in BaseNode at line 167
setFinalValidationClosures(array $closures)

Sets the closures used for final validation.

Parameters

array $closures An array of Closures used for final validation

in BaseNode at line 175
bool isRequired()

Returns true when the node is required.

Return Value

bool If the node is required

in BaseNode at line 183
string getName()

Returns the name of the node.

Return Value

string The name of the node

in BaseNode at line 191
string getPath()

Returns the path of the node.

Return Value

string The node path

in BaseNode at line 205
final mixed merge(mixed $leftSide, mixed $rightSide)

Merges two values together.

Parameters

mixed $leftSide
mixed $rightSide

Return Value

mixed The merged value

Exceptions

ForbiddenOverwriteException if the configuration path cannot be overwritten
InvalidTypeException if the value type is invalid

in BaseNode at line 220
final mixed normalize(mixed $value)

Normalizes a value.

Parameters

mixed $value The value to normalize

Return Value

mixed The normalized value

Exceptions

InvalidTypeException if the value type is invalid

in ArrayNode at line 53
protected $value preNormalize($value)

Normalizes keys between the different configuration formats.

Namely, you mostly have foo_bar in YAML while you have foo-bar in XML. After running this method, all keys are normalized to foo_bar.

If you have a mixed key like foo-bar_moo, it will not be altered. The key will also not be altered if the target key already exists.

Parameters

$value

Return Value

$value The normalized array value

in BaseNode at line 260
NodeInterface|null getParent()

Returns parent node for this node.

Return Value

NodeInterface|null

in BaseNode at line 268
final mixed finalize(mixed $value)

Finalizes a value.

Parameters

mixed $value The value to finalize

Return Value

mixed The finalized value

Exceptions

InvalidTypeException if the value type is invalid
InvalidConfigurationException if the value is invalid configuration

in ArrayNode at line 258
protected validateType(mixed $value)

Validates the type of the value.

Parameters

mixed $value The value to validate

Exceptions

InvalidTypeException

at line 220
protected mixed normalizeValue(mixed $value)

Normalizes the value.

Parameters

mixed $value The value to normalize

Return Value

mixed The normalized value

Exceptions

InvalidConfigurationException
DuplicateKeyException

at line 291
protected mixed mergeValues(mixed $leftSide, mixed $rightSide)

Merges values together.

Parameters

mixed $leftSide
mixed $rightSide

Return Value

mixed The merged value

Exceptions

InvalidConfigurationException
RuntimeException

at line 185
protected mixed finalizeValue(mixed $value)

Finalizes the value of this node.

Parameters

mixed $value The value to finalize

Return Value

mixed The finalized value

Exceptions

UnsetKeyException
InvalidConfigurationException if the node doesn't have enough children

in ArrayNode at line 35
setNormalizeKeys($normalizeKeys)

Parameters

$normalizeKeys

in ArrayNode at line 77
array getChildren()

Retrieves the children of this node.

Return Value

array The children

in ArrayNode at line 87
setXmlRemappings(array $remappings)

Sets the xml remappings that should be performed.

Parameters

array $remappings An array of the form array(array(string, string))

in ArrayNode at line 97
array getXmlRemappings()

Gets the xml remappings that should be performed.

Return Value

array $remappings an array of the form array(array(string, string))

in ArrayNode at line 108
setAddIfNotSet(bool $boolean)

Sets whether to add default values for this array if it has not been defined in any of the configuration files.

Parameters

bool $boolean

in ArrayNode at line 118
setAllowFalse(bool $allow)

Sets whether false is allowed as value indicating that the array should be unset.

Parameters

bool $allow

in ArrayNode at line 128
setAllowNewKeys(bool $allow)

Sets whether new keys can be defined in subsequent configurations.

Parameters

bool $allow

in ArrayNode at line 138
setPerformDeepMerging(bool $boolean)

Sets if deep merging should occur.

Parameters

bool $boolean

in ArrayNode at line 149
setIgnoreExtraKeys(bool $boolean, bool $remove = true)

Whether extra keys should just be ignore without an exception.

Parameters

bool $boolean To allow extra keys
bool $remove To remove extra keys

in ArrayNode at line 158
setName(string $name)

Sets the name of the node.

Parameters

string $name The name of the node

at line 107
bool hasDefaultValue()

Returns true when the node has a default value.

Return Value

bool If the node has a default value

at line 132
mixed getDefaultValue()

Returns the default value of the node.

Return Value

mixed The default value

Exceptions

RuntimeException if the node has no default value

at line 170
addChild(NodeInterface $node)

Disable adding concrete children for prototyped nodes.

Parameters

NodeInterface $node

Exceptions

Exception

in ArrayNode at line 316
protected array remapXml(array $value)

Remaps multiple singular values to a single plural value.

Parameters

array $value The source values

Return Value

array The remapped values

at line 43
setMinNumberOfElements(int $number)

Sets the minimum number of elements that a prototype based node must contain. By default this is zero, meaning no elements.

Parameters

int $number

at line 72
setKeyAttribute(string $attribute, bool $remove = true)

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.

Parameters

string $attribute The name of the attribute which value is to be used as a key
bool $remove Whether or not to remove the key

at line 83
string getKeyAttribute()

Retrieves the name of the attribute which value should be used as key.

Return Value

string The name of the attribute

at line 95
setDefaultValue(string $value)

Sets the default value of this node.

Parameters

string $value

Exceptions

InvalidArgumentException if the default value is not an array

at line 117
setAddChildrenIfNoneSet(int|string|array|null $children = array('defaults'))

Adds default children when none are set.

Parameters

int|string|array|null $children The number of children|The child name|The children names to be added

at line 150
setPrototype(PrototypeNodeInterface $node)

Sets the node prototype.

Parameters

PrototypeNodeInterface $node

at line 160
PrototypeNodeInterface getPrototype()

Retrieves the prototype.

Return Value

PrototypeNodeInterface The prototype