Symfony\Component\Config\Definition\PrototypedArrayNode::getDefaultValue PHP Method

getDefaultValue() public method

The default value could be either explicited or derived from the prototype default value.
public getDefaultValue ( ) : array
return array The default value
    public function getDefaultValue()
    {
        if (null !== $this->defaultChildren) {
            $default = $this->prototype->hasDefaultValue() ? $this->prototype->getDefaultValue() : array();
            $defaults = array();
            foreach (array_values($this->defaultChildren) as $i => $name) {
                $defaults[null === $this->keyAttribute ? $i : $name] = $default;
            }
            return $defaults;
        }
        return $this->defaultValue;
    }

Usage Example

 public function testGetDefaultValueReturnsDefaultValueForPrototypes()
 {
     $node = new PrototypedArrayNode('root');
     $prototype = new ArrayNode(null, $node);
     $node->setPrototype($prototype);
     $node->setDefaultValue(array('test'));
     $this->assertEquals(array('test'), $node->getDefaultValue());
 }