@@ -37,32 +37,42 @@ final class TwigGridRenderer implements GridRendererInterface
37
37
38
38
private FormTypeRegistryInterface $ formTypeRegistry ;
39
39
40
- private OptionsParserInterface $ optionsParser ;
41
-
42
40
private string $ defaultTemplate ;
43
41
44
42
private array $ actionTemplates ;
45
43
46
44
private array $ filterTemplates ;
47
45
46
+ private ?OptionsParserInterface $ optionsParser ;
47
+
48
48
public function __construct (
49
49
Environment $ twig ,
50
50
ServiceRegistryInterface $ fieldsRegistry ,
51
51
FormFactoryInterface $ formFactory ,
52
52
FormTypeRegistryInterface $ formTypeRegistry ,
53
- OptionsParserInterface $ optionsParser ,
54
53
string $ defaultTemplate ,
55
54
array $ actionTemplates = [],
56
55
array $ filterTemplates = [],
56
+ ?OptionsParserInterface $ optionsParser = null ,
57
57
) {
58
58
$ this ->twig = $ twig ;
59
59
$ this ->fieldsRegistry = $ fieldsRegistry ;
60
60
$ this ->formFactory = $ formFactory ;
61
61
$ this ->formTypeRegistry = $ formTypeRegistry ;
62
- $ this ->optionsParser = $ optionsParser ;
63
62
$ this ->defaultTemplate = $ defaultTemplate ;
64
63
$ this ->actionTemplates = $ actionTemplates ;
65
64
$ this ->filterTemplates = $ filterTemplates ;
65
+ $ this ->optionsParser = $ optionsParser ;
66
+
67
+ if (null === $ optionsParser ) {
68
+ trigger_deprecation (
69
+ 'sylius/grid-bundle ' ,
70
+ '1.14 ' ,
71
+ 'Not passing an instance of "%s" as the eighth constructor argument of "%s" is deprecated. ' ,
72
+ OptionsParserInterface::class,
73
+ self ::class,
74
+ );
75
+ }
66
76
}
67
77
68
78
public function render (GridViewInterface $ gridView , ?string $ template = null )
@@ -77,7 +87,11 @@ public function renderField(GridViewInterface $gridView, Field $field, $data)
77
87
$ resolver = new OptionsResolver ();
78
88
$ fieldType ->configureOptions ($ resolver );
79
89
80
- $ options = $ resolver ->resolve ($ this ->optionsParser ->parseOptions ($ field ->getOptions ()));
90
+ $ options = $ field ->getOptions ();
91
+ if (null !== $ this ->optionsParser ) {
92
+ $ options = $ this ->optionsParser ->parseOptions ($ options );
93
+ }
94
+ $ options = $ resolver ->resolve ($ options );
81
95
82
96
return $ fieldType ->render ($ field , $ data , $ options );
83
97
}
0 commit comments