PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
← All changes | app/Services/NotificationGate.php +7 -23 2.4.0 → 2.5.0 View file →
@@ -2,34 +2,19 @@
2 2
3 3 namespace FluentBooking\App\Services;
4 4
5 5 /**
6 - * A request-scoped switch that stops booking notifications from going out.
6 + * Suppresses booking notifications for the current request, and nothing else:
7 + * calendar sync, CRM triggers and webhooks still run, and reminders still go
8 + * out later. For backfills, migrations and agent writes that shouldn't email
9 + * the attendee.
7 10 *
8 - * Some programmatic callers legitimately need to change a booking without
9 - * emailing the attendee — an operator backfilling a booking that was already
10 - * agreed on the phone, a data migration, an AI agent acting on the host's
11 - * behalf. There was previously no way to express that: notifications are wired
12 - * to the booking lifecycle hooks, and suppressing them meant unhooking whole
13 - * actions, which also silenced calendar sync, CRM triggers and webhooks.
14 - *
15 - * This gate is deliberately narrow. It suppresses *notifications only*.
16 - * Everything else a booking triggers still runs.
17 - *
18 - * The gate is request-scoped, so it covers notifications sent during the call
19 - * only. Reminders belong to the booking, not to the operation that moved it:
20 - * a silent create or reschedule still leaves the event's reminder schedule
21 - * intact, and the attendee gets their reminder as normal.
22 - *
23 - * Usage:
24 - *
25 11 * $booking = NotificationGate::silently(function () use ($data) {
26 12 * return BookingService::createBooking($data);
27 13 * });
28 14 *
29 15 * Add-ons that send their own notifications (SMS, push) should check
30 - * NotificationGate::isSuppressed() at the top of their handlers, or hook the
31 - * `fluent_booking/suppress_notifications` filter.
16 + * isSuppressed() or hook `fluent_booking/suppress_notifications`.
32 17 *
33 18 * @since 2.2.6
34 19 */
35 20 class NotificationGate
@@ -39,11 +24,10 @@
39 24 */
40 25 private static $suppressed = false;
41 26
42 27 /**
43 - * Run $callback with notifications turned off, then restore the previous
44 - * state — including when $callback throws, so one failed call cannot leave
45 - * the rest of the request silent.
28 + * Run $callback with notifications off, restoring the previous state even
29 + * if it throws.
46 30 *
47 31 * @param callable $callback
48 32 *
49 33 * @return mixed Whatever $callback returns.