11
11
12
12
use Symfony \WebpackEncoreBundle \Dto \StimulusActionsDto ;
13
13
use Symfony \WebpackEncoreBundle \Dto \StimulusControllersDto ;
14
+ use Symfony \WebpackEncoreBundle \Dto \StimulusOutletsDto ;
14
15
use Symfony \WebpackEncoreBundle \Dto \StimulusTargetsDto ;
15
16
use Twig \Environment ;
16
17
use Twig \Extension \AbstractExtension ;
@@ -25,6 +26,7 @@ public function getFunctions(): array
25
26
new TwigFunction ('stimulus_controller ' , [$ this , 'renderStimulusController ' ], ['needs_environment ' => true , 'is_safe ' => ['html_attr ' ]]),
26
27
new TwigFunction ('stimulus_action ' , [$ this , 'renderStimulusAction ' ], ['needs_environment ' => true , 'is_safe ' => ['html_attr ' ]]),
27
28
new TwigFunction ('stimulus_target ' , [$ this , 'renderStimulusTarget ' ], ['needs_environment ' => true , 'is_safe ' => ['html_attr ' ]]),
29
+ new TwigFunction ('stimulus_outlet ' , [$ this , 'renderStimulusOutlet ' ], ['needs_environment ' => true , 'is_safe ' => ['html_attr ' ]]),
28
30
];
29
31
}
30
32
@@ -34,6 +36,7 @@ public function getFilters(): array
34
36
new TwigFilter ('stimulus_controller ' , [$ this , 'appendStimulusController ' ], ['is_safe ' => ['html_attr ' ]]),
35
37
new TwigFilter ('stimulus_action ' , [$ this , 'appendStimulusAction ' ], ['is_safe ' => ['html_attr ' ]]),
36
38
new TwigFilter ('stimulus_target ' , [$ this , 'appendStimulusTarget ' ], ['is_safe ' => ['html_attr ' ]]),
39
+ new TwigFilter ('stimulus_outlet ' , [$ this , 'appendStimulusOutlet ' ], ['is_safe ' => ['html_attr ' ]]),
37
40
];
38
41
}
39
42
@@ -153,6 +156,20 @@ public function renderStimulusTarget(Environment $env, $controllerName, string $
153
156
return $ dto ;
154
157
}
155
158
159
+ /**
160
+ * @param string $controllerName The Stimulus controller name
161
+ * @param string $outletName The outlet name
162
+ * @param string $selector A CSS selector
163
+ */
164
+ public function renderStimulusOutlet (Environment $ env , string $ controllerName , string $ outletName , string $ selector ): StimulusOutletsDto
165
+ {
166
+ $ dto = new StimulusOutletsDto ($ env );
167
+
168
+ $ dto ->addOutlet ($ controllerName , $ outletName , $ selector );
169
+
170
+ return $ dto ;
171
+ }
172
+
156
173
/**
157
174
* @param string $controllerName the Stimulus controller name
158
175
* @param string|null $targetNames The space-separated list of target names if a string is passed to the 1st argument. Optional.
@@ -163,4 +180,16 @@ public function appendStimulusTarget(StimulusTargetsDto $dto, string $controller
163
180
164
181
return $ dto ;
165
182
}
183
+
184
+ /**
185
+ * @param string $controllerName The Stimulus controller name
186
+ * @param string $outletName The outlet name
187
+ * @param string $selector A CSS selector
188
+ */
189
+ public function appendStimulusOutlet (StimulusOutletsDto $ dto , string $ controllerName , string $ outletName , string $ selector ): StimulusOutletsDto
190
+ {
191
+ $ dto ->addOutlet ($ controllerName , $ outletName , $ selector );
192
+
193
+ return $ dto ;
194
+ }
166
195
}
0 commit comments