PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.2.1
Fluent Support – Helpdesk & Customer Support Ticket System v2.2.1
2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 All 67 releases
fluent-support / app / Services / Notifications / NotificationEventMap.php

NotificationEventMap.php in Fluent Support – Helpdesk & Customer Support Ticket System 2.2.1, at app/Services/Notifications/NotificationEventMap.php

115 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Services\Notifications;
4
5 use InvalidArgumentException;
6
7 class NotificationEventMap
8 {
9 const AGENT_MENTIONED = 'agent_mentioned';
10 const AGENT_REPLIED = 'agent_replied';
11 const TICKET_ASSIGNED = 'ticket_assigned';
12 const TICKET_REASSIGNED = 'ticket_reassigned';
13 const CUSTOMER_REPLIED = 'customer_replied';
14 const TICKET_CLOSED = 'ticket_closed';
15 const TICKET_REOPENED = 'ticket_reopened';
16 const WORKFLOW_TRIGGERED = 'workflow_triggered';
17
18 public static function normalizeEventType($eventType)
19 {
20 return static::legacyEventMap()[$eventType] ?? $eventType;
21 }
22
23 public static function all()
24 {
25 return array_keys(static::categoryMap());
26 }
27
28 public static function categoryMap()
29 {
30 return [
31 static::AGENT_MENTIONED => NotificationCategory::MENTIONS,
32 static::AGENT_REPLIED => NotificationCategory::TICKET_ACTIVITY,
33 static::TICKET_ASSIGNED => NotificationCategory::TICKET_ACTIVITY,
34 static::TICKET_REASSIGNED => NotificationCategory::TICKET_ACTIVITY,
35 static::CUSTOMER_REPLIED => NotificationCategory::TICKET_ACTIVITY,
36 static::TICKET_CLOSED => NotificationCategory::TICKET_ACTIVITY,
37 static::TICKET_REOPENED => NotificationCategory::TICKET_ACTIVITY,
38 static::WORKFLOW_TRIGGERED => NotificationCategory::AUTOMATION_TRIGGERS,
39 ];
40 }
41
42 public static function legacyEventMap()
43 {
44 return [
45 'fluent_support/response_added_by_agent' => static::AGENT_REPLIED,
46 'fluent_support/note_added_by_agent' => static::AGENT_MENTIONED,
47 ];
48 }
49
50 public static function displayMap()
51 {
52 return [
53 static::AGENT_MENTIONED => [
54 'label' => __('mentioned you', 'fluent-support'),
55 'icon' => 'reply'
56 ],
57 static::AGENT_REPLIED => [
58 'label' => __('replied to a ticket', 'fluent-support'),
59 'icon' => 'reply'
60 ],
61 static::TICKET_ASSIGNED => [
62 'label' => __('assigned a ticket', 'fluent-support'),
63 'icon' => 'agent'
64 ],
65 static::TICKET_REASSIGNED => [
66 'label' => __('reassigned a ticket', 'fluent-support'),
67 'icon' => 'agent'
68 ],
69 static::CUSTOMER_REPLIED => [
70 'label' => __('replied to a ticket', 'fluent-support'),
71 'icon' => 'reply'
72 ],
73 static::TICKET_CLOSED => [
74 'label' => __('closed a ticket', 'fluent-support'),
75 'icon' => 'closeTicket'
76 ],
77 static::TICKET_REOPENED => [
78 'label' => __('reopened a ticket', 'fluent-support'),
79 'icon' => 'refresh'
80 ],
81 static::WORKFLOW_TRIGGERED => [
82 'label' => __('triggered automation', 'fluent-support'),
83 'icon' => 'workflow'
84 ]
85 ];
86 }
87
88 public static function displayData($eventType)
89 {
90 $eventType = static::normalizeEventType($eventType);
91
92 return static::displayMap()[$eventType] ?? [
93 'label' => __('updated a ticket', 'fluent-support'),
94 'icon' => 'reply'
95 ];
96 }
97
98 public static function resolveCategory($eventType)
99 {
100 $eventType = static::normalizeEventType($eventType);
101 $category = static::categoryMap()[$eventType] ?? null;
102
103 if (!$category) {
104 throw new InvalidArgumentException('Unsupported notification event type: ' . esc_html($eventType));
105 }
106
107 return $category;
108 }
109
110 public static function isValid($eventType)
111 {
112 return array_key_exists($eventType, static::categoryMap());
113 }
114 }
115