Document Mautic 8 class-name dispatch for Stage, Dashboard, and SMS bundle events - #649
Document Mautic 8 class-name dispatch for Stage, Dashboard, and SMS bundle events#649promptless-for-oss wants to merge 3 commits into
Conversation
… SMS bundles Since Mautic 8 (mautic/mautic#17216), StageBuilderEvent, the Dashboard widget-list/form events, and the SMS Contact-filtering events are dispatched by the event object alone (Symfony 4.3+ class-name dispatch). The old SmsEvents/StageEvents/DashboardEvents string constants remain for backward compatibility but no longer dispatch these events, so a subscriber still keyed on an old constant fails silently. Update the plugin event-listener and SMS extension guides to key getSubscribedEvents() on the event class, add a debug:event-dispatcher verification step, and annotate the SMS event-constants table.
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, ``Mautic\StageBundle\Event\StageBuilderEvent`` is dispatched by the event object alone. Key ``getSubscribedEvents()`` on ``StageBuilderEvent::class``, not on ``StageEvents::STAGE_ON_BUILD`` or the string ``mautic.stage_on_build``. Those constants remain for backward compatibility but no longer dispatch this event, so a subscriber still keyed on the old constant never fires — no exception is thrown and nothing is logged. The ``StageEvent`` CRUD group, ``STAGE_ON_ACTION``, and ``ON_CAMPAIGN_BATCH_ACTION`` are unchanged. |
There was a problem hiding this comment.
StageModel::getStageActions() dispatches StageBuilderEvent via $this->dispatcher->dispatch($event) with no event-name argument, so Symfony uses StageBuilderEvent::class as the event name (class-name dispatch). StageEvents::STAGE_ON_BUILD constant (StageEvents.php L45) still exists but is no longer passed to dispatch().
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, ``Mautic\StageBundle\Event\StageBuilderEvent`` is dispatched by the event object alone. Key ``getSubscribedEvents()`` on ``StageBuilderEvent::class``, not on ``StageEvents::STAGE_ON_BUILD`` or the string ``mautic.stage_on_build``. Those constants remain for backward compatibility but no longer dispatch this event, so a subscriber still keyed on the old constant never fires — no exception is thrown and nothing is logged. The ``StageEvent`` CRUD group, ``STAGE_ON_ACTION``, and ``ON_CAMPAIGN_BATCH_ACTION`` are unchanged. |
There was a problem hiding this comment.
UPGRADE-8.0.md confirms StageEvents::STAGE_ON_BUILD constant is kept for backward compatibility but no longer used internally; STAGE_PRE_SAVE/POST_SAVE/PRE_DELETE/POST_DELETE (StageEvent) and ON_CAMPAIGN_BATCH_ACTION (PendingEvent) remain unchanged, matching the doc's claim.
Source: https://github.com/mautic/mautic/blob/d854bbb37faac0d324b55182545d824a942219cf/UPGRADE-8.0.md#L380
|
|
||
| Since Mautic 8, two DashboardBundle widget events are dispatched by the event object alone. Key ``getSubscribedEvents()`` on the event class rather than on the former constant. The classes live in ``Mautic\DashboardBundle\Event``. | ||
|
|
||
| .. list-table:: |
There was a problem hiding this comment.
DashboardSubscriber::getSubscribedEvents() keys the widget list/form events on WidgetTypeListEvent::class and WidgetFormEvent::class (L37-38), replacing the former DashboardEvents::DASHBOARD_ON_MODULE_LIST_GENERATE/FORM_GENERATE string keys, while DASHBOARD_ON_MODULE_DETAIL_PRE_LOAD/GENERATE (L39-40, sharing WidgetDetailEvent) remain string-keyed, matching the doc's mapping table exactly.
|
|
||
| Since Mautic 8, two DashboardBundle widget events are dispatched by the event object alone. Key ``getSubscribedEvents()`` on the event class rather than on the former constant. The classes live in ``Mautic\DashboardBundle\Event``. | ||
|
|
||
| .. list-table:: |
There was a problem hiding this comment.
DashboardEvents.php still defines DASHBOARD_ON_MODULE_LIST_GENERATE (L18, string mautic.dashboard_on_widget_list_generate) and DASHBOARD_ON_MODULE_FORM_GENERATE (L26) for BC, confirming the doc's "former constant" column and the constant strings referenced.
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, these three filtering events are dispatched by the event object alone (Symfony 4.3+ class-name dispatch), so you subscribe by the event class. The ``SmsEvents`` constants remain for backward compatibility but no longer dispatch these three events. A subscriber still keyed on an old constant fails silently: no exception is thrown, nothing is logged, and the listener never runs. Within the SmsBundle, this section covers the three Contact-filtering events. Other SmsBundle events converted in Mautic 8 (such as ``SmsSendEvent`` and ``TokensBuildEvent``) aren't covered here. The Campaign trigger, CRUD, and reply events still key on their ``SmsEvents`` constants. |
There was a problem hiding this comment.
SmsModel::sendSms() dispatches DncEvent (L233), QueueEvent (L250), and FilterEvent (L267) each via dispatch($event) with no event-name argument, i.e. class-name dispatch; the SmsEvents string constants (DNC_FILTER_CONTACTS_ON_SEND, QUEUE_FILTER_CONTACTS_ON_SEND, FILTER_CONTACTS_ON_SEND) are no longer passed.
| { | ||
| return [ | ||
| SmsEvents::DNC_FILTER_CONTACTS_ON_SEND => ['onDncFilter', 0], | ||
| DncEvent::class => ['onDncFilter', 0], |
There was a problem hiding this comment.
SendSmsSubscriber::getSubscribedEvents() keys DncEvent::class, QueueEvent::class, and FilterEvent::class (L30-32) rather than the former SmsEvents string constants, matching the doc's code sample and the "Subscribe by DncEvent::class (formerly SmsEvents::DNC_FILTER_CONTACTS_ON_SEND)" claims for all three filter sections.
|
|
||
| .. code-block:: bash | ||
|
|
||
| bin/console debug:event-dispatcher 'Mautic\SmsBundle\Event\DncEvent' |
There was a problem hiding this comment.
Symfony docs confirm: (1) dispatch($event) without an eventName uses the event's FQCN as the event name (class-name dispatch); (2) bin/console debug:event-dispatcher is a real console command that accepts an event name/FQCN and lists its registered listeners, so bin/console debug:event-dispatcher 'Mautic\SmsBundle\Event\DncEvent' is a valid, accurate verification command.
Source: https://symfony.com/doc/current/components/event_dispatcher.html
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, these three filtering events are dispatched by the event object alone (Symfony 4.3+ class-name dispatch), so you subscribe by the event class. The ``SmsEvents`` constants remain for backward compatibility but no longer dispatch these three events. A subscriber still keyed on an old constant fails silently: no exception is thrown, nothing is logged, and the listener never runs. Within the SmsBundle, this section covers the three Contact-filtering events. Other SmsBundle events converted in Mautic 8 (such as ``SmsSendEvent`` and ``TokensBuildEvent``) aren't covered here. The Campaign trigger, CRUD, and reply events still key on their ``SmsEvents`` constants. |
There was a problem hiding this comment.
SmsEvents::ON_CAMPAIGN_TRIGGER_ACTION (L61) and ON_CAMPAIGN_TRIGGER_BATCH_ACTION (L67) are untouched by PR mautic/mautic#17216 (not in the changed-files list) and remain string constants, still used as the getSubscribedEvents key and batchEventName value in CampaignSendSubscriber.php (L28, L40 at head commit), supporting the doc's "The Campaign trigger ... events still key on their SmsEvents constants" claim (corrected pass: re-pinned from stale L228 to the actual claim location, L155).
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, these three filtering events are dispatched by the event object alone (Symfony 4.3+ class-name dispatch), so you subscribe by the event class. The ``SmsEvents`` constants remain for backward compatibility but no longer dispatch these three events. A subscriber still keyed on an old constant fails silently: no exception is thrown, nothing is logged, and the listener never runs. Within the SmsBundle, this section covers the three Contact-filtering events. Other SmsBundle events converted in Mautic 8 (such as ``SmsSendEvent`` and ``TokensBuildEvent``) aren't covered here. The Campaign trigger, CRUD, and reply events still key on their ``SmsEvents`` constants. |
There was a problem hiding this comment.
SmsModel::dispatchEvent() still resolves $name to the SmsEvents::SMS_PRE_SAVE/SMS_POST_SAVE/SMS_PRE_DELETE/SMS_POST_DELETE string constants (L421,424,427,430) and passes $name as the dispatch event-name argument (L442, dispatch($event, $name)) — untouched by PR #17216 (SmsModel.php's diff only touches the filter/send dispatches at L233/250/267/297). Confirms the doc's claim that "the CRUD ... events still key on their SmsEvents constants" is accurate.
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, these three filtering events are dispatched by the event object alone (Symfony 4.3+ class-name dispatch), so you subscribe by the event class. The ``SmsEvents`` constants remain for backward compatibility but no longer dispatch these three events. A subscriber still keyed on an old constant fails silently: no exception is thrown, nothing is logged, and the listener never runs. Within the SmsBundle, this section covers the three Contact-filtering events. Other SmsBundle events converted in Mautic 8 (such as ``SmsSendEvent`` and ``TokensBuildEvent``) aren't covered here. The Campaign trigger, CRUD, and reply events still key on their ``SmsEvents`` constants. |
There was a problem hiding this comment.
ReplySubscriber::getSubscribedEvents() still keys on the SmsEvents::ON_REPLY string constant (L31); this file is untouched by PR #17216 (not in the changed-files list), and SmsEvents::ON_CAMPAIGN_REPLY is likewise unconverted. Confirms the doc's claim that "the ... reply events still key on their SmsEvents constants" is accurate.
|
|
||
| .. vale off | ||
|
|
||
| That advice holds for every event dispatched by a string constant. Since Mautic 8, some bundles instead dispatch an event by the event object alone (Symfony 4.3+ class-name dispatch), so the event name is the event class rather than a string constant. For a converted event, the event class — not a string constant — is the stable dispatch identifier, and you key ``getSubscribedEvents()`` on the class. The notes below cover the StageBundle and DashboardBundle events; other bundles received similar conversions in this release. |
There was a problem hiding this comment.
CampaignSubscriber::buildNotificationToSend() now calls $this->dispatcher->dispatch(new NotificationSendEvent(...)) with no event-name argument (L234-235), i.e. class-name dispatch, replacing the former NotificationEvents::NOTIFICATION_ON_SEND string-keyed dispatch — part of the same PR #17216 that converted StageBundle/DashboardBundle events. Supports the corrected bridging sentence's claim that "other bundles received similar conversions in this release" without overclaiming the notes below are exhaustive.
adiati98
left a comment
There was a problem hiding this comment.
@promptless-for-oss please address the suggestions.
|
Thanks @adiati98 — on it. I'll work through all the review comments (hyphens instead of parentheses, active voice, and periods in place of semicolons), run Vale, and push the updates to this PR shortly. |
Apply @adiati98's review on PR mautic#649: convert parenthetical asides to the repo's spaced-hyphen form, rewrite flagged passive constructions to active voice, and split semicolons into separate sentences across the StageBundle/DashboardBundle notes and the SMS Contact-filtering events.
|
Done @adiati98 — worked through all of your review comments across |
Open in Promptless
Since Mautic 8, the StageBundle stage-builder event, the two DashboardBundle widget events, and the SmsBundle Contact-filtering events are dispatched by the event object alone (Symfony 4.3+ class-name dispatch), so the event name is now the event class rather than a string constant. The old
StageEvents,DashboardEvents, andSmsEventsconstants remain for backward compatibility but no longer dispatch these events — a plugin subscriber still keyed on an old constant fails silently, so the existing string-keyed subscriber guidance became inaccurate.This updates the two affected developer pages so plugin authors key
getSubscribedEvents()on the event class:docs/plugins/event_listeners.rst— adds StageBundle and DashboardBundle notes (with a Dashboard constant-to-class mapping table) in the "Available events" section, reconciles the page's "always use the event constants" advice for converted events, and adds a genericbin/console debug:event-dispatcherverification step.docs/plugin_extensions/sms.rst— re-keys the workedSmsFilterSubscriberexample toDncEvent::class, recasts the DNC/Queue/Generic filter guidance to name the event class as the subscription key, adds a Mautic 8 silent-failure note (with a multi-version caveat and verification command), and annotates the SMS event-constants table.Scope is limited to events already documented with string-keyed subscriber examples that the conversion made inaccurate; NotificationBundle's converted event and the other converted SMS events are undocumented and were left out.
Trigger Events
Review feedback addressed (@adiati98, review 5086643454)
Applied all 13 actionable comments across the two pages. Three requested transforms:
- … -, matching the repo convention indocs/design/labelling.rst): intro paragraph and the "Mautic 8 event class - subscription key" table header andWidgetDetailEventaside inevent_listeners.rst; the class-name-dispatch note, the three filter-section "formerlySmsEvents::…" asides, and the three SMS event-constants table rows insms.rst.debug:event-dispatcherverification sentences, and the three SMS table rows.event_listeners.rstverification note, and the three SMS table rows.Disposition: all 13 items applied. The
sms.rstverification sentence was applied verbatim per the suppliedsuggestionblock (semicolon → period only; passive retained as suggested). For consistency, three em-dash asides in the same paragraphs were also normalised to the repo's spaced-hyphen form. Vale passes clean on both files.