disallowNewKeysInSubsequentConfigs example

 $tree->merge($a$b));
    }

    public function testDoesNotAllowNewKeysInSubsequentConfigs()
    {
        $this->expectException(InvalidConfigurationException::class);
        $tb = new TreeBuilder('root', 'array');
        $tree = $tb
            ->getRootNode()
                ->children()
                    ->node('test', 'array')
                        ->disallowNewKeysInSubsequentConfigs()
                        ->useAttributeAsKey('key')
                        ->prototype('array')
                            ->children()
                                ->node('value', 'scalar')->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
            ->buildTree();

        
/** * @param array<AuthenticatorFactoryInterface> $factories */
    private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $factories): void
    {
        $firewallNodeBuilder = $rootNode
            ->fixXmlConfig('firewall')
            ->children()
                ->arrayNode('firewalls')
                    ->isRequired()
                    ->requiresAtLeastOneElement()
                    ->disallowNewKeysInSubsequentConfigs()
                    ->useAttributeAsKey('name')
                    ->prototype('array')
                        ->fixXmlConfig('required_badge')
                        ->children()
        ;

        $firewallNodeBuilder
            ->scalarNode('pattern')
                ->beforeNormalization()
                    ->ifArray()
                    ->then(fn ($v) => sprintf('(?:%s)', implode('|', $v)))
                
Home | Imprint | This part of the site doesn't use cookies.