Channels ######## Todo: .. vale off Listening for Channel features ------------------------------ .. vale on You can find several events through the ``ChannelEvents`` class. .. code-block:: php ['onAddChannel', 100], ]; } public function onAddChannel(ChannelEvent $event) { $event->addChannel( 'email', [ MessageModel::CHANNEL_FEATURE => [ 'campaignAction' => 'email.send', 'campaignDecisionsSupported' => [ 'email.open', 'page.pagehit', 'asset.download', 'form.submit', ], 'lookupFormType' => EmailListType::class, ], LeadModel::CHANNEL_FEATURE => [], ReportModel::CHANNEL_FEATURE => [ 'table' => 'emails', ], ] ); } 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. The event listener should check for the appropriate context and ID. .. code-block:: php model = $model; } public static function getSubscribedEvents(): array { return [ ChannelEvents::CHANNEL_BROADCAST => ['onChannelBroadcast', 0] ]; } public function onChannelBroadcast(ChannelBroadcastEvent $event): void { if (!$event->checkContext('world')) { return; } // Get list of published broadcasts or broadcast if there is only a single ID $id = $event->getId(); $broadcasts = $this->model->getRepository()->getPublishedBroadcasts($id); $output = $event->getOutput(); while (($broadcast = $broadcasts->next()) !== false) { list($sentCount, $failedCount, $ignore) = $this->model->sendIntergalacticMessages($broadcast[0], null, 100, true, $output); $event->setResults($this->translator->trans('plugin.helloworld').': '.$broadcast[0]->getName(), $sentCount, $failedCount); } } }