Document Mautic 8 class-name dispatch for Form, Integration, and Focus events - #658
Conversation
…ation, and Focus events Source: mautic/mautic#17223
| - New event class | ||
| * - FormBundle | ||
| - ``mautic.form_on_submit`` | ||
| - ``FormEvents::FORM_ON_SUBMIT`` |
There was a problem hiding this comment.
Confirms FormEvents constant string values: FORM_ON_SUBMIT='mautic.form_on_submit' (L88), FORM_ON_BUILD='mautic.form_on_build' (L74), ON_OBJECT_COLLECT='mautic.form.on_object_collect' (L128), ON_FIELD_COLLECT='mautic.form.on_field_collect' (L136).
| - ``Mautic\FormBundle\Event\FieldCollectEvent`` | ||
| * - IntegrationsBundle | ||
| - ``mautic.integration.INTEGRATION_FIND_INTERNAL_RECORDS`` | ||
| - ``IntegrationEvents::INTEGRATION_FIND_INTERNAL_RECORDS`` |
There was a problem hiding this comment.
Confirms IntegrationEvents constant string values: INTEGRATION_FIND_INTERNAL_RECORDS='mautic.integration.INTEGRATION_FIND_INTERNAL_RECORDS' (L91), INTEGRATION_FIND_OWNER_IDS='mautic.integration.INTEGRATION_FIND_OWNER_IDS' (L98).
| - ``Mautic\IntegrationsBundle\Event\InternalObjectOwnerEvent`` | ||
| * - MauticFocusBundle | ||
| - ``mautic.focus.on_view`` | ||
| - ``FocusEvents::FOCUS_ON_VIEW`` |
There was a problem hiding this comment.
Confirms FocusEvents::FOCUS_ON_VIEW = 'mautic.focus.on_view'.
| - ``FocusEvents::FOCUS_ON_VIEW`` | ||
| - ``MauticPlugin\MauticFocusBundle\Event\FocusViewEvent`` | ||
|
|
||
| The FormBundle event classes live in the ``Mautic\FormBundle\Event`` namespace and the IntegrationsBundle event classes in the ``Mautic\IntegrationsBundle\Event`` namespace, both under ``app/bundles/``. MauticFocusBundle is a Plugin under ``plugins/``, so its event class is in the ``MauticPlugin\MauticFocusBundle\Event`` namespace. Note the different top-level namespace. |
There was a problem hiding this comment.
Confirms Mautic\FormBundle\Event namespace under app/bundles/ for the converted FormBundle event classes (SubmissionEvent, FormBuilderEvent, ObjectCollectEvent, FieldCollectEvent all live in app/bundles/FormBundle/Event/).
| - ``FocusEvents::FOCUS_ON_VIEW`` | ||
| - ``MauticPlugin\MauticFocusBundle\Event\FocusViewEvent`` | ||
|
|
||
| The FormBundle event classes live in the ``Mautic\FormBundle\Event`` namespace and the IntegrationsBundle event classes in the ``Mautic\IntegrationsBundle\Event`` namespace, both under ``app/bundles/``. MauticFocusBundle is a Plugin under ``plugins/``, so its event class is in the ``MauticPlugin\MauticFocusBundle\Event`` namespace. Note the different top-level namespace. |
There was a problem hiding this comment.
Confirms MauticPlugin\MauticFocusBundle\Event namespace under plugins/ for FocusViewEvent.
|
|
||
| .. warning:: | ||
|
|
||
| The string value of ``FormEvents::FORM_ON_SUBMIT`` is ``mautic.form_on_submit``, which is also the persisted Webhook event-type identifier in ``WebhookSubscriber``. Only the event-dispatch subscription moved to ``SubmissionEvent::class``. Webhook configuration and the type identifier are unaffected, so only your event-subscription code needs to change. |
There was a problem hiding this comment.
Confirms WebhookSubscriber::getSubscribedEvents() rekeyed to SubmissionEvent::class (L24) while FormEvents::FORM_ON_SUBMIT string constant is still used as the webhook type identifier in onWebhookBuild()/onFormSubmit() (L40, L46).
|
|
||
| .. warning:: | ||
|
|
||
| ``FocusEventTypes::FOCUS_ON_VIEW`` is a separate stat-type identifier and is untouched. Only ``FocusEvents::FOCUS_ON_VIEW`` converted to class-name dispatch. Don't confuse the two. |
There was a problem hiding this comment.
Confirms FocusEventTypes::FOCUS_ON_VIEW = 'focus.on_view' is a distinct class/value from FocusEvents::FOCUS_ON_VIEW ('mautic.focus.on_view'), left untouched by the PR.
|
|
||
| The FormBundle event classes live in the ``Mautic\FormBundle\Event`` namespace and the IntegrationsBundle event classes in the ``Mautic\IntegrationsBundle\Event`` namespace, both under ``app/bundles/``. MauticFocusBundle is a Plugin under ``plugins/``, so its event class is in the ``MauticPlugin\MauticFocusBundle\Event`` namespace. Note the different top-level namespace. | ||
|
|
||
| Only these seven events changed. Mautic keeps an event as a string constant when several event names share one event object, or when the event crosses bundle boundaries, so those events still dispatch by the string name. For example, the IntegrationsBundle ``INTEGRATION_CONFIG_*`` before-and-after pair reuses one ``ConfigSaveEvent``, and FormBundle's create, read, update, and delete group constants do the same. For those, the guidance in the "Available events" intro to always use the event constants still holds. |
There was a problem hiding this comment.
Confirms IntegrationEvents::INTEGRATION_CONFIG_BEFORE_SAVE/AFTER_SAVE remain string-constant dispatch, reusing one ConfigSaveEvent object ($configEvent) across both dispatch calls; not converted to class-name dispatch by this PR.
| public static function getSubscribedEvents(): array | ||
| { | ||
| return [ | ||
| FormEvents::FORM_ON_SUBMIT => ['onFormSubmit', 0], |
There was a problem hiding this comment.
Confirms a real subscriber rekeyed from FormEvents::FORM_ON_SUBMIT to SubmissionEvent::class in getSubscribedEvents(), matching the before/after code example pattern shown in the docs.
| public static function getSubscribedEvents(): array | ||
| { | ||
| return [ | ||
| SubmissionEvent::class => ['onFormSubmit', 0], |
There was a problem hiding this comment.
Source PR "[events] dispatch Form, Integrations and Focus bundle events by class name" (base 8.x); its UPGRADE-8.0.md addition documents the same seven-event mapping, the WebhookSubscriber/webhook-type-id exception, and the FocusEventTypes exception described in this doc subsection.
Source: mautic/mautic#17223
Open in Promptless
Mautic 8 dispatches seven events across FormBundle, IntegrationsBundle, and MauticFocusBundle by their event object (the Symfony 4.3+ convention) instead of the old
*Eventsstring constants. A plugin whose subscriber orkernel.event_listener-tagged service still keys on a converted constant silently stops receiving the event — no exception and no log entry — so developers upgrading to Mautic 8 need to know which events changed and re-key their listeners on the event class.This adds a subsection to the "Available events" page of the plugin developer docs covering the seven converted events (constant → new event class), the namespace difference for the
plugins/-based MauticFocusBundle, the events intentionally left as string constants, themautic.form_on_submitWebhook type-identifier exception, the distinctFocusEventTypes::FOCUS_ON_VIEWstat-type identifier, a before/aftergetSubscribedEvents()example, and abin/console debug:event-dispatcherverification tip. Follows the same template as the sibling bundle-migration documentation in this series.Trigger Events