Skip to content

Key ChannelBundle event subscribers on the event class (Mautic 8.0) - #644

Open
promptless-for-oss wants to merge 4 commits into
mautic:7.2from
Promptless:promptless/pr-17201-channel-events-by-class
Open

Key ChannelBundle event subscribers on the event class (Mautic 8.0)#644
promptless-for-oss wants to merge 4 commits into
mautic:7.2from
Promptless:promptless/pr-17201-channel-events-by-class

Conversation

@promptless-for-oss

@promptless-for-oss promptless-for-oss commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Open in Promptless

From Mautic 8.0, Mautic dispatches five ChannelBundle events by their event class name (the Symfony convention for dispatching events by class name since Symfony 4.3) instead of the ChannelEvents::* string constants. This updates the plugin Channels extension page to reflect the new convention: the two subscriber examples now key on ChannelEvent::class and ChannelBroadcastEvent::class (priorities preserved), the now-unused ChannelEvents import is dropped, and the broadcast listener reference is corrected to \Mautic\ChannelBundle\Event\ChannelBroadcastEvent. A concise note tells developers to key affected subscribers on the event class and attributes the pattern to Symfony 4.3. Reflects mautic/mautic#17201 (targets 8.x, documented on the 7.2 docs branch).

Trigger Events

Review feedback addressed

  • @escopecz (review on docs/plugin_extensions/channels.rst): "Perhaps we could find a way how to shorten these notes and also say that it's how Symfony does it since v4.3" — Applied with the reviewer's intent. The Mautic 8.0 note is shortened to a single sentence directing developers to key subscribers to these ChannelBundle events on the event class (for example, ChannelEvent::class), following the Symfony convention for dispatching events by class name since Symfony 4.3. Verified against the 8.x source that ChannelEvents is kept (not removed), so the note drops the earlier "silently stops receiving" and "backward compatibility" framing rather than describing the constants as still-defined-but-unused. Vale passes on the changed line.
  • @adiati98 (earlier review on docs/plugin_extensions/channels.rst): "we use hyphen instead of parentheses." — Applied. The for example aside in the note is set off without parentheses; the current single-sentence note uses em-dashes per the repo's Vale Google.EmDash rule.

Update the plugin Channels extension examples for the Mautic 8.0
class-name event dispatch introduced in mautic/mautic#17201: key
subscribers on ChannelEvent::class and ChannelBroadcastEvent::class
instead of the ChannelEvents string constants, drop the now-unused
import, and correct the broadcast listener reference to the event
class. Add a note explaining that subscribers keyed on the old
ChannelEvents constants silently stop receiving these events.
{
return [
ChannelEvents::ADD_CHANNEL => ['onAddChannel', 100],
ChannelEvent::class => ['onAddChannel', 100],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ADD_CHANNEL subscriber example now keys on ChannelEvent::class. Confirmed: Mautic\ChannelBundle\Event\ChannelEvent is the event class, and mautic/mautic PR #17201's UPGRADE-8.0.md maps ChannelEvents::ADD_CHANNEL -> ChannelEvent.

Source: https://github.com/mautic/mautic/blob/3813aee10a279da5cffe2b2bd391cc63d4a8cb6e/app/bundles/ChannelBundle/Event/ChannelEvent.php#L8

{
return [
ChannelEvents::CHANNEL_BROADCAST => ['onChannelBroadcast', 0]
ChannelBroadcastEvent::class => ['onChannelBroadcast', 0],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Broadcast subscriber example now keys on ChannelBroadcastEvent::class. Confirmed: Mautic\ChannelBundle\Event\ChannelBroadcastEvent is the event class, and mautic/mautic PR #17201's UPGRADE-8.0.md maps ChannelEvents::CHANNEL_BROADCAST -> ChannelBroadcastEvent.

Source: https://github.com/mautic/mautic/blob/3813aee10a279da5cffe2b2bd391cc63d4a8cb6e/app/bundles/ChannelBundle/Event/ChannelBroadcastEvent.php#L10

Comment thread docs/plugin_extensions/channels.rst Outdated

.. note::

From Mautic 8.0, Mautic dispatches and subscribes to these ChannelBundle events by their event class name (for example ``ChannelEvent::class``) rather than the ``ChannelEvents`` constant. A subscriber still keyed on the old ``ChannelEvents`` constant silently stops receiving the event, so re-key it on the event class. The ``ChannelEvents`` constants stay defined for backward compatibility but no longer route dispatch for these events.

@promptless-for-oss promptless-for-oss Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Current note text (single sentence): from Mautic 8.0, subscribers to these ChannelBundle events key on the event class (e.g. ChannelEvent::class), following the Symfony convention of dispatching events by class name since Symfony 4.3. Verified against UPGRADE-8.0.md (added in mautic/mautic PR #17201), which documents the ChannelEvents constant -> event class rekeying for ADD_CHANNEL, CHANNEL_BROADCAST, MESSAGE_QUEUED, PROCESS_MESSAGE_QUEUE, PROCESS_MESSAGE_QUEUE_BATCH, and attributes the behavior to "Symfony 4.3+".

Source: https://github.com/mautic/mautic/blob/3813aee10a279da5cffe2b2bd391cc63d4a8cb6e/UPGRADE-8.0.md#L283-L305

Comment thread docs/plugin_extensions/channels.rst Outdated

.. note::

From Mautic 8.0, Mautic dispatches and subscribes to these ChannelBundle events by their event class name (for example ``ChannelEvent::class``) rather than the ``ChannelEvents`` constant. A subscriber still keyed on the old ``ChannelEvents`` constant silently stops receiving the event, so re-key it on the event class. The ``ChannelEvents`` constants stay defined for backward compatibility but no longer route dispatch for these events.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirms Mautic\ChannelBundle\ChannelEvents constants class still exists, unmodified by PR #17201's diff, i.e. the constants are retained for backward compatibility even though they no longer route dispatch of the five converted events.

Source: https://github.com/mautic/mautic/blob/3813aee10a279da5cffe2b2bd391cc63d4a8cb6e/app/bundles/ChannelBundle/ChannelEvents.php#L7

Comment thread docs/plugin_extensions/channels.rst Outdated
@adiati98 adiati98 added this to the 8.0 milestone Sep 2, 2026
@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

Thanks @adiati98 — will do. I'll swap the parentheses for a hyphen on docs/plugin_extensions/channels.rst and push the update to this PR.

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

Update: confirmed the spot — the aside (for example ``ChannelEvent::class``) in the note on channels.rst. Reworking it to the spaced-hyphen style the dev docs use for mid-sentence asides, then pushing.

Applies maintainer @adiati98's review on PR mautic#644: the dev-docs corpus
sets off mid-sentence 'for example' asides with paired spaced hyphens
(docs/design/labelling.rst), not parentheses.
@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

Thanks @adiati98 — done. I've replaced the parentheses around the "for example" aside in the Mautic 8.0 note with the paired hyphen form the dev docs use elsewhere, so it now reads "...by their event class name - for example, ChannelEvent::class - rather than the ChannelEvents constant." That was the only place the parenthetical pattern appeared in the change. Vale passes on the updated line, and the change is pushed to this PR.

@promptless-for-oss
promptless-for-oss marked this pull request as ready for review September 2, 2026 18:04
Comment thread docs/plugin_extensions/channels.rst Outdated

.. note::

From Mautic 8.0, Mautic dispatches and subscribes to these ChannelBundle events by their event class name - for example, ``ChannelEvent::class`` - rather than the ``ChannelEvents`` constant. A subscriber still keyed on the old ``ChannelEvents`` constant silently stops receiving the event, so re-key it on the event class. The ``ChannelEvents`` constants stay defined for backward compatibility but no longer route dispatch for these events.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps we could find a way how to shorten these notes and also say that it's how Symfony does it since v4.3

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

Thanks @escopecz — good call. I'll tighten these notes and frame keying subscribers on the event class as the Symfony 4.3+ convention, and push an update here shortly.

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

Update: verified against the 8.x source and revising the PR now. I'm shortening the note and framing this as the Symfony 4.3+ dispatch-by-event-class convention, and dropping the "silently stops receiving"/BC-framing. The corrected subscriber examples (keyed on ChannelEvent::class / ChannelBroadcastEvent::class) stay as-is.

Applies @escopecz's review on PR mautic#644: shorten the note added after the
first subscriber example and state that keying subscribers on the event
class is the Symfony convention since Symfony 4.3. Drops the silent-failure
warning and backward-compatibility framing.

.. note::

From Mautic 8.0, key subscribers to these ChannelBundle events on the event class—for example, ``ChannelEvent::class``—following the Symfony convention for dispatching events by class name since Symfony 4.3.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirms the "since Symfony 4.3" attribution: Symfony 4.3 changed EventDispatcherInterface::dispatch() so the event name argument became optional (dispatch($event) instead of dispatch($eventName, $event)), and listeners/subscribers can key on the event's FQCN (e.g. OrderPlacedEvent::class) instead of an arbitrary string constant. This is the convention line 61 attributes to Symfony 4.3.

Source: https://symfony.com/blog/new-in-symfony-4-3-simpler-event-dispatching

@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.

LGTM

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

@escopecz done — the note is now a single sentence attributing the pattern to the Symfony convention for dispatching events by class name (since Symfony 4.3). I also confirmed against the 8.x source that ChannelEvents is kept (not removed), so the note no longer warns about subscribers "silently stopping" or frames the constants as merely kept for BC; it just tells developers to key these ChannelBundle subscribers on the event class. Corrected examples unchanged; Vale passes. Pushed to this PR.

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.

4 participants