-
Notifications
You must be signed in to change notification settings - Fork 26
/
Emailvision.php
59 lines (51 loc) · 1.49 KB
/
Emailvision.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
<?php
namespace Namshi\Notificator\Notification\Handler;
use Namshi\Notificator\Notification\Email\Emailvision\ClientInterface;
use Namshi\Notificator\NotificationInterface;
use Namshi\Notificator\Notification\Email\Emailvision\EmailvisionNotificationInterface;
/**
* This class handles notifications that should be sent via email.
*/
class Emailvision extends Email
{
protected $emailClient;
/**
* Constructor
*
* @param \Namshi\Notificator\Notification\Email\Emailvision\ClientInterface $emailClient
*/
public function __construct(ClientInterface $emailClient)
{
$this->emailClient = $emailClient;
}
/**
* @inheritDoc
*/
public function handle(NotificationInterface $notification)
{
foreach ($notification->getRecipientAddresses() as $recipientAddress) {
$this->getEmailClient()->sendEmail(
$notification->getEmailTemplate(),
$recipientAddress,
$notification->getParameters()
);
}
return true;
}
/**
* @inheritDoc
*/
public function shouldHandle(NotificationInterface $notification)
{
return $notification instanceof EmailvisionNotificationInterface;
}
/**
* Returns the email client used by this handler.
*
* @return \Namshi\Notificator\Notification\Email\Emailvision\ClientInterface
*/
public function getEmailClient()
{
return $this->emailClient;
}
}