[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/symfony/config/Definition/ -> PrototypedArrayNode.php (summary)

(no description)

File Size: 377 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

PrototypedArrayNode:: (14 methods):
  setMinNumberOfElements()
  setKeyAttribute()
  getKeyAttribute()
  setDefaultValue()
  hasDefaultValue()
  setAddChildrenIfNoneSet()
  getDefaultValue()
  setPrototype()
  getPrototype()
  addChild()
  finalizeValue()
  normalizeValue()
  mergeValues()
  getPrototypeForChild()


Class: PrototypedArrayNode  - X-Ref

Represents a prototyped Array node in the config tree.

setMinNumberOfElements($number)   X-Ref
Sets the minimum number of elements that a prototype based node must
contain. By default this is zero, meaning no elements.

param: int $number

setKeyAttribute($attribute, $remove = true)   X-Ref
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:

[
['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.

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

getKeyAttribute()   X-Ref
Retrieves the name of the attribute which value should be used as key.

return: string|null The name of the attribute

setDefaultValue($value)   X-Ref
Sets the default value of this node.

param: string $value

hasDefaultValue()   X-Ref
{@inheritdoc}


setAddChildrenIfNoneSet($children = ['defaults'])   X-Ref
Adds default children when none are set.

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

getDefaultValue()   X-Ref
{@inheritdoc}

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

setPrototype(PrototypeNodeInterface $node)   X-Ref
Sets the node prototype.


getPrototype()   X-Ref
Retrieves the prototype.

return: PrototypeNodeInterface The prototype

addChild(NodeInterface $node)   X-Ref
Disable adding concrete children for prototyped nodes.


finalizeValue($value)   X-Ref
Finalizes the value of this node.

param: mixed $value
return: mixed The finalized value

normalizeValue($value)   X-Ref
Normalizes the value.

param: mixed $value The value to normalize
return: mixed The normalized value

mergeValues($leftSide, $rightSide)   X-Ref
Merges values together.

param: mixed $leftSide  The left side to merge
param: mixed $rightSide The right side to merge
return: mixed The merged values

getPrototypeForChild($key)   X-Ref
Returns a prototype for the child node that is associated to $key in the value array.
For general child nodes, this will be $this->prototype.
But if $this->removeKeyAttribute is true and there are only two keys in the child node:
one is same as this->keyAttribute and the other is 'value', then the prototype will be different.

For example, assume $this->keyAttribute is 'name' and the value array is as follows:

[
[
'name' => 'name001',
'value' => 'value001'
]
]

Now, the key is 0 and the child node is:

[
'name' => 'name001',
'value' => 'value001'
]

When normalizing the value array, the 'name' element will removed from the child node
and its value becomes the new key of the child node:

[
'name001' => ['value' => 'value001']
]

Now only 'value' element is left in the child node which can be further simplified into a string:

['name001' => 'value001']

Now, the key becomes 'name001' and the child node becomes 'value001' and
the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance.

param: string $key The key of the child node
return: mixed The prototype instance



Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1