@@ -37,32 +37,42 @@ final class TwigGridRenderer implements GridRendererInterface
3737
3838 private FormTypeRegistryInterface $ formTypeRegistry ;
3939
40- private OptionsParserInterface $ optionsParser ;
41-
4240 private string $ defaultTemplate ;
4341
4442 private array $ actionTemplates ;
4543
4644 private array $ filterTemplates ;
4745
46+ private OptionsParserInterface $ optionsParser ;
47+
4848 public function __construct (
4949 Environment $ twig ,
5050 ServiceRegistryInterface $ fieldsRegistry ,
5151 FormFactoryInterface $ formFactory ,
5252 FormTypeRegistryInterface $ formTypeRegistry ,
53- OptionsParserInterface $ optionsParser ,
5453 string $ defaultTemplate ,
5554 array $ actionTemplates = [],
5655 array $ filterTemplates = [],
56+ ?OptionsParserInterface $ optionsParser = null ,
5757 ) {
5858 $ this ->twig = $ twig ;
5959 $ this ->fieldsRegistry = $ fieldsRegistry ;
6060 $ this ->formFactory = $ formFactory ;
6161 $ this ->formTypeRegistry = $ formTypeRegistry ;
62- $ this ->optionsParser = $ optionsParser ;
6362 $ this ->defaultTemplate = $ defaultTemplate ;
6463 $ this ->actionTemplates = $ actionTemplates ;
6564 $ 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+ }
6676 }
6777
6878 public function render (GridViewInterface $ gridView , ?string $ template = null )
@@ -77,7 +87,11 @@ public function renderField(GridViewInterface $gridView, Field $field, $data)
7787 $ resolver = new OptionsResolver ();
7888 $ fieldType ->configureOptions ($ resolver );
7989
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 );
8195
8296 return $ fieldType ->render ($ field , $ data , $ options );
8397 }
0 commit comments