Skip to content

Commit 8d25ed8

Browse files
committed
Stimulus: move deprecations from DTOs to filters/functions
1 parent c38ecba commit 8d25ed8

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/Dto/StimulusActionsDto.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public function addAction($dataOrControllerName, string $actionName = null, stri
3232
if (\is_string($dataOrControllerName)) {
3333
$data = [$dataOrControllerName => null === $eventName ? [[$actionName]] : [[$eventName => $actionName]]];
3434
} else {
35-
trigger_deprecation('symfony/webpack-encore-bundle', 'v1.15.0', 'Passing an array as first argument of stimulus_action() is deprecated.');
3635
if ($actionName || $eventName || $parameters) {
3736
throw new \InvalidArgumentException('You cannot pass a string to the second or third argument nor an array to the fourth argument while passing an array to the first argument of stimulus_action(): check the documentation.');
3837
}

src/Dto/StimulusControllersDto.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public function addController($dataOrControllerName, array $controllerValues = [
3030
if (\is_string($dataOrControllerName)) {
3131
$data = [$dataOrControllerName => $controllerValues];
3232
} else {
33-
trigger_deprecation('symfony/webpack-encore-bundle', 'v1.15.0', 'Passing an array as first argument of stimulus_controller() is deprecated.');
3433
if ($controllerValues) {
3534
throw new \InvalidArgumentException('You cannot pass an array to the first and second argument of stimulus_controller(): check the documentation.');
3635
}

src/Dto/StimulusTargetsDto.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public function addTarget($dataOrControllerName, string $targetNames = null): vo
2929
if (\is_string($dataOrControllerName)) {
3030
$data = [$dataOrControllerName => $targetNames];
3131
} else {
32-
trigger_deprecation('symfony/webpack-encore-bundle', 'v1.15.0', 'Passing an array as first argument of stimulus_target() is deprecated.');
3332
if ($targetNames) {
3433
throw new \InvalidArgumentException('You cannot pass a string to the second argument while passing an array to the first argument of stimulus_target(): check the documentation.');
3534
}

src/Twig/StimulusTwigExtension.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function getFilters(): array
4848
*/
4949
public function renderStimulusController(Environment $env, $dataOrControllerName, array $controllerValues = []): StimulusControllersDto
5050
{
51+
if (!\is_string($dataOrControllerName)) {
52+
trigger_deprecation('symfony/webpack-encore-bundle', 'v1.15.0', 'Passing an array as first argument of stimulus_controller() is deprecated.');
53+
}
54+
5155
$dto = new StimulusControllersDto($env);
5256
$dto->addController($dataOrControllerName, $controllerValues);
5357

@@ -65,6 +69,10 @@ public function renderStimulusController(Environment $env, $dataOrControllerName
6569
*/
6670
public function appendStimulusController(StimulusControllersDto $dto, $dataOrControllerName, array $controllerValues = []): StimulusControllersDto
6771
{
72+
if (!\is_string($dataOrControllerName)) {
73+
trigger_deprecation('symfony/webpack-encore-bundle', 'v1.15.0', 'Passing an array as first argument of stimulus_controller() is deprecated.');
74+
}
75+
6876
$dto->addController($dataOrControllerName, $controllerValues);
6977

7078
return $dto;
@@ -83,6 +91,10 @@ public function appendStimulusController(StimulusControllersDto $dto, $dataOrCon
8391
*/
8492
public function renderStimulusAction(Environment $env, $dataOrControllerName, string $actionName = null, string $eventName = null, array $parameters = []): StimulusActionsDto
8593
{
94+
if (!\is_string($dataOrControllerName)) {
95+
trigger_deprecation('symfony/webpack-encore-bundle', 'v1.15.0', 'Passing an array as first argument of stimulus_action() is deprecated.');
96+
}
97+
8698
$dto = new StimulusActionsDto($env);
8799
$dto->addAction($dataOrControllerName, $actionName, $eventName, $parameters);
88100

@@ -102,6 +114,10 @@ public function renderStimulusAction(Environment $env, $dataOrControllerName, st
102114
*/
103115
public function appendStimulusAction(StimulusActionsDto $dto, $dataOrControllerName, string $actionName = null, string $eventName = null, array $parameters = []): StimulusActionsDto
104116
{
117+
if (!\is_string($dataOrControllerName)) {
118+
trigger_deprecation('symfony/webpack-encore-bundle', 'v1.15.0', 'Passing an array as first argument of stimulus_action() is deprecated.');
119+
}
120+
105121
$dto->addAction($dataOrControllerName, $actionName, $eventName, $parameters);
106122

107123
return $dto;
@@ -118,6 +134,10 @@ public function appendStimulusAction(StimulusActionsDto $dto, $dataOrControllerN
118134
*/
119135
public function renderStimulusTarget(Environment $env, $dataOrControllerName, string $targetNames = null): StimulusTargetsDto
120136
{
137+
if (!\is_string($dataOrControllerName)) {
138+
trigger_deprecation('symfony/webpack-encore-bundle', 'v1.15.0', 'Passing an array as first argument of stimulus_target() is deprecated.');
139+
}
140+
121141
$dto = new StimulusTargetsDto($env);
122142
$dto->addTarget($dataOrControllerName, $targetNames);
123143

@@ -135,6 +155,10 @@ public function renderStimulusTarget(Environment $env, $dataOrControllerName, st
135155
*/
136156
public function appendStimulusTarget(StimulusTargetsDto $dto, $dataOrControllerName, string $targetNames = null): StimulusTargetsDto
137157
{
158+
if (!\is_string($dataOrControllerName)) {
159+
trigger_deprecation('symfony/webpack-encore-bundle', 'v1.15.0', 'Passing an array as first argument of stimulus_target() is deprecated.');
160+
}
161+
138162
$dto->addTarget($dataOrControllerName, $targetNames);
139163

140164
return $dto;

0 commit comments

Comments
 (0)