1 | <?php |
||
17 | class Manager |
||
18 | { |
||
19 | /** |
||
20 | * Registered notifications. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $notifications = []; |
||
25 | |||
26 | /** |
||
27 | * Push notifications. |
||
28 | * |
||
29 | * @return \Jgut\Tify\Result[] |
||
30 | */ |
||
31 | public function push() |
||
32 | { |
||
33 | $results = []; |
||
34 | |||
35 | foreach ($this->notifications as $notification) { |
||
36 | $notification->setPending(); |
||
37 | |||
38 | $notification->getService()->send($notification); |
||
39 | |||
40 | $results = array_merge($results, $notification->getResults()); |
||
41 | } |
||
42 | |||
43 | return $results; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Get feedback from service. |
||
48 | * |
||
49 | * @param \Jgut\Tify\Service\AbstractService $service |
||
50 | * |
||
51 | * @throws \Jgut\Tify\Exception\ServiceException |
||
52 | * |
||
53 | * @return array |
||
54 | */ |
||
55 | public function feedback(AbstractService $service) |
||
56 | { |
||
57 | if (!$service instanceof FeedbackInterface) { |
||
58 | throw new ServiceException(sprintf('%s is not a feedback enabled service', get_class($service))); |
||
59 | } |
||
60 | |||
61 | return $service->feedback(); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Retrieve registered notifications. |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | public function getNotifications() |
||
73 | |||
74 | /** |
||
75 | * Register notification. |
||
76 | * |
||
77 | * @param \Jgut\Tify\Notification\AbstractNotification $notification |
||
78 | */ |
||
79 | public function addNotification(AbstractNotification $notification) |
||
85 | |||
86 | /** |
||
87 | * Clear list of notifications. |
||
88 | */ |
||
89 | public function clearNotifications() |
||
95 | } |
||
96 |