W3cubDocs

/Symfony 2.8

Symfony\Component\Config\Definition\PrototypedArrayNode

class PrototypedArrayNode extends ArrayNode

Represents a prototyped Array node in the config tree.

Methods

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

Constructor.

from BaseNode
setAttribute($key, $value) from BaseNode
getAttribute($key, $default = null) from BaseNode
hasAttribute($key) from BaseNode
getAttributes() from BaseNode
setAttributes(array $attributes) from BaseNode
removeAttribute($key) 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()

Checks if this node is required.

from BaseNode
string getName()

Returns the name of this node.

from BaseNode
string getPath()

Retrieves the path of this node.

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

Merges two values together.

from BaseNode
mixed normalize(mixed $value)

Normalizes a value, applying all normalization closures.

from BaseNode
NodeInterface|null getParent()

Returns parent node for this node.

from BaseNode
mixed finalize(mixed $value)

Finalizes a value, applying all finalization closures.

from BaseNode
setNormalizeKeys($normalizeKeys) 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 node Name.

from ArrayNode
bool hasDefaultValue()

Checks if the node has a default value.

array getDefaultValue()

Retrieves the default value.

addChild(NodeInterface $node)

Disable adding concrete children for prototyped nodes.

setMinNumberOfElements(int $number)

Sets the minimum number of elements that a prototype based node must contain.

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.

PrototypeNodeInterface getPrototype()

Retrieves the prototype.

Details

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

Constructor.

Parameters

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

Exceptions

InvalidArgumentException if the name contains a period.

public setAttribute($key, $value)

Parameters

$key
$value

public getAttribute($key, $default = null)

Parameters

$key
$default

public hasAttribute($key)

Parameters

$key

public getAttributes()

public setAttributes(array $attributes)

Parameters

array $attributes

public removeAttribute($key)

Parameters

$key

public setInfo(string $info)

Sets an info message.

Parameters

string $info

public string getInfo()

Returns info message.

Return Value

string The info text

public setExample(string|array $example)

Sets the example configuration for this node.

Parameters

string|array $example

public string|array getExample()

Retrieves the example configuration for this node.

Return Value

string|array The example

public addEquivalentValue(mixed $originalValue, mixed $equivalentValue)

Adds an equivalent value.

Parameters

mixed $originalValue
mixed $equivalentValue

public setRequired(bool $boolean)

Set this node as required.

Parameters

bool $boolean Required node

public setAllowOverwrite(bool $allow)

Sets if this node can be overridden.

Parameters

bool $allow

public setNormalizationClosures(array $closures)

Sets the closures used for normalization.

Parameters

array $closures An array of Closures used for normalization

public setFinalValidationClosures(array $closures)

Sets the closures used for final validation.

Parameters

array $closures An array of Closures used for final validation

public bool isRequired()

Checks if this node is required.

Return Value

bool If the node is required

public string getName()

Returns the name of this node.

Return Value

string The Node's name.

public string getPath()

Retrieves the path of this node.

Return Value

string The Node's path

final public mixed merge(mixed $leftSide, mixed $rightSide)

Merges two values together.

Parameters

mixed $leftSide
mixed $rightSide

Return Value

mixed The merged value

Exceptions

ForbiddenOverwriteException

final public mixed normalize(mixed $value)

Normalizes a value, applying all normalization closures.

Parameters

mixed $value Value to normalize.

Return Value

mixed The normalized value.

public NodeInterface|null getParent()

Returns parent node for this node.

Return Value

NodeInterface|null

final public mixed finalize(mixed $value)

Finalizes a value, applying all finalization closures.

Parameters

mixed $value The value to finalize

Return Value

mixed The finalized value

Exceptions

Exception
InvalidConfigurationException

public setNormalizeKeys($normalizeKeys)

Parameters

$normalizeKeys

public array getChildren()

Retrieves the children of this node.

Return Value

array The children

public setXmlRemappings(array $remappings)

Sets the xml remappings that should be performed.

Parameters

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

public array getXmlRemappings()

Gets the xml remappings that should be performed.

Return Value

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

public 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

public setAllowFalse(bool $allow)

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

Parameters

bool $allow

public setAllowNewKeys(bool $allow)

Sets whether new keys can be defined in subsequent configurations.

Parameters

bool $allow

public setPerformDeepMerging(bool $boolean)

Sets if deep merging should occur.

Parameters

bool $boolean

public 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

public setName(string $name)

Sets the node Name.

Parameters

string $name The node's name

public bool hasDefaultValue()

Checks if the node has a default value.

Return Value

bool If the node has a default value

public array getDefaultValue()

Retrieves the default value.

The default value could be either explicited or derived from the prototype default value.

Return Value

array The default value

public addChild(NodeInterface $node)

Disable adding concrete children for prototyped nodes.

Parameters

NodeInterface $node The child node to add

Exceptions

Exception

public 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

public 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

public string getKeyAttribute()

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

Return Value

string The name of the attribute

public setDefaultValue(string $value)

Sets the default value of this node.

Parameters

string $value

Exceptions

InvalidArgumentException if the default value is not an array

public 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

public setPrototype(PrototypeNodeInterface $node)

Sets the node prototype.

Parameters

PrototypeNodeInterface $node

public PrototypeNodeInterface getPrototype()

Retrieves the prototype.

Return Value

PrototypeNodeInterface The prototype

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/Config/Definition/PrototypedArrayNode.html