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\Message\PaymentOrder; |
20
|
|
|
|
21
|
|
|
use App\Entity\PaymentOrder; |
22
|
|
|
|
23
|
|
|
class PaymentOrderDeletedNotification |
24
|
|
|
{ |
25
|
|
|
public const DELETED_WHERE_FRONTEND = "frontend"; |
26
|
|
|
public const DELETED_WHERE_BACKEND = "backend"; |
27
|
|
|
|
28
|
|
|
private const DELETED_WHERE = [self::DELETED_WHERE_FRONTEND, self::DELETED_WHERE_BACKEND]; |
29
|
|
|
|
30
|
|
|
/** @var PaymentOrder The payment order that was deleted. We need to pass the full payment order, so that we can use it even after it was removed */ |
31
|
|
|
private $payment_order; |
32
|
|
|
|
33
|
|
|
/** @var string The user who did the deletion */ |
34
|
|
|
private $blame_user; |
35
|
|
|
|
36
|
|
|
/** @var string Whether the payment order was deleted in backend or frontend */ |
37
|
|
|
private $deleted_where; |
38
|
|
|
|
39
|
|
|
public function __construct(PaymentOrder $payment_order, string $blame_user, string $deleted_where) |
40
|
|
|
{ |
41
|
|
|
if (!in_array($deleted_where, self::DELETED_WHERE)) { |
42
|
|
|
throw new \InvalidArgumentException('$deleted_where has an value that is not allowed!'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$this->payment_order = $payment_order; |
46
|
|
|
$this->blame_user = $blame_user; |
47
|
|
|
$this->deleted_where = $deleted_where; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getPaymentOrder(): PaymentOrder |
51
|
|
|
{ |
52
|
|
|
return $this->payment_order; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getBlameUser(): string |
56
|
|
|
{ |
57
|
|
|
return $this->blame_user; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getDeletedWhere(): string |
61
|
|
|
{ |
62
|
|
|
return $this->deleted_where; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |