Document class-name dispatch for IntegrationsBundle events (Mautic 8) - #642
Document class-name dispatch for IntegrationsBundle events (Mautic 8)#642promptless-for-oss wants to merge 5 commits into
Conversation
Since Mautic 8, IntegrationsBundle dispatches many events by the event object alone (event class = event name), so subscribers must key getSubscribedEvents() on the event class rather than the retained-but-unused IntegrationEvents constants. Add a note to the Available events section warning that a stale constant-keyed subscriber fails silently, and that multi-name event families still dispatch by their constants. Source: mautic/mautic#17160
|
I noticed that some CI checks failed for this PR. I'm investigating whether the failures are caused by this suggestion. If they're unrelated or pre-existing, I'll leave this suggestion unchanged and create a separate suggestion if a standalone docs fix is needed. |
adiati98
left a comment
There was a problem hiding this comment.
@promptless-for-oss please address the suggestions.
|
|
||
| Since Mautic 8, Mautic dispatches many ``Mautic\IntegrationsBundle\Event`` events by the event object alone, so the event class is the event name. This matches the Symfony 4.3 dispatch style. | ||
|
|
||
| * For a converted event, key ``getSubscribedEvents()`` on the event class, for example ``InternalObjectEvent::class``, not on the matching ``Mautic\IntegrationsBundle\IntegrationEvents`` constant or its string value. |
There was a problem hiding this comment.
I think we can use hyphe here for clarity instead of many commas.
| * For a converted event, key ``getSubscribedEvents()`` on the event class, for example ``InternalObjectEvent::class``, not on the matching ``Mautic\IntegrationsBundle\IntegrationEvents`` constant or its string value. | |
| * For a converted event, key ``getSubscribedEvents()`` on the event class - for example ``InternalObjectEvent::class`` - not on the matching ``Mautic\IntegrationsBundle\IntegrationEvents`` constant or its string value. |
| Since Mautic 8, Mautic dispatches many ``Mautic\IntegrationsBundle\Event`` events by the event object alone, so the event class is the event name. This matches the Symfony 4.3 dispatch style. | ||
|
|
||
| * For a converted event, key ``getSubscribedEvents()`` on the event class, for example ``InternalObjectEvent::class``, not on the matching ``Mautic\IntegrationsBundle\IntegrationEvents`` constant or its string value. | ||
| * The ``IntegrationEvents`` constants remain in the codebase but are no longer used to dispatch these events, so a subscriber still keyed on a converted constant won't fire. It fails silently: it throws no exception and logs nothing, and simply never runs. |
There was a problem hiding this comment.
Use active instead of passive voice.
|
Thanks @adiati98 — on it. We'll apply your hyphen suggestion, fix the passive voice, and push the updates to this PR shortly. |
Address @adiati98's review (pullrequestreview-5131357865): - Use hyphens instead of commas around the 'for example InternalObjectEvent::class' aside (verbatim reviewer suggestion). - Rewrite 'are no longer used to dispatch these events' to active voice: 'Mautic no longer uses them to dispatch these events'.
|
Thanks @adiati98 — both suggestions are addressed in the latest push. I applied your hyphen suggestion verbatim on the "For a converted event…" bullet, so the "for example |
Replace this page's copy of the general Mautic 8 class-name event dispatch explanation with a cross-reference to the shared "Mautic 8: class-name event dispatch" section in plugins/event_listeners.rst, keeping the bundle-specific facts. Part of consolidating the duplicated note across the open Mautic 8 dev-docs PRs.
Open in Promptless
Since Mautic 8, the IntegrationsBundle dispatches many of its events by the event object alone (Symfony 4.3 style), so the event class is the event name. A subscriber that still keys
getSubscribedEvents()on the matchingMautic\IntegrationsBundle\IntegrationEventsconstant no longer fires for a converted event — and it fails silently, throwing no exception and logging nothing.This adds a note to the "Available events" section of
docs/plugins/event_listeners.rstexplaining that plugin developers must key on the event class (for exampleInternalObjectEvent::class) instead of the retained-but-unused constants, and that event families whose class serves several names (such asConfigSaveEventandInternalObjectFindEvent) still dispatch by theirIntegrationEventsconstants.Source: mautic/mautic#17160 (follow-up to #17157, which converted CoreBundle).
Trigger Events