root('foq_elastica', 'array'); $this->addClientsSection($rootNode); $this->addIndexesSection($rootNode); $rootNode ->children() ->scalarNode('default_client')->end() ->scalarNode('default_index')->end() ->end() ; return $treeBuilder->buildTree(); } /** * Adds the configuration for the "clients" key */ private function addClientsSection(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('client') ->children() ->arrayNode('clients') ->useAttributeAsKey('id') ->prototype('array') ->performNoDeepMerging() ->children() ->scalarNode('host')->defaultValue('localhost')->end() ->scalarNode('port')->defaultValue('9000')->end() ->end() ->end() ->end() ->end() ; } /** * Adds the configuration for the "indexes" key */ private function addIndexesSection(ArrayNodeDefinition $rootNode) { $rootNode ->fixXmlConfig('index') ->children() ->arrayNode('indexes') ->useAttributeAsKey('name') ->prototype('array') ->performNoDeepMerging() ->children() ->scalarNode('client')->end() ->end() ->append($this->getTypesNode()) ->end() ->end() ->end() ; } /** * Returns the array node used for "types". */ protected function getTypesNode() { $builder = new TreeBuilder(); $node = $builder->root('types'); $node ->useAttributeAsKey('name') ->prototype('array') ->treatNullLike(array()) ->children() ->end() ->end() ; return $node; } }