File size: 1,033 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

namespace Mautic\CampaignBundle\Membership;

use Mautic\CampaignBundle\CampaignEvents;
use Mautic\CampaignBundle\Entity\Campaign;
use Mautic\CampaignBundle\Event\CampaignLeadChangeEvent;
use Mautic\LeadBundle\Entity\Lead;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class EventDispatcher
{
    public function __construct(
        private EventDispatcherInterface $dispatcher
    ) {
    }

    /**
     * @param string $action
     */
    public function dispatchMembershipChange(Lead $contact, Campaign $campaign, $action): void
    {
        $this->dispatcher->dispatch(
            new CampaignLeadChangeEvent($campaign, $contact, $action),
            CampaignEvents::CAMPAIGN_ON_LEADCHANGE
        );
    }

    public function dispatchBatchMembershipChange(array $contacts, Campaign $campaign, $action): void
    {
        $this->dispatcher->dispatch(
            new CampaignLeadChangeEvent($campaign, $contacts, $action),
            CampaignEvents::LEAD_CAMPAIGN_BATCH_CHANGE
        );
    }
}