Document Mautic 8 class-name dispatch for the DynamicContentBundle event - #645
Conversation
|
|
||
| .. note:: | ||
|
|
||
| Since Mautic 8, Mautic dispatches the ``ContactFiltersEvaluateEvent`` event 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.
Verifies: since Mautic 8, ContactFiltersEvaluateEvent is dispatched via $this->dispatcher->dispatch($event) with no name argument (Symfony 4.3+ style), so the event class is the event name. hasListeners(ContactFiltersEvaluateEvent::class) confirms the class itself is used as the lookup key. Note: doc text overgeneralizes this to "Mautic\DynamicContentBundle\Event events" (plural/whole namespace) rather than scoping to ContactFiltersEvaluateEvent specifically — see correction.
|
|
||
| Since Mautic 8, Mautic dispatches the ``ContactFiltersEvaluateEvent`` event by the event object alone, so the event class is the event name. This matches the Symfony 4.3 dispatch style. | ||
|
|
||
| * Key ``getSubscribedEvents()`` on ``ContactFiltersEvaluateEvent::class``, not on the matching ``Mautic\DynamicContentBundle\DynamicContentEvents`` constant (``ON_CONTACTS_FILTER_EVALUATE``) or its string value. |
There was a problem hiding this comment.
Verifies: core subscriber's getSubscribedEvents() keys on ContactFiltersEvaluateEvent::class, not on DynamicContentEvents::ON_CONTACTS_FILTER_EVALUATE or its string value 'mautic.dwc.on_contact_filters_evaluate'.
| Since Mautic 8, Mautic dispatches the ``ContactFiltersEvaluateEvent`` event by the event object alone, so the event class is the event name. This matches the Symfony 4.3 dispatch style. | ||
|
|
||
| * Key ``getSubscribedEvents()`` on ``ContactFiltersEvaluateEvent::class``, not on the matching ``Mautic\DynamicContentBundle\DynamicContentEvents`` constant (``ON_CONTACTS_FILTER_EVALUATE``) or its string value. | ||
| * The ``DynamicContentEvents`` 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.
Verifies: ON_CONTACTS_FILTER_EVALUATE constant kept for backwards compatibility but no longer used internally to dispatch; a subscriber still keyed on the old constant simply won't receive the event (standard Symfony dispatcher behavior when no listener matches the dispatched name — no exception, no log). Constant retained at DynamicContentEvents.php L107 (https://github.com/mautic/mautic/blob/39b1297c4121d6a8820803b909c1124587a190ec/app/bundles/DynamicContentBundle/DynamicContentEvents.php#L100-L107).
Source: https://github.com/mautic/mautic/blob/39b1297c4121d6a8820803b909c1124587a190ec/UPGRADE-8.0.md#L283
|
|
||
| * Key ``getSubscribedEvents()`` on ``ContactFiltersEvaluateEvent::class``, not on the matching ``Mautic\DynamicContentBundle\DynamicContentEvents`` constant (``ON_CONTACTS_FILTER_EVALUATE``) or its string value. | ||
| * The ``DynamicContentEvents`` 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 events whose class maps to a single name. The ``DynamicContentEvent`` CRUD group (``PRE_SAVE``, ``POST_SAVE``, ``PRE_DELETE``, ``POST_DELETE``) shares one event object dispatched under four names, so keep keying on those ``DynamicContentEvents`` constants. |
There was a problem hiding this comment.
Verifies: DynamicContentModel::dispatchEvent() creates a single DynamicContentEvent object and dispatches it under one of four DynamicContentEvents constants (PRE_SAVE/POST_SAVE/PRE_DELETE/POST_DELETE) depending on $action, via $this->dispatcher->dispatch($event, $name) — confirms this CRUD family was not converted to the object-only dispatch style and still keys on the DynamicContentEvents constants.
Open in Promptless
Mautic 8 dispatches the DynamicContentBundle
ContactFiltersEvaluateEventby the event object alone (Symfony 4.3 class-name style), so the event class is now the event name and theDynamicContentEvents::ON_CONTACTS_FILTER_EVALUATEstring constant is no longer used to dispatch it (though the constant remains in the codebase for backward compatibility). This adds a note to the "Available events" section of the plugin event-listeners page so plugin authors key aContactFiltersEvaluateEventsubscriber on the event class instead of the old constant.The note warns that a subscriber still keyed on the
ON_CONTACTS_FILTER_EVALUATEconstant (or its string value) silently stops firing under Mautic 8 — no exception, no log — and clarifies that theDynamicContentEventCRUD group (PRE_SAVE/POST_SAVE/PRE_DELETE/POST_DELETE) still dispatches by itsDynamicContentEventsconstants because it shares one event object across four names. This mirrors the notes added for the sibling CoreBundle, IntegrationsBundle, PluginBundle, and CampaignBundle conversions.Trigger Events