You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Important:** The `url()` method **only sets authorization when the `$subscribe` parameter is provided**. If you're already handling authorization in your controller (via `MercureComponent`), you can use either:
581
+
> [!NOTE]
582
+
> **Separation of Concerns:** The `url()` method **only sets authorization when the `$subscribe` parameter is provided**. If you're already handling authorization in your controller (via `MercureComponent`), simply omit the `$subscribe` parameter:
583
583
>
584
584
>```php
585
585
> // Authorization already set in controller
586
586
> $this->Mercure->authorize(['/books/123']);
587
587
>
588
-
> // In template: either of these works (no duplicate authorization)
589
-
> const url1 = '<?= $this->Mercure->url(['/books/123']) ?>'; // No $subscribe = no auth
> Use `getHubUrl()` when you want to be explicit that authorization is handled elsewhere.
594
591
595
592
#### Setting Default Topics
596
593
597
-
You can configure default topics that will be automatically merged with any topics you provide to `url()` or `getHubUrl()`. This is useful when you want certain topics (like notifications or global alerts) to be included in every subscription:
594
+
You can configure default topics that will be automatically merged with any topics you provide to `url()`. This is useful when you want certain topics (like notifications or global alerts) to be included in every subscription:
598
595
599
596
```php
600
597
// In your controller or AppView
@@ -612,18 +609,23 @@ public function initialize(): void
612
609
}
613
610
```
614
611
615
-
Now every call to `url()`or `getHubUrl()`will automatically include these default topics:
612
+
Now every call to `url()` will automatically include these default topics:
616
613
617
614
```php
618
615
// In your template
619
616
<script>
620
617
// This will subscribe to: /notifications, /alerts, AND /books/123
0 commit comments