This repository has been archived by the owner on Sep 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
EventListener.php
72 lines (59 loc) · 1.94 KB
/
EventListener.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace Knp\Bundle\MailjetBundle\Event\Listener;
use Knp\Bundle\MailjetBundle\Event\Adapter\BlockedEvent;
use Knp\Bundle\MailjetBundle\Event\Adapter\BounceEvent;
use Knp\Bundle\MailjetBundle\Event\Adapter\ClickEvent;
use Knp\Bundle\MailjetBundle\Event\Adapter\OpenEvent;
use Knp\Bundle\MailjetBundle\Event\Adapter\SpamEvent;
use Knp\Bundle\MailjetBundle\Event\Adapter\TypofixEvent;
use Knp\Bundle\MailjetBundle\Event\Adapter\UnsubEvent;
use Knp\Bundle\MailjetBundle\Event\EventAdapter;
use Psr\Log\LoggerInterface;
/**
* ******************** NB! ***************************** *
* THIS CLASS IS JUST FOR DEMONSTRATION AND DEBUGGING *
* DO NOT EXTEND FROM THIS CLASS FOR YOUR IMPLEMENTATION *
* YOU SHOULD IMPLEMENT FROM EventListenerInterface *
* ******************** NB! ***************************** *
*/
class EventListener implements EventListenerInterface
{
protected $logger;
protected $logMessageTemplate = 'Caught Mailjet event: %s with following data: %s';
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
public function onOpenEvent(OpenEvent $event)
{
$this->logEvent($event);
}
public function onSpamEvent(SpamEvent $event)
{
$this->logEvent($event);
}
public function onClickEvent(ClickEvent $event)
{
$this->logEvent($event);
}
public function onUnsubEvent(UnsubEvent $event)
{
$this->logEvent($event);
}
public function onBounceEvent(BounceEvent $event)
{
$this->logEvent($event);
}
public function onBlockedEvent(BlockedEvent $event)
{
$this->logEvent($event);
}
public function onTypofixEvent(TypofixEvent $event)
{
$this->logEvent($event);
}
protected function logEvent(EventAdapter $event)
{
$this->logger->debug(sprintf($this->logMessageTemplate, $event->getType(), json_encode($event->getData())));
}
}