@@ -76,13 +76,13 @@ public function getConfigTreeBuilder()
7676 /**
7777 * Returns the array node used for "dynamic_templates".
7878 */
79- private function getDynamicTemplateNode ()
79+ private function getDynamicTemplateNode (): ArrayNodeDefinition
8080 {
8181 $ node = $ this ->createTreeBuilderNode ('dynamic_templates ' );
8282
8383 $ node
84- ->prototype ( ' array ' )
85- ->prototype ( ' array ' )
84+ ->arrayPrototype ( )
85+ ->arrayPrototype ( )
8686 ->children ()
8787 ->scalarNode ('match ' )->end ()
8888 ->scalarNode ('unmatch ' )->end ()
@@ -91,12 +91,18 @@ private function getDynamicTemplateNode()
9191 ->scalarNode ('path_unmatch ' )->end ()
9292 ->scalarNode ('match_pattern ' )->end ()
9393 ->arrayNode ('mapping ' )
94- ->prototype ( ' variable ' )
94+ ->variablePrototype ( )
9595 ->treatNullLike ([])
9696 ->end ()
9797 ->end ()
9898 ->end ()
9999 ->end ()
100+ ->validate ()
101+ ->ifTrue (static function ($ v ) {
102+ return 1 !== \count ($ v );
103+ })
104+ ->thenInvalid ('Dynamic template should consist of a single named object: %s. ' )
105+ ->end ()
100106 ->end ()
101107 ;
102108
@@ -420,33 +426,8 @@ private function addIndexesSection(ArrayNodeDefinition $rootNode)
420426 ->children ()
421427 ->arrayNode ('indexes ' )
422428 ->useAttributeAsKey ('name ' )
423- ->prototype ( ' array ' )
429+ ->arrayPrototype ( )
424430 ->treatNullLike ([])
425- ->beforeNormalization ()
426- ->ifNull ()
427- ->thenEmptyArray ()
428- ->end ()
429- // Support multiple dynamic_template formats to match the old bundle style
430- // and the way ElasticSearch expects them
431- ->beforeNormalization ()
432- ->ifTrue (function ($ v ) {
433- return isset ($ v ['dynamic_templates ' ]);
434- })
435- ->then (function ($ v ) {
436- $ dt = [];
437- foreach ($ v ['dynamic_templates ' ] as $ key => $ type ) {
438- if (\is_int ($ key )) {
439- $ dt [] = $ type ;
440- } else {
441- $ dt [][$ key ] = $ type ;
442- }
443- }
444-
445- $ v ['dynamic_templates ' ] = $ dt ;
446-
447- return $ v ;
448- })
449- ->end ()
450431 ->children ()
451432 ->scalarNode ('index_name ' )
452433 ->info ('Defaults to the name of the index, but can be modified if the index name is different in ElasticSearch ' )
0 commit comments