File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,29 @@ public function process(ContainerBuilder $container): void
1717
1818 // Getting the new list of adjustment types to clear
1919 $ listOfAdjustmentsToClear = $ clearerDefinition ->getArgument (0 );
20- if (1 === preg_match ('/^%(.*)%$/ ' , $ listOfAdjustmentsToClear , $ matches )) {
21- $ listOfAdjustmentsToClear = $ container ->getParameter ($ matches [1 ]);
20+
21+ // If the argument is a string then it's the name of the parameter where the services are configured
22+ // We then just need to modify the parameter.
23+ if (is_string ($ listOfAdjustmentsToClear )) {
24+ $ this ->addClearerToContainerParameter ($ container , $ listOfAdjustmentsToClear );
25+
26+ return ;
2227 }
28+
29+ // BC: For Symfony < 6 (modifing the service directly)
2330 $ listOfAdjustmentsToClear [] = CustomerOptionRecalculator::CUSTOMER_OPTION_ADJUSTMENT ;
2431
2532 // Setting the new list as the new definition
2633 $ clearerDefinition ->setArgument (0 , $ listOfAdjustmentsToClear );
2734 }
35+
36+ private function addClearerToContainerParameter (ContainerBuilder $ container , string $ parameterName ): void
37+ {
38+ assert (1 === preg_match ('/^%(.*)%$/ ' , $ parameterName , $ matches ));
39+ $ parameterName = $ matches [1 ];
40+ $ listOfAdjustmentsToClear = $ container ->getParameter ($ parameterName );
41+ $ listOfAdjustmentsToClear [] = CustomerOptionRecalculator::CUSTOMER_OPTION_ADJUSTMENT ;
42+
43+ $ container ->setParameter ($ parameterName , $ listOfAdjustmentsToClear );
44+ }
2845}
You can’t perform that action at this time.
0 commit comments