Document Mautic 8 class-name dispatch for WebhookBundle events - #646
Document Mautic 8 class-name dispatch for WebhookBundle events#646promptless-for-oss wants to merge 3 commits into
Conversation
Note that WebhookBuilderEvent, WebhookQueueEvent, and WebhookRequestEvent now dispatch by class name (Symfony 4.3 style), so subscribers must key getSubscribedEvents() on the event class rather than the WebhookEvents constant. Mirrors mautic/mautic PR #17202.
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, Mautic dispatches three ``Mautic\WebhookBundle\Event`` events by the event object alone, so the event class is the event name. This matches the Symfony 4.3 dispatch style. |
There was a problem hiding this comment.
Mautic 8 (PR #17202) dispatches WebhookBuilderEvent (getEvents()) by the event object alone via $this->dispatcher->dispatch($event), dropping the former WebhookEvents::WEBHOOK_ON_BUILD name argument.
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, Mautic dispatches three ``Mautic\WebhookBundle\Event`` events by the event object alone, so the event class is the event name. This matches the Symfony 4.3 dispatch style. |
There was a problem hiding this comment.
queueWebhook() now checks hasListeners(Events\WebhookQueueEvent::class) and dispatches WebhookQueueEvent by class alone, replacing the former WebhookEvents::WEBHOOK_QUEUE_ON_ADD constant usage.
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, Mautic dispatches three ``Mautic\WebhookBundle\Event`` events by the event object alone, so the event class is the event name. This matches the Symfony 4.3 dispatch style. |
There was a problem hiding this comment.
CampaignHelper::fireWebhook() dispatches WebhookRequestEvent by the event object alone, replacing the former WebhookEvents::WEBHOOK_ON_REQUEST constant usage.
|
|
||
| Since Mautic 8, Mautic dispatches three ``Mautic\WebhookBundle\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 ``WebhookBuilderEvent::class``, not on the matching ``Mautic\WebhookBundle\WebhookEvents`` constant or its string value. |
There was a problem hiding this comment.
Converted subscriber keys getSubscribedEvents() on WebhookBuilderEvent::class and WebhookQueueEvent::class instead of the former WebhookEvents string constants.
| Since Mautic 8, Mautic dispatches three ``Mautic\WebhookBundle\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 ``WebhookBuilderEvent::class``, not on the matching ``Mautic\WebhookBundle\WebhookEvents`` constant or its string value. | ||
| * The ``WebhookEvents`` 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.
WebhookEvents constants WEBHOOK_ON_BUILD, WEBHOOK_QUEUE_ON_ADD, and WEBHOOK_ON_REQUEST remain defined in the class for backward compatibility even though they are no longer used to dispatch these three events.
|
|
||
| * For a converted event, key ``getSubscribedEvents()`` on the event class, for example ``WebhookBuilderEvent::class``, not on the matching ``Mautic\WebhookBundle\WebhookEvents`` constant or its string value. | ||
| * The ``WebhookEvents`` 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. | ||
| * Mautic 8 converted only ``WebhookBuilderEvent``, ``WebhookQueueEvent``, and ``WebhookRequestEvent``, each of whose class maps to a single name. Families whose class serves several names, such as ``WebhookEvent`` (dispatched for ``WEBHOOK_PRE_SAVE``, ``WEBHOOK_POST_SAVE``, ``WEBHOOK_PRE_DELETE``, ``WEBHOOK_POST_DELETE``, and ``WEBHOOK_KILL``), still dispatch by their ``WebhookEvents`` constants, so keep keying on the constant for those. |
There was a problem hiding this comment.
dispatchEvent() still maps WEBHOOK_PRE_SAVE/POST_SAVE/PRE_DELETE/POST_DELETE to the shared WebhookEvent class and dispatches by the WebhookEvents string constant ($name), unconverted because one class serves several event names.
|
|
||
| * For a converted event, key ``getSubscribedEvents()`` on the event class, for example ``WebhookBuilderEvent::class``, not on the matching ``Mautic\WebhookBundle\WebhookEvents`` constant or its string value. | ||
| * The ``WebhookEvents`` 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. | ||
| * Mautic 8 converted only ``WebhookBuilderEvent``, ``WebhookQueueEvent``, and ``WebhookRequestEvent``, each of whose class maps to a single name. Families whose class serves several names, such as ``WebhookEvent`` (dispatched for ``WEBHOOK_PRE_SAVE``, ``WEBHOOK_POST_SAVE``, ``WEBHOOK_PRE_DELETE``, ``WEBHOOK_POST_DELETE``, and ``WEBHOOK_KILL``), still dispatch by their ``WebhookEvents`` constants, so keep keying on the constant for those. |
There was a problem hiding this comment.
killWebhook() still constructs the shared WebhookEvent class and dispatches by the WebhookEvents::WEBHOOK_KILL string constant, unconverted.
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, Mautic dispatches three ``Mautic\WebhookBundle\Event`` events by the event object alone, so the event class is the event name. This matches the Symfony 4.3 dispatch style. |
There was a problem hiding this comment.
Symfony 4.3 event-dispatcher changelog documents the dispatch(Event $event, string $eventName = null) signature change (event object first, name optional/derived from class), which is the dispatch style Mautic 8 now uses for the converted WebhookBundle events.
Source: https://github.com/symfony/event-dispatcher/blob/v4.3.0/CHANGELOG.md
adiati98
left a comment
There was a problem hiding this comment.
@promptless-for-oss please address the Vale warnings. We use hyphen instead of parentheses.
|
Thanks @adiati98 — on it. I'll address the Vale warnings and switch the parenthetical asides to hyphens, run Vale, and push the updates to this PR shortly. |
…side Convert the parenthetical aside in the Available events note to the repo's spaced-hyphen form, per maintainer review on PR mautic#646.
|
Done @adiati98 — converted the parenthetical aside in the WebhookBundle events note to the spaced-hyphen form, which also clears the Vale (Google.Parens) warning. |
|
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. |
Open in Promptless
Mautic 8 converts three WebhookBundle events to Symfony 4.3-style dispatch-by-class-name, so a Plugin that subscribes to them must key
getSubscribedEvents()on the event class instead of theWebhookEventsstring constant. A subscriber left keyed on a converted constant stops firing silently — with no exception and no log — so plugin developers need to know which events changed and which did not.This adds a note to the "Available events" section of
docs/plugins/event_listeners.rstexplaining the new keying convention: the three converted events (WebhookBuilderEvent,WebhookQueueEvent,WebhookRequestEvent) key on the event class, while the shared-classWebhookEventfamily (WEBHOOK_PRE_SAVE,WEBHOOK_POST_SAVE,WEBHOOK_PRE_DELETE,WEBHOOK_POST_DELETE,WEBHOOK_KILL) still dispatches by constant. It mirrors the note added for the sibling IntegrationsBundle conversion.Trigger Events