Skip to content

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

Draft
promptless-for-oss wants to merge 1 commit into
mautic:7.2from
Promptless:promptless/pr-17201-channel-events-by-class
Draft

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

Conversation

@promptless-for-oss

Copy link
Copy Markdown
Contributor

Open in Promptless

Mautic 8.0 dispatches five ChannelBundle events by their event class name (Symfony 4.3+ style) instead of the ChannelEvents::* string constants, so a plugin subscriber still keyed on one of those constants silently stops receiving the event. 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 new note explains the change and tells developers to re-key affected subscribers on the event class; the ChannelEvents constants remain defined for backward compatibility. Reflects mautic/mautic#17201 (targets 8.x, documented on the 7.2 docs branch).

Trigger Events

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


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

New note text: from Mautic 8.0, ChannelBundle events (ADD_CHANNEL, CHANNEL_BROADCAST, MESSAGE_QUEUED, PROCESS_MESSAGE_QUEUE, PROCESS_MESSAGE_QUEUE_BATCH) dispatch by event class name instead of the ChannelEvents string constants, so a subscriber keyed on the old constant stops receiving the event. Verified against UPGRADE-8.0.md (added in mautic/mautic PR #17201), which states the change and gives the full 5-row constant-to-class mapping table.

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


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant