1 | <?php |
||
26 | class EmailQueueItem extends AbstractModel implements QueueItemInterface |
||
|
|||
27 | { |
||
28 | use QueueItemTrait; |
||
29 | use EmailAwareTrait; |
||
30 | |||
31 | /** |
||
32 | * The recipient's email address. |
||
33 | * |
||
34 | * @var string $to |
||
35 | */ |
||
36 | private $to; |
||
37 | |||
38 | /** |
||
39 | * The sender's email address. |
||
40 | * |
||
41 | * @var string $from |
||
42 | */ |
||
43 | private $from; |
||
44 | |||
45 | /** |
||
46 | * The email subject. |
||
47 | * |
||
48 | * @var string $subject. |
||
49 | */ |
||
50 | private $subject; |
||
51 | |||
52 | /** |
||
53 | * The HTML message body. |
||
54 | * |
||
55 | * @var string $msgHtml |
||
56 | */ |
||
57 | private $msgHtml; |
||
58 | |||
59 | /** |
||
60 | * The plain-text message body. |
||
61 | * |
||
62 | * @var string $msgTxt |
||
63 | */ |
||
64 | private $msgTxt; |
||
65 | |||
66 | /** |
||
67 | * The campaign ID. |
||
68 | * |
||
69 | * @var string $campaign |
||
70 | */ |
||
71 | private $campaign; |
||
72 | |||
73 | /** |
||
74 | * @var FactoryInterface $emailFactory |
||
75 | */ |
||
76 | private $emailFactory; |
||
77 | |||
78 | /** |
||
79 | * Get the primary key that uniquely identifies each queue item. |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | public function key() |
||
87 | |||
88 | /** |
||
89 | * Set the recipient's email address. |
||
90 | * |
||
91 | * @param string|array $email An email address. |
||
92 | * @return self |
||
93 | */ |
||
94 | public function setTo($email) |
||
103 | |||
104 | /** |
||
105 | * Get the recipient's email address. |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | public function to() |
||
113 | |||
114 | /** |
||
115 | * Set the sender's email address. |
||
116 | * |
||
117 | * @param string|array $email An email address. |
||
118 | * @return self |
||
119 | */ |
||
120 | public function setFrom($email) |
||
129 | |||
130 | /** |
||
131 | * Get the sender's email address. |
||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | public function from() |
||
139 | |||
140 | /** |
||
141 | * Set the email subject. |
||
142 | * |
||
143 | * @param string $subject The email subject. |
||
144 | * @return self |
||
145 | */ |
||
146 | public function setSubject($subject) |
||
151 | |||
152 | /** |
||
153 | * Get the email subject. |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | public function subject() |
||
161 | |||
162 | /** |
||
163 | * Set the email's HTML message body. |
||
164 | * |
||
165 | * @param string $body The HTML message body. |
||
166 | * @return self |
||
167 | */ |
||
168 | public function setMsgHtml($body) |
||
173 | |||
174 | /** |
||
175 | * Get the email's HTML message body. |
||
176 | * |
||
177 | * @return string |
||
178 | */ |
||
179 | public function msgHtml() |
||
183 | |||
184 | /** |
||
185 | * Set the email's plain-text message body. |
||
186 | * |
||
187 | * @param string $body The plain-text mesage body. |
||
188 | * @return self |
||
189 | */ |
||
190 | public function setMsgTxt($body) |
||
195 | |||
196 | /** |
||
197 | * Get the email's plain-text message body. |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | public function msgTxt() |
||
205 | |||
206 | /** |
||
207 | * Set the campaign ID. |
||
208 | * |
||
209 | * @param string $campaign The campaign identifier. |
||
210 | * @return self |
||
211 | */ |
||
212 | public function setCampaign($campaign) |
||
217 | |||
218 | /** |
||
219 | * Get the campaign ID. |
||
220 | * |
||
221 | * If it has not been explicitely set, it will be auto-generated (with uniqid). |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | public function campaign() |
||
229 | |||
230 | /** |
||
231 | * Process the item. |
||
232 | * |
||
233 | * @param callable $alwaysCallback An optional callback routine executed after the item is processed. |
||
234 | * @param callable $successCallback An optional callback routine executed when the item is resolved. |
||
235 | * @param callable $failureCallback An optional callback routine executed when the item is rejected. |
||
236 | * @return boolean|null Returns TRUE i this item was successfully processed, |
||
237 | * FALSE on failure or if an error occurs, NULL if this item is already processed. |
||
238 | */ |
||
239 | public function process( |
||
289 | |||
290 | /** |
||
291 | * @param Container $container Pimple DI container. |
||
292 | * @return void |
||
293 | */ |
||
294 | protected function setDependencies(Container $container): void |
||
299 | |||
300 | /** |
||
301 | * Hook called before saving the item. |
||
302 | * |
||
303 | * @return boolean |
||
304 | * @see \Charcoal\Queue\QueueItemTrait::preSaveQueueItem() |
||
305 | */ |
||
306 | protected function preSave(): bool |
||
314 | |||
315 | /** |
||
316 | * @return FactoryInterface |
||
317 | */ |
||
318 | protected function emailFactory(): FactoryInterface |
||
322 | |||
323 | /** |
||
324 | * @param FactoryInterface $factory The factory to create email objects. |
||
325 | * @return void |
||
326 | */ |
||
327 | private function setEmailFactory(FactoryInterface $factory): void |
||
331 | } |
||
332 |