1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* Copyright (C) |
6
|
|
|
* Nathan Boiron <[email protected]> |
7
|
|
|
* Romain Canon <[email protected]> |
8
|
|
|
* |
9
|
|
|
* This file is part of the TYPO3 NotiZ project. |
10
|
|
|
* It is free software; you can redistribute it and/or modify it |
11
|
|
|
* under the terms of the GNU General Public License, either |
12
|
|
|
* version 3 of the License, or any later version. |
13
|
|
|
* |
14
|
|
|
* For the full copyright and license information, see: |
15
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace CuyZ\Notiz\Core\Channel; |
19
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Core\Definition\Tree\Notification\NotificationDefinition; |
21
|
|
|
use CuyZ\Notiz\Core\Event\Event; |
22
|
|
|
use CuyZ\Notiz\Core\Notification\Notification; |
23
|
|
|
use CuyZ\Notiz\Core\Notification\Processor\NotificationProcessor; |
24
|
|
|
use CuyZ\Notiz\Core\Notification\Processor\NotificationProcessorFactory; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Object passed to a channel object when an event is fired and triggers a |
28
|
|
|
* notification dispatch. |
29
|
|
|
* |
30
|
|
|
* It gives access to: |
31
|
|
|
* |
32
|
|
|
* - The notification instance; |
33
|
|
|
* - The notification definition object; |
34
|
|
|
* - The notification processor; |
35
|
|
|
* - The event instance. |
36
|
|
|
*/ |
37
|
|
|
class Payload |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* @var Notification |
41
|
|
|
*/ |
42
|
|
|
protected $notification; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var NotificationDefinition |
46
|
|
|
*/ |
47
|
|
|
protected $notificationDefinition; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var Event |
51
|
|
|
*/ |
52
|
|
|
protected $event; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var NotificationProcessor |
56
|
|
|
*/ |
57
|
|
|
protected $notificationProcessor; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param Notification $notification |
61
|
|
|
* @param NotificationDefinition $notificationDefinition |
62
|
|
|
* @param Event $event |
63
|
|
|
*/ |
64
|
|
|
public function __construct(Notification $notification, NotificationDefinition $notificationDefinition, Event $event) |
65
|
|
|
{ |
66
|
|
|
$this->notification = $notification; |
67
|
|
|
$this->notificationDefinition = $notificationDefinition; |
68
|
|
|
$this->event = $event; |
69
|
|
|
$this->notificationProcessor = NotificationProcessorFactory::get()->getFromNotification($this->notification); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return Notification |
74
|
|
|
*/ |
75
|
|
|
public function getNotification(): Notification |
76
|
|
|
{ |
77
|
|
|
return $this->notification; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return NotificationDefinition |
82
|
|
|
*/ |
83
|
|
|
public function getNotificationDefinition(): NotificationDefinition |
84
|
|
|
{ |
85
|
|
|
return $this->notificationDefinition; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return Event |
90
|
|
|
*/ |
91
|
|
|
public function getEvent(): Event |
92
|
|
|
{ |
93
|
|
|
return $this->event; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return NotificationProcessor |
98
|
|
|
*/ |
99
|
|
|
public function getNotificationProcessor(): NotificationProcessor |
100
|
|
|
{ |
101
|
|
|
return $this->notificationProcessor; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|