private function addDbalSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
            ->arrayNode('dbal')
                ->beforeNormalization()
                    ->ifTrue(static function ($v) {
                        return is_array($v) && ! array_key_exists('connections', $v) && ! array_key_exists('connection', $v);
                    })
                    ->then(static function ($v) {
                        // Key that should not be rewritten to the connection config
                        $excludedKeys = ['default_connection' => true, 'types' => true, 'type' => true];
                        $connection   = [];
                        foreach ($v as $key => $value) {
                            if (isset($excludedKeys[$key])) {
                                continue;
                            }
                            $connection[$key] = $v[$key];
                            unset($v[$key]);
                        }
                        $v['default_connection'] = isset($v['default_connection']) ? (string) $v['default_connection'] : 'default';
                        $v['connections']        = [$v['default_connection'] => $connection];

                        return $v;
                    })
                ->end()
                ->children()
                    ->scalarNode('default_connection')->end()
                ->end()
                ->fixXmlConfig('type')
                ->children()
                    ->arrayNode('types')
                        ->useAttributeAsKey('name')
                        ->prototype('array')
                            ->beforeNormalization()
                                ->ifString()
                                ->then(static function ($v) {
                                    return ['class' => $v];
                                })
                            ->end()
                            ->children()
                                ->scalarNode('class')->isRequired()->end()
                                ->booleanNode('commented')->defaultNull()->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
                ->fixXmlConfig('connection')
                ->append($this->getDbalConnectionsNode())
            ->end();
    }
private function addDbalSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
            ->arrayNode('dbal')
                ->beforeNormalization()
                    ->ifTrue(static function ($v) {
                        return is_array($v) && ! array_key_exists('connections', $v) && ! array_key_exists('connection', $v);
                    })
                    ->then(static function ($v) {
                        // Key that should not be rewritten to the connection config
                        $excludedKeys = ['default_connection' => true, 'types' => true, 'type' => true];
                        $connection   = [];
                        foreach ($v as $key => $value) {
                            if (isset($excludedKeys[$key])) {
                                continue;
                            }
                            $connection[$key] = $v[$key];
                            unset($v[$key]);
                        }
                        $v['default_connection'] = isset($v['default_connection']) ? (string) $v['default_connection'] : 'default';
                        $v['connections']        = [$v['default_connection'] => $connection];

                        return $v;
                    })
                ->end()
                ->children()
                    ->scalarNode('default_connection')->end()
                ->end()
                ->fixXmlConfig('type')
                ->children()
                    ->arrayNode('types')
                        ->useAttributeAsKey('name')
                        ->prototype('array')
                            ->beforeNormalization()
                                ->ifString()
                                ->then(static function ($v) {
                                    return ['class' => $v];
                                })
                            ->end()
                            ->children()
                                ->scalarNode('class')->isRequired()->end()
                                ->booleanNode('commented')->defaultNull()->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
                ->fixXmlConfig('connection')
                ->append($this->getDbalConnectionsNode())
            ->end();
    }
private function addDbalSection ( ArrayNodeDefinition $ node ) { $ node -> children ( ) -> arrayNode ( 'dbal' ) -> beforeNormalization ( ) -> ifTrue ( static function ( $ v ) { return is_array ( $ v ) && ! array_key_exists ( 'connections' , $ v ) && ! array_key_exists ( 'connection' , $ v ) ; } ) -> then ( static function ( $ v ) { // Key that should not be rewritten to the connection config $ excludedKeys = [ 'default_connection' => true , 'types' => true , 'type' => true ] ; $ connection = [ ] ; foreach ( $ v as $ key => $ value ) { if ( isset ( $ excludedKeys [ $ key ] ) ) { continue ; } $ connection [ $ key ] = $ v [ $ key ] ; unset ( $ v [ $ key ] ) ; } $ v [ 'default_connection' ] = isset ( $ v [ 'default_connection' ] ) ? ( string ) $ v [ 'default_connection' ] : 'default' ; $ v [ 'connections' ] = [ $ v [ 'default_connection' ] => $ connection ] ; return $ v ; } ) -> end ( ) -> children ( ) -> scalarNode ( 'default_connection' ) -> end ( ) -> end ( ) -> fixXmlConfig ( 'type' ) -> children ( ) -> arrayNode ( 'types' ) -> useAttributeAsKey ( 'name' ) -> prototype ( 'array' ) -> beforeNormalization ( ) -> ifString ( ) -> then ( static function ( $ v ) { return [ 'class' => $ v ] ; } ) -> end ( ) -> children ( ) -> scalarNode ( 'class' ) -> isRequired ( ) -> end ( ) -> booleanNode ( 'commented' ) -> defaultNull ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> fixXmlConfig ( 'connection' ) -> append ( $ this -> getDbalConnectionsNode ( ) ) -> end ( ) ; }
Add DBAL section to configuration tree
Add DBAL section to configuration tree