|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Gewaer\Notifications\PushNotifications; |
|
4
|
|
|
|
|
5
|
|
|
use Namshi\Notificator\Notification; |
|
6
|
|
|
use Gewaer\Contracts\PushNotificationsContract; |
|
7
|
|
|
use Gewaer\Models\Users; |
|
8
|
|
|
use Gewaer\Notifications\PushNotifications\AppsPushNotifications; |
|
9
|
|
|
use Gewaer\Notifications\PushNotifications\UsersPushNotifications; |
|
10
|
|
|
use Gewaer\Notifications\PushNotifications\SystemPushNotifications; |
|
11
|
|
|
use Phalcon\Di; |
|
12
|
|
|
|
|
13
|
|
|
class PushNotifications extends Notification implements PushNotificationsContract |
|
14
|
|
|
{ |
|
15
|
|
|
|
|
16
|
|
|
public $user; |
|
17
|
|
|
|
|
18
|
|
|
public $content; |
|
19
|
|
|
|
|
20
|
|
|
public $systemModule; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct(string $content) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->content = $content; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Assemble Notification |
|
29
|
|
|
*/ |
|
30
|
|
|
public function assemble() |
|
31
|
|
|
{ |
|
32
|
|
|
return $this->content; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Create a new Apps Notification |
|
37
|
|
|
* @return void |
|
38
|
|
|
*/ |
|
39
|
|
|
public static function apps(string $content, string $systemModule): void |
|
40
|
|
|
{ |
|
41
|
|
|
/** |
|
42
|
|
|
* Create a new Apps Push Notification |
|
43
|
|
|
*/ |
|
44
|
|
|
$notification = new AppsPushNotifications(Di::getDefault()->getUserData(),$content,$systemModule); |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Send to notifications queue |
|
48
|
|
|
*/ |
|
49
|
|
|
Di::getDefault()->getManager()->trigger($notification); |
|
50
|
|
|
|
|
51
|
|
|
} |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Create a new Users Notification |
|
55
|
|
|
* @return void |
|
56
|
|
|
*/ |
|
57
|
|
|
public static function users(string $content, string $systemModule): void |
|
58
|
|
|
{ |
|
59
|
|
|
/** |
|
60
|
|
|
* Create a new Apps Push Notification |
|
61
|
|
|
*/ |
|
62
|
|
|
$notification = new UsersPushNotifications(Di::getDefault()->getUserData(),$content,$systemModule); |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Send to notifications queue |
|
66
|
|
|
*/ |
|
67
|
|
|
Di::getDefault()->getManager()->trigger($notification); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Create a new System Notification |
|
72
|
|
|
* @return void |
|
73
|
|
|
*/ |
|
74
|
|
|
public static function system(string $content, string $systemModule): void |
|
75
|
|
|
{ |
|
76
|
|
|
/** |
|
77
|
|
|
* Create a new Apps Push Notification |
|
78
|
|
|
*/ |
|
79
|
|
|
$notification = new SystemPushNotifications(Di::getDefault()->getUserData(),$content,$systemModule); |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Send to notifications queue |
|
83
|
|
|
*/ |
|
84
|
|
|
Di::getDefault()->getManager()->trigger($notification); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|