Skip to content

Document class-name dispatch for IntegrationsBundle events (Mautic 8) - #642

Open
promptless-for-oss wants to merge 5 commits into
mautic:8.0from
Promptless:promptless/pr-17160-integration-events-by-class
Open

Document class-name dispatch for IntegrationsBundle events (Mautic 8)#642
promptless-for-oss wants to merge 5 commits into
mautic:8.0from
Promptless:promptless/pr-17160-integration-events-by-class

Conversation

@promptless-for-oss

Copy link
Copy Markdown
Contributor

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 matching Mautic\IntegrationsBundle\IntegrationEvents constant 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.rst explaining that plugin developers must key on the event class (for example InternalObjectEvent::class) instead of the retained-but-unused constants, and that event families whose class serves several names (such as ConfigSaveEvent and InternalObjectFindEvent) still dispatch by their IntegrationEvents constants.

Source: mautic/mautic#17160 (follow-up to #17157, which converted CoreBundle).

Trigger Events

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
Comment thread docs/plugins/event_listeners.rst Outdated
Comment thread docs/plugins/event_listeners.rst Outdated
Comment thread docs/plugins/event_listeners.rst Outdated
Comment thread docs/plugins/event_listeners.rst Outdated
@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

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 adiati98 added this to the 8.0 milestone Aug 31, 2026

@TomasVotruba TomasVotruba left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@adiati98 adiati98 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@promptless-for-oss please address the suggestions.

Comment thread docs/plugins/event_listeners.rst Outdated

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use hyphe here for clarity instead of many commas.

Suggested change
* 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.

Comment thread docs/plugins/event_listeners.rst Outdated
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use active instead of passive voice.

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

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'.
@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

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 InternalObjectEvent::class" aside is now set off with hyphens instead of commas. I also fixed the passive voice on the next bullet: "…are no longer used to dispatch these events" is now active — "…but Mautic no longer uses them to dispatch these events." Vale passes clean on the changed file.

@promptless-for-oss
promptless-for-oss changed the base branch from 7.2 to 8.0 September 9, 2026 16:12
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants