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

setPrototype() public method

Sets the node prototype.
public setPrototype ( Symfony\Component\Config\Definition\PrototypeNodeInterface $node )
$node Symfony\Component\Config\Definition\PrototypeNodeInterface
    public function setPrototype(PrototypeNodeInterface $node)
    {
        $this->prototype = $node;
    }

Usage Example

 /**
  * Tests the opposite of the testMappedAttributeKeyIsRemoved because
  * the removal can be toggled with an option.
  */
 public function testMappedAttributeKeyNotRemoved()
 {
     $node = new PrototypedArrayNode('root');
     $node->setKeyAttribute('id', false);
     // each item under the root is an array, with two scalar items
     $prototype = new ArrayNode(null, $node);
     $prototype->addChild(new ScalarNode('foo'));
     $prototype->addChild(new ScalarNode('id'));
     // the key attribute will remain
     $node->setPrototype($prototype);
     $children = array();
     $children[] = array('id' => 'item_name', 'foo' => 'bar');
     $normalized = $node->normalize($children);
     $expected = array();
     $expected['item_name'] = array('id' => 'item_name', 'foo' => 'bar');
     $this->assertEquals($expected, $normalized);
 }
All Usage Examples Of Symfony\Component\Config\Definition\PrototypedArrayNode::setPrototype