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
|
|
|
* Create a new Users Notification |
54
|
|
|
* @return void |
55
|
|
|
*/ |
56
|
|
|
public static function users(string $content, string $systemModule): void |
57
|
|
|
{ |
58
|
|
|
/** |
59
|
|
|
* Create a new Apps Push Notification |
60
|
|
|
*/ |
61
|
|
|
$notification = new UsersPushNotifications(Di::getDefault()->getUserData(),$content,$systemModule); |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Send to notifications queue |
65
|
|
|
*/ |
66
|
|
|
Di::getDefault()->getManager()->trigger($notification); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Create a new System Notification |
71
|
|
|
* @return void |
72
|
|
|
*/ |
73
|
|
|
public static function system(string $content, string $systemModule): void |
74
|
|
|
{ |
75
|
|
|
/** |
76
|
|
|
* Create a new Apps Push Notification |
77
|
|
|
*/ |
78
|
|
|
$notification = new SystemPushNotifications(Di::getDefault()->getUserData(),$content,$systemModule); |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Send to notifications queue |
82
|
|
|
*/ |
83
|
|
|
Di::getDefault()->getManager()->trigger($notification); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|