-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractSending.php
More file actions
78 lines (62 loc) · 1.67 KB
/
AbstractSending.php
File metadata and controls
78 lines (62 loc) · 1.67 KB
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
73
74
75
76
77
78
<?php
namespace Netpeople\JangoMailBundle;
use Netpeople\JangoMailBundle\JangoMail;
use Netpeople\JangoMailBundle\Emails\EmailInterface;
/**
* Description of AbstractSending
*
* @author maguirre
*/
abstract class AbstractSending
{
/**
*
* @var JangoMail
*/
protected $jangoMail;
/**
*
* @var EmailInterface
*/
protected $email;
public function __construct(JangoMail $jangoMail)
{
$this->jangoMail = $jangoMail;
}
public function setEmail(EmailInterface $email)
{
$this->email = $email;
return $this;
}
public function getEmail()
{
return $this->email;
}
protected function getOptionsString()
{
$opts = array();
foreach ($this->prepareOptions() as $index => $value) {
$opts[] = "$index=$value";
}
return join(',', $opts);
}
protected function prepareOptions()
{
$options = ((array) $this->email->getOptions()) + (array) $this
->jangoMail->getConfig('options');
$options = array_intersect_key($options, $this->getValidOptions());
if (isset($options['BCC']) && is_array($options['BCC']) &&
is_array($this->jangoMail->getConfig('bcc'))) {
$options['BCC'] = array_merge($options['BCC'], $this
->jangoMail->getConfig('bcc'));
}
foreach ($options as $index => $value) {
if (null === $value || is_object($value)) {
unset($options[$index]);
}
}
return $options;
}
abstract public function send();
abstract public function getValidOptions();
}