Skip to content
11 changes: 7 additions & 4 deletions docs/plugin_extensions/channels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ You can find several events through the ``ChannelEvents`` class.
public static function getSubscribedEvents()
{
return [
ChannelEvents::ADD_CHANNEL => ['onAddChannel', 100],
ChannelEvent::class => ['onAddChannel', 100],
Comment thread
adiati98 marked this conversation as resolved.
];
}

Expand All @@ -56,13 +56,17 @@ You can find several events through the ``ChannelEvents`` class.
);
}

.. note::

From Mautic 8.0, ChannelBundle events key on the event class - for example, ``ChannelEvent::class`` and ``ChannelBroadcastEvent::class``. For the rationale, see :ref:`Mautic 8 class-name event dispatch <Mautic 8 class-name event dispatch>`.

Extending broadcasts
--------------------

Broadcasts are communications sent in bulk through a Channel such as Email.
An event is available to execute the sending of these bulk communications via the ``mautic:broadcasts:send`` command.

To hook into the ``mautic:broadcasts:send`` command, create a listener for the ``\Mautic\CoreBundle\CoreEvents::CHANNEL_BROADCAST`` event.
To hook into the ``mautic:broadcasts:send`` command, create a listener for the ``\Mautic\ChannelBundle\Event\ChannelBroadcastEvent`` event.
The event listener should check for the appropriate context and ID.

.. code-block:: php
Expand All @@ -74,7 +78,6 @@ The event listener should check for the appropriate context and ID.

namespace MauticPlugin\HelloWorldBundle\EventListener;

use Mautic\ChannelBundle\ChannelEvents;
use Mautic\ChannelBundle\Event\ChannelBroadcastEvent;
use MauticPlugin\HelloWorldPlugin\Model\WorldModel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand All @@ -91,7 +94,7 @@ The event listener should check for the appropriate context and ID.
public static function getSubscribedEvents(): array
{
return [
ChannelEvents::CHANNEL_BROADCAST => ['onChannelBroadcast', 0]
ChannelBroadcastEvent::class => ['onChannelBroadcast', 0],
Comment thread
adiati98 marked this conversation as resolved.
];
}

Expand Down
Loading