1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright (C) 2020 Jan Böhmer |
4
|
|
|
* |
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
6
|
|
|
* it under the terms of the GNU Affero General Public License as published |
7
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
8
|
|
|
* (at your option) any later version. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU Affero General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU Affero General Public License |
16
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace App; |
20
|
|
|
|
21
|
|
|
use App\Message\PaymentOrder\PaymentOrderDeletedNotification; |
22
|
|
|
use App\Services\ReplyEmailDecisonMaker; |
23
|
|
|
use Symfony\Bridge\Twig\Mime\TemplatedEmail; |
24
|
|
|
use Symfony\Component\Mailer\MailerInterface; |
25
|
|
|
use Symfony\Component\Messenger\Handler\MessageHandlerInterface; |
26
|
|
|
use Symfony\Component\Mime\Email; |
27
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
28
|
|
|
|
29
|
|
|
class PaymentOrderDeletedNotificationHandler implements MessageHandlerInterface |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
private $mailer; |
33
|
|
|
private $reply_decision_maker; |
34
|
|
|
private $translator; |
35
|
|
|
|
36
|
|
|
public function __construct(MailerInterface $mailer, ReplyEmailDecisonMaker $reply_decision_maker, TranslatorInterface $translator) |
37
|
|
|
{ |
38
|
|
|
$this->mailer = $mailer; |
39
|
|
|
$this->reply_decision_maker = $reply_decision_maker; |
40
|
|
|
$this->translator = $translator; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function __invoke(PaymentOrderDeletedNotification $message) |
44
|
|
|
{ |
45
|
|
|
$paymentOrder = $message->getPaymentOrder(); |
46
|
|
|
|
47
|
|
|
$email = new TemplatedEmail(); |
48
|
|
|
$email->priority(Email::PRIORITY_HIGH); |
49
|
|
|
$reply_to_email = $this->reply_decision_maker->getReplyToMailForPaymentOrder($paymentOrder); |
50
|
|
|
$email->replyTo($reply_to_email); |
51
|
|
|
|
52
|
|
|
$email->subject( |
53
|
|
|
$this->translator->trans( |
54
|
|
|
'payment_order.deletion_email.subject', |
55
|
|
|
[ |
56
|
|
|
'%project%' => $paymentOrder->getProjectName(), |
57
|
|
|
] |
58
|
|
|
)); |
59
|
|
|
|
60
|
|
|
$email->htmlTemplate('mails/deletion_notification.html.twig'); |
61
|
|
|
$email->context([ |
62
|
|
|
'payment_order' => $paymentOrder, |
63
|
|
|
'blame_user' => $message->getBlameUser(), |
64
|
|
|
'deleted_where' => $message->getDeletedWhere(), |
65
|
|
|
]); |
66
|
|
|
|
67
|
|
|
//Send the email to the FSR officers and the HHV/FSB |
68
|
|
|
$email_addresses = array_merge( |
69
|
|
|
$paymentOrder->getDepartment()->getEmailHhv(), |
70
|
|
|
$paymentOrder->getDepartment()->getEmailTreasurer(), |
71
|
|
|
[$reply_to_email] |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
$email->addBcc(...$email_addresses); |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
//Send email |
78
|
|
|
$this->mailer->send($email); |
79
|
|
|
} |
80
|
|
|
} |