Skip to content

Commit f556d2a

Browse files
committed
Pass topics to mercure if not defined
1 parent e46ba44 commit f556d2a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Turbo/src/Bridge/Mercure/TurboStreamListenRenderer.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ public function renderTurboStreamListen(Environment $env, $topic /* array $event
6565
if (isset($eventSourceOptions)) {
6666
try {
6767
$mercure = $this->twig->getExtension(MercureExtension::class);
68-
$mercure->mercure($topics, $eventSourceOptions);
6968

70-
if (isset($eventSourceOptions['withCredentials'])) {
71-
$controllerAttributes['withCredentials'] = $eventSourceOptions['withCredentials'];
69+
if ($eventSourceOptions['withCredentials'] ?? false) {
70+
$eventSourceOptions['subscribe'] ??= $topics;
71+
$controllerAttributes['withCredentials'] = true;
7272
}
73+
74+
$mercure->mercure($topics, $eventSourceOptions);
7375
} catch (RuntimeError $e) {
7476
}
7577
}

0 commit comments

Comments
 (0)