Skip to content
9 changes: 5 additions & 4 deletions docs/plugins/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Install and update events

.. note:: The events below are available since Mautic 4.2.0.

You can create event listeners as follows:
Since Mautic 8, key your subscriber on the event class, ``PluginInstallEvent::class`` and ``PluginUpdateEvent::class``, rather than on a ``PluginEvents`` constant:
Comment thread
adiati98 marked this conversation as resolved.

.. code-block:: php

Expand All @@ -22,16 +22,15 @@ You can create event listeners as follows:

use Mautic\PluginBundle\Event\PluginInstallEvent;
use Mautic\PluginBundle\Event\PluginUpdateEvent;
Comment thread
adiati98 marked this conversation as resolved.
use Mautic\PluginBundle\PluginEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class InstallUpdateSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
PluginEvents::ON_PLUGIN_INSTALL => ['onPluginInstall', 0],
PluginEvents::ON_PLUGIN_UPDATE => ['onPluginUpdate', 0],
PluginInstallEvent::class => ['onPluginInstall', 0],
Comment thread
adiati98 marked this conversation as resolved.
PluginUpdateEvent::class => ['onPluginUpdate', 0],
];
}

Expand All @@ -46,6 +45,8 @@ You can create event listeners as follows:
}
}

For why this changed and what breaks if you don't re-key, see :ref:`Mautic 8 class-name event dispatch <Mautic 8 class-name event dispatch>`.

Database migrations
===================

Expand Down
Loading