Skip to content

Commit 75aeef1

Browse files
committed
Fixing for WebpackEncoreBundle 1.15.0 changes
1 parent be3c396 commit 75aeef1

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/Chartjs/Twig/ChartExtension.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\UX\Chartjs\Twig;
1313

1414
use Symfony\UX\Chartjs\Model\Chart;
15+
use Symfony\WebpackEncoreBundle\Dto\StimulusControllersDto;
1516
use Symfony\WebpackEncoreBundle\Twig\StimulusTwigExtension;
1617
use Twig\Environment;
1718
use Twig\Extension\AbstractExtension;
@@ -49,7 +50,16 @@ public function renderChart(Environment $env, Chart $chart, array $attributes =
4950
}
5051
$controllers['@symfony/ux-chartjs/chart'] = ['view' => $chart->createView()];
5152

52-
$html = '<canvas '.$this->stimulus->renderStimulusController($env, $controllers).' ';
53+
if (class_exists(StimulusControllersDto::class)) {
54+
$dto = new StimulusControllersDto($env);
55+
foreach ($controllers as $name => $controllerValues) {
56+
$dto->addController($name, $controllerValues);
57+
}
58+
59+
$html = '<canvas '.$dto.' ';
60+
} else {
61+
$html = '<canvas '.$this->stimulus->renderStimulusController($env, $controllers).' ';
62+
}
5363

5464
foreach ($chart->getAttributes() as $name => $value) {
5565
if ('data-controller' === $name) {

src/Notify/Twig/NotifyRuntime.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\UX\Notify\Twig;
1313

1414
use Symfony\Component\Mercure\HubInterface;
15+
use Symfony\WebpackEncoreBundle\Dto\StimulusControllersDto;
1516
use Symfony\WebpackEncoreBundle\Twig\StimulusTwigExtension;
1617
use Twig\Environment;
1718
use Twig\Extension\RuntimeExtensionInterface;
@@ -39,7 +40,15 @@ public function renderStreamNotifications(Environment $environment, array|string
3940
}
4041
$controllers['@symfony/ux-notify/notify'] = ['topics' => $topics, 'hub' => $this->hub->getPublicUrl()];
4142

42-
$html = $this->stimulusTwigExtension->renderStimulusController($environment, $controllers);
43+
if (class_exists(StimulusControllersDto::class)) {
44+
$dto = new StimulusControllersDto($environment);
45+
foreach ($controllers as $name => $controllerValues) {
46+
$dto->addController($name, $controllerValues);
47+
}
48+
$html = (string) $dto;
49+
} else {
50+
$html = $this->stimulusTwigExtension->renderStimulusController($environment, $controllers);
51+
}
4352

4453
return trim(sprintf('<div %s></div>', $html));
4554
}

0 commit comments

Comments
 (0)