enumPrototype example

'6.3',
                            'The "%node%" option is deprecated. Use "csrf_token_manager" instead.'
                        )
                    ->end()
                    ->scalarNode('csrf_token_manager')->end()
                    ->scalarNode('path')->defaultValue('/logout')->end()
                    ->scalarNode('target')->defaultValue('/')->end()
                    ->booleanNode('invalidate_session')->defaultTrue()->end()
                    ->arrayNode('clear_site_data')
                        ->performNoDeepMerging()
                        ->beforeNormalization()->ifString()->then(fn ($v) => $v ? array_map('trim', explode(',', $v)) : [])->end()
                        ->enumPrototype()
                            ->values([
                                '*', 'cache', 'cookies', 'storage', 'executionContexts',
                            ])
                        ->end()
                    ->end()
                ->end()
                ->fixXmlConfig('delete_cookie')
                ->children()
                    ->arrayNode('delete_cookies')
                        ->normalizeKeys(false)
                        ->beforeNormalization()
                            


    public function testPrototypeArray()
    {
        $node = new ArrayNodeDefinition('root');
        $this->assertEquals($node->prototype('array')$node->arrayPrototype());
    }

    public function testPrototypeEnum()
    {
        $node = new ArrayNodeDefinition('root');
        $this->assertEquals($node->prototype('enum')$node->enumPrototype());
    }

    public static function getEnableableNodeFixtures(): array
    {
        return [
            [['enabled' => true, 'foo' => 'bar'][true], 'true enables an enableable node'],
            [['enabled' => true, 'foo' => 'bar'][null], 'null enables an enableable node'],
            [['enabled' => true, 'foo' => 'bar'][['enabled' => true]], 'An enableable node can be enabled'],
            [['enabled' => true, 'foo' => 'baz'][['foo' => 'baz']], 'any configuration enables an enableable node'],
            [['enabled' => false, 'foo' => 'baz'][['foo' => 'baz', 'enabled' => false]], 'An enableable node can be disabled'],
            [['enabled' => false, 'foo' => 'bar'][false], 'false disables an enableable node'],
        ];
->end()
                ->arrayNode('trusted_hosts')
                    ->beforeNormalization()->ifString()->then(fn ($v) => [$v])->end()
                    ->prototype('scalar')->end()
                ->end()
                ->scalarNode('trusted_proxies')->end()
                ->arrayNode('trusted_headers')
                    ->fixXmlConfig('trusted_header')
                    ->performNoDeepMerging()
                    ->defaultValue(['x-forwarded-for', 'x-forwarded-port', 'x-forwarded-proto'])
                    ->beforeNormalization()->ifString()->then(fn ($v) => $v ? array_map('trim', explode(',', $v)) : [])->end()
                    ->enumPrototype()
                        ->values([
                            'forwarded',
                            'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-forwarded-prefix',
                        ])
                    ->end()
                ->end()
                ->scalarNode('error_controller')
                    ->defaultValue('error_controller')
                ->end()
                ->booleanNode('handle_all_throwables')->info('HttpKernel will handle all kinds of \Throwable')->end()
            ->end()
        ;
Home | Imprint | This part of the site doesn't use cookies.