2222
2323final class Configuration implements ConfigurationInterface
2424{
25+ /**
26+ * @return TreeBuilder<'array'>
27+ */
2528 public function getConfigTreeBuilder (): TreeBuilder
2629 {
2730 $ treeBuilder = new TreeBuilder ('sylius_twig_hooks ' );
@@ -69,6 +72,7 @@ private function addHooksConfiguration(ArrayNodeDefinition $rootNode): void
6972 ->arrayPrototype ()
7073 ->beforeNormalization ()
7174 ->always (function ($ v ) {
75+ $ isTypeDefined = isset ($ v ['type ' ]);
7276 $ isComponentDefined = isset ($ v ['component ' ]);
7377 $ isTemplateDefined = isset ($ v ['template ' ]);
7478 $ isDisabled = isset ($ v ['enabled ' ]) && $ v ['enabled ' ] === false ;
@@ -77,6 +81,10 @@ private function addHooksConfiguration(ArrayNodeDefinition $rootNode): void
7781 return $ v ;
7882 }
7983
84+ if (true === $ isTypeDefined ) {
85+ return $ v ;
86+ }
87+
8088 $ v ['type ' ] = match (true ) {
8189 $ isDisabled => 'disabled ' ,
8290 $ isComponentDefined => 'component ' ,
@@ -89,6 +97,16 @@ private function addHooksConfiguration(ArrayNodeDefinition $rootNode): void
8997 ->end ()
9098 ->validate ()
9199 ->always (static function ($ v ) {
100+ $ type = $ v ['type ' ] ?? null ;
101+ if ('template ' === $ type ) {
102+ $ v ['component ' ] = null ;
103+ $ v ['props ' ] = [];
104+ }
105+
106+ if ('component ' === $ type ) {
107+ $ v ['template ' ] = null ;
108+ }
109+
92110 $ component = $ v ['component ' ] ?? null ;
93111 $ template = $ v ['template ' ] ?? null ;
94112 $ enabled = $ v ['enabled ' ] ?? true ;
0 commit comments