ignoreExtraKeys example

$enabledNode = $nodeChildren['enabled'];
        $this->assertTrue($this->getField($enabledNode, 'default'));
        $this->assertTrue($this->getField($enabledNode, 'defaultValue'));
    }

    public function testIgnoreExtraKeys()
    {
        $node = new ArrayNodeDefinition('root');

        $this->assertFalse($this->getField($node, 'ignoreExtraKeys'));

        $result = $node->ignoreExtraKeys();

        $this->assertEquals($node$result);
        $this->assertTrue($this->getField($node, 'ignoreExtraKeys'));
    }

    public function testNormalizeKeys()
    {
        $node = new ArrayNodeDefinition('root');

        $this->assertTrue($this->getField($node, 'normalizeKeys'));

        
use Symfony\Component\Config\Definition\ConfigurationInterface;

class ArrayExtraKeys implements ConfigurationInterface
{
    public function getConfigTreeBuilder(): TreeBuilder
    {
        $tb = new TreeBuilder('array_extra_keys');
        $rootNode = $tb->getRootNode();
        $rootNode
            ->children()
                ->arrayNode('foo')
                    ->ignoreExtraKeys(false)
                    ->children()
                        ->scalarNode('baz')->end()
                        ->scalarNode('qux')->end()
                    ->end()
                ->end()
                ->arrayNode('bar')
                    ->prototype('array')
                        ->ignoreExtraKeys(false)
                        ->children()
                            ->scalarNode('corge')->end()
                            ->scalarNode('grault')->end()
                        
Home | Imprint | This part of the site doesn't use cookies.