1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Gewaer\Handlers; |
4
|
|
|
|
5
|
|
|
use Namshi\Notificator\Notification\Handler\HandlerInterface; |
6
|
|
|
use Gewaer\Contracts\PushNotificationsContract; |
7
|
|
|
use Phalcon\Http\Response; |
8
|
|
|
use Namshi\Notificator\NotificationInterface; |
9
|
|
|
use Phalcon\Di; |
10
|
|
|
use Gewaer\Notifications\PushNotifications\AppsPushNotifications; |
11
|
|
|
use Gewaer\Notifications\PushNotifications\PushNotifications; |
12
|
|
|
use Gewaer\Models\Notifications; |
13
|
|
|
use Gewaer\Traits\NotificationsTrait; |
14
|
|
|
use Gewaer\Models\SystemModules; |
15
|
|
|
|
16
|
|
|
class PushNotificationsHandler implements HandlerInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Notifications Trait |
20
|
|
|
*/ |
21
|
|
|
use NotificationsTrait; |
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Stablishes type of handler |
25
|
|
|
*/ |
26
|
|
|
public function shouldHandle(NotificationInterface $notification) |
27
|
|
|
{ |
28
|
|
|
return $notification instanceof PushNotificationsContract; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Handles actions to take depending of notifications |
33
|
|
|
* @param NotificationInterface $notification |
34
|
|
|
*/ |
35
|
|
|
public function handle(NotificationInterface $notification) |
36
|
|
|
{ |
37
|
|
|
$this->create($notification->user,$notification->content,$notification->notificationTypeId,$notification->systemModule); |
|
|
|
|
38
|
|
|
die(); |
39
|
|
|
$notificationType = $notification->notificationTypeId; |
|
|
|
|
40
|
|
|
|
41
|
|
|
switch ($notificationType) { |
42
|
|
|
case '1': |
43
|
|
|
$newTypeRecord = new AppsPushNotifications($notification->getMessage(), $notification->notificationTypeId); |
44
|
|
|
Di::getDefault()->getLog()->info($newTypeRecord->getMessage()); |
45
|
|
|
break; |
46
|
|
|
// case '2': |
47
|
|
|
// $notificationType = new AppsPushNotifications($notification->getMessage(), $notification->source_id); |
48
|
|
|
// Di::getDefault()->getLog()->info($notificationType->getMessage()); |
49
|
|
|
// break; |
50
|
|
|
|
51
|
|
|
// case '3': |
52
|
|
|
// $notificationType = new AppsPushNotifications($notification->getMessage(), $notification->source_id); |
53
|
|
|
// Di::getDefault()->getLog()->info($notificationType->getMessage()); |
54
|
|
|
// break; |
55
|
|
|
|
56
|
|
|
default: |
57
|
|
|
$newTypeRecord = new PushNotifications($notification->getMessage(), $notification->notificationTypeId); |
58
|
|
|
Di::getDefault()->getLog()->info($newTypeRecord->getMessage()); |
59
|
|
|
break; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|