1 | <?php |
||
9 | class Notifier extends Observable |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @var \Monitor\Notification\Parser |
||
14 | */ |
||
15 | private $notificationParser; |
||
16 | /** |
||
17 | * @var integer |
||
18 | */ |
||
19 | private $notificationDelayInHours; |
||
20 | /** |
||
21 | * @var \Monitor\Service\NotificationLog |
||
22 | */ |
||
23 | private $notificationLogService; |
||
24 | /** |
||
25 | * Notification repository |
||
26 | * @var \Doctrine\ORM\EntityRepository |
||
27 | */ |
||
28 | private $repository; |
||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $notificationData; |
||
33 | |||
34 | public function __construct( |
||
46 | |||
47 | /** |
||
48 | * Add notification data, we will use them in notification services |
||
49 | * |
||
50 | * @param array $data |
||
51 | */ |
||
52 | public function setNotificationData(array $data) |
||
56 | /** |
||
57 | * Get Notification by id |
||
58 | * |
||
59 | * @param int $id |
||
60 | * @return \Monitor\Model\Notification $notification |
||
61 | */ |
||
62 | private function getNotificationById($id) |
||
67 | |||
68 | /** |
||
69 | * Parse notification message |
||
70 | * |
||
71 | * @param \Monitor\Model\Notification $notification |
||
72 | * @param array $data |
||
73 | */ |
||
74 | private function parseNotification(Notification $notification, $data) |
||
78 | |||
79 | /** |
||
80 | * Prepare notification |
||
81 | * |
||
82 | * @access private |
||
83 | * @param Trigger $trigger |
||
84 | * @param array $serverData |
||
85 | * @return \Monitor\Notification\Notification |
||
86 | */ |
||
87 | private function prepareNotification(Trigger $trigger, array $serverData) |
||
96 | |||
97 | /** |
||
98 | * Check if same type of notification for concret server has been sent already |
||
99 | * |
||
100 | * @access private |
||
101 | * @param int $triggerId |
||
102 | * @param int $serverId |
||
103 | * @return boolean |
||
104 | */ |
||
105 | public function hasNotificationDelayExpired($triggerId, $serverId, $msDelay) |
||
118 | /** |
||
119 | * |
||
120 | * |
||
121 | * @param Trigger $trigger |
||
122 | * @param array $serverData |
||
123 | * @return \Monitor\Notification\Notification |
||
124 | */ |
||
125 | public function triggerHasBeenFired(Trigger $trigger, array $serverData) |
||
131 | |||
132 | /** |
||
133 | * Send notification to notification service |
||
134 | * |
||
135 | * @access public |
||
136 | * @param Notification $notification |
||
137 | * @return |
||
138 | */ |
||
139 | public function notifyServices(Notification $notification) |
||
145 | } |
||
146 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: