1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MtMail - e-mail module for Zend Framework |
4
|
|
|
* |
5
|
|
|
* @link http://github.com/mtymek/MtMail |
6
|
|
|
* @copyright Copyright (c) 2013-2017 Mateusz Tymek |
7
|
|
|
* @license BSD 2-Clause |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace MtMail\Event; |
11
|
|
|
|
12
|
|
|
use MtMail\Template\TemplateInterface; |
13
|
|
|
use Zend\EventManager\Event; |
14
|
|
|
use Zend\Mail\Message; |
15
|
|
|
use Zend\View\Model\ModelInterface; |
16
|
|
|
use Zend\Mime\Message as MimeMessage; |
17
|
|
|
|
18
|
|
|
class ComposerEvent extends Event |
19
|
|
|
{ |
20
|
|
|
/**#@+ |
21
|
|
|
* Mail events |
22
|
|
|
*/ |
23
|
|
|
const EVENT_COMPOSE_PRE = 'compose.pre'; |
24
|
|
|
const EVENT_COMPOSE_POST = 'compose.post'; |
25
|
|
|
const EVENT_HEADERS_PRE = 'headers.pre'; |
26
|
|
|
const EVENT_HEADERS_POST = 'headers.post'; |
27
|
|
|
const EVENT_HTML_BODY_PRE = 'html_body.pre'; |
28
|
|
|
const EVENT_HTML_BODY_POST = 'html_body.post'; |
29
|
|
|
const EVENT_TEXT_BODY_PRE = 'text_body.pre'; |
30
|
|
|
const EVENT_TEXT_BODY_POST = 'text_body.post'; |
31
|
|
|
/**#@-*/ |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var TemplateInterface |
35
|
|
|
*/ |
36
|
|
|
protected $template; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var Message |
40
|
|
|
*/ |
41
|
|
|
protected $message; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var MimeMessage |
45
|
|
|
*/ |
46
|
|
|
protected $body; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var ModelInterface |
50
|
|
|
*/ |
51
|
|
|
protected $viewModel; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param Message $message |
55
|
|
|
* @return self |
56
|
|
|
*/ |
57
|
10 |
|
public function setMessage(Message $message) |
58
|
|
|
{ |
59
|
10 |
|
$this->message = $message; |
60
|
|
|
|
61
|
10 |
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return Message |
66
|
|
|
*/ |
67
|
10 |
|
public function getMessage() |
68
|
|
|
{ |
69
|
10 |
|
if (!$this->message instanceof Message) { |
70
|
5 |
|
$this->setMessage(new Message); |
71
|
|
|
} |
72
|
|
|
|
73
|
10 |
|
return $this->message; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param ModelInterface $viewModel |
78
|
|
|
* @return self |
79
|
|
|
*/ |
80
|
8 |
|
public function setViewModel(ModelInterface $viewModel) |
81
|
|
|
{ |
82
|
8 |
|
$this->viewModel = $viewModel; |
83
|
|
|
|
84
|
8 |
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return ModelInterface |
89
|
|
|
*/ |
90
|
8 |
|
public function getViewModel() |
91
|
|
|
{ |
92
|
8 |
|
return $this->viewModel; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param \Zend\Mime\Message $body |
97
|
|
|
* @return self |
98
|
|
|
*/ |
99
|
5 |
|
public function setBody($body) |
100
|
|
|
{ |
101
|
5 |
|
$this->body = $body; |
102
|
|
|
|
103
|
5 |
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return \Zend\Mime\Message |
108
|
|
|
*/ |
109
|
|
|
public function getBody() |
110
|
|
|
{ |
111
|
|
|
return $this->body; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param TemplateInterface $template |
116
|
|
|
*/ |
117
|
8 |
|
public function setTemplate(TemplateInterface $template) |
118
|
|
|
{ |
119
|
8 |
|
$this->template = $template; |
120
|
8 |
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return TemplateInterface |
124
|
|
|
*/ |
125
|
6 |
|
public function getTemplate() |
126
|
|
|
{ |
127
|
6 |
|
return $this->template; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|