Skip to content

Commit c5fc9fb

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,15 @@ public function renderTurboStreamListen(Environment $env, $topic /* array $event
6565
if (isset($eventSourceOptions)) {
6666
try {
6767
$mercure = $this->twig->getExtension(MercureExtension::class);
68+
69+
if ($withCredentials = $eventSourceOptions['withCredentials'] ?? false) {
70+
$eventSourceOptions['subscribe'] ??= $topics;
71+
}
72+
6873
$mercure->mercure($topics, $eventSourceOptions);
6974

70-
if (isset($eventSourceOptions['withCredentials'])) {
71-
$controllerAttributes['withCredentials'] = $eventSourceOptions['withCredentials'];
75+
if ($withCredentials) {
76+
$controllerAttributes['withCredentials'] = true;
7277
}
7378
} catch (RuntimeError $e) {
7479
}

0 commit comments

Comments
 (0)