1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the smsmode-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\SMSModeBundle\EventListener; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\EventDispatcher\Event; |
15
|
|
|
use WBW\Bundle\SMSModeBundle\Event\AddingContactEvent; |
16
|
|
|
use WBW\Bundle\SMSModeBundle\Event\CheckingSMSMessageStatusEvent; |
17
|
|
|
use WBW\Bundle\SMSModeBundle\Event\CreatingSubAccountEvent; |
18
|
|
|
use WBW\Bundle\SMSModeBundle\Event\DeletingSMSEvent; |
19
|
|
|
use WBW\Bundle\SMSModeBundle\Event\DeletingSubAccountEvent; |
20
|
|
|
use WBW\Bundle\SMSModeBundle\Event\DeliveryReportEvent; |
21
|
|
|
use WBW\Bundle\SMSModeBundle\Event\RetrievingSMSReplyEvent; |
22
|
|
|
use WBW\Bundle\SMSModeBundle\Event\SendingSMSBatchEvent; |
23
|
|
|
use WBW\Bundle\SMSModeBundle\Event\SendingSMSMessageEvent; |
24
|
|
|
use WBW\Bundle\SMSModeBundle\Event\SendingTextToSpeechSMSEvent; |
25
|
|
|
use WBW\Bundle\SMSModeBundle\Event\SendingUnicodeSMSEvent; |
26
|
|
|
use WBW\Bundle\SMSModeBundle\Event\SentSMSMessageListEvent; |
27
|
|
|
use WBW\Bundle\SMSModeBundle\Event\TransferringCreditsEvent; |
28
|
|
|
use WBW\Library\SMSMode\Provider\APIProvider; |
29
|
|
|
use WBW\Library\SMSMode\Traits\AccessTokenTrait; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* sMsmode event listener. |
33
|
|
|
* |
34
|
|
|
* @author webeweb <https://github.com/webeweb/> |
35
|
|
|
* @package WBW\Bundle\SMSModeBundle\EventListener |
36
|
|
|
*/ |
37
|
|
|
class SMSModeEventListener { |
38
|
|
|
|
39
|
|
|
use AccessTokenTrait; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Service name. |
43
|
|
|
* |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
const SERVICE_NAME = "webeweb.smsmode.event_listener"; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* API provider. |
50
|
|
|
* |
51
|
|
|
* @var APIProvider |
52
|
|
|
*/ |
53
|
|
|
private $apiProvider; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Pseudo. |
57
|
|
|
* |
58
|
|
|
* @var string |
59
|
|
|
*/ |
60
|
|
|
private $pass; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Pass. |
64
|
|
|
* |
65
|
|
|
* @var string. |
66
|
|
|
*/ |
67
|
|
|
private $pseudo; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Constructor. |
71
|
|
|
*/ |
72
|
|
|
public function __construct() { |
73
|
|
|
// NOTHING TO DO. |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get the API provider. |
78
|
|
|
* |
79
|
|
|
* @return APIProvider Returns the API provider. |
80
|
|
|
*/ |
81
|
|
|
public function getApiProvider() { |
82
|
|
|
return $this->apiProvider; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Get the pass. |
87
|
|
|
* |
88
|
|
|
* @return string Returns the pass. |
89
|
|
|
*/ |
90
|
|
|
public function getPass() { |
91
|
|
|
return $this->pass; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Get the pseudo. |
96
|
|
|
* |
97
|
|
|
* @return string Returns the pseudo. |
98
|
|
|
*/ |
99
|
|
|
public function getPseudo() { |
100
|
|
|
return $this->pseudo; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* On adding contact. |
105
|
|
|
* |
106
|
|
|
* @param AddingContactEvent $event The adding contact event. |
107
|
|
|
* @return Event Returns the event. |
108
|
|
|
*/ |
109
|
|
|
public function onAddingContact(AddingContactEvent $event) { |
110
|
|
|
|
111
|
|
|
return $event; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* On checking SMS message status. |
116
|
|
|
* |
117
|
|
|
* @param CheckingSMSMessageStatusEvent $event The checking SMS message status event. |
118
|
|
|
* @return Event Returns the event. |
119
|
|
|
*/ |
120
|
|
|
public function onCheckingSMSMessageStatus(CheckingSMSMessageStatusEvent $event) { |
121
|
|
|
|
122
|
|
|
return $event; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* On creating sub-account. |
127
|
|
|
* |
128
|
|
|
* @param CreatingSubAccountEvent $event The creating sub-account event. |
129
|
|
|
* @return Event Returns the event. |
130
|
|
|
*/ |
131
|
|
|
public function onCreatingSubAccount(CreatingSubAccountEvent $event) { |
132
|
|
|
|
133
|
|
|
return $event; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* On deleting SMS. |
138
|
|
|
* |
139
|
|
|
* @param DeletingSMSEvent $event The deleting SMS event. |
140
|
|
|
* @return Event Returns the event. |
141
|
|
|
*/ |
142
|
|
|
public function onDeletingSMS(DeletingSMSEvent $event) { |
143
|
|
|
|
144
|
|
|
return $event; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* On deleting sub-account. |
149
|
|
|
* |
150
|
|
|
* @param DeletingSubAccountEvent $event The deleting sub-account event. |
151
|
|
|
* @return Event Returns the event. |
152
|
|
|
*/ |
153
|
|
|
public function onDeletingSubAccount(DeletingSubAccountEvent $event) { |
154
|
|
|
|
155
|
|
|
return $event; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* On delivery report. |
160
|
|
|
* |
161
|
|
|
* @param DeliveryReportEvent $event The delivery report event. |
162
|
|
|
* @return Event Returns the event. |
163
|
|
|
*/ |
164
|
|
|
public function onDeliveryReport(DeliveryReportEvent $event) { |
165
|
|
|
|
166
|
|
|
return $event; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* On retrieving SMS reply. |
171
|
|
|
* |
172
|
|
|
* @param RetrievingSMSReplyEvent $event The retrieving SMS reply event. |
173
|
|
|
* @return Event Returns the event. |
174
|
|
|
*/ |
175
|
|
|
public function onRetrievingSMSReply(RetrievingSMSReplyEvent $event) { |
176
|
|
|
|
177
|
|
|
return $event; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* On sending SMS batch. |
182
|
|
|
* |
183
|
|
|
* @param SendingSMSBatchEvent $event The sending SMS batch event. |
184
|
|
|
* @return Event Returns the event. |
185
|
|
|
*/ |
186
|
|
|
public function onSendingSMSBatch(SendingSMSBatchEvent $event) { |
187
|
|
|
|
188
|
|
|
return $event; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* On sending SMS message. |
193
|
|
|
* |
194
|
|
|
* @param SendingSMSMessageEvent $event The sending SMS message event. |
195
|
|
|
* @return Event Returns the event. |
196
|
|
|
*/ |
197
|
|
|
public function onSendingSMSMessage(SendingSMSMessageEvent $event) { |
198
|
|
|
|
199
|
|
|
return $event; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* On sending text-to-speech. |
204
|
|
|
* |
205
|
|
|
* @param SendingTextToSpeechSMSEvent $event The sending text-to-speech event. |
206
|
|
|
* @return Event Returns the event. |
207
|
|
|
*/ |
208
|
|
|
public function onSendingTextToSpeechSMS(SendingTextToSpeechSMSEvent $event) { |
209
|
|
|
|
210
|
|
|
return $event; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* On sending unicode SMS. |
215
|
|
|
* |
216
|
|
|
* @param SendingUnicodeSMSEvent $event The sending unicode SMS event. |
217
|
|
|
* @return Event Returns the event. |
218
|
|
|
*/ |
219
|
|
|
public function onSendingUnicodeSMS(SendingUnicodeSMSEvent $event) { |
220
|
|
|
|
221
|
|
|
return $event; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* On sent SMS message lis. |
226
|
|
|
* |
227
|
|
|
* @param SentSMSMessageListEvent $event The sent SMS message list event. |
228
|
|
|
* @return Event Returns the event. |
229
|
|
|
*/ |
230
|
|
|
public function onSentSMSMessageList(SentSMSMessageListEvent $event) { |
231
|
|
|
|
232
|
|
|
return $event; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* On transferring credits. |
237
|
|
|
* |
238
|
|
|
* @param TransferringCreditsEvent $event The transferring credits event. |
239
|
|
|
* @return Event Returns the event. |
240
|
|
|
*/ |
241
|
|
|
public function onTransferringCredits(TransferringCreditsEvent $event) { |
242
|
|
|
|
243
|
|
|
return $event; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Set the API provider. |
248
|
|
|
* |
249
|
|
|
* @param APIProvider $apiProvider The API provider. |
250
|
|
|
* @return SMSModeEventListener Returns this event listener. |
251
|
|
|
*/ |
252
|
|
|
protected function setApiProvider($apiProvider) { |
253
|
|
|
$this->apiProvider = $apiProvider; |
254
|
|
|
return $this; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* Set the pass. |
259
|
|
|
* |
260
|
|
|
* @param string $pass The pass. |
261
|
|
|
* @return SMSModeEventListener Returns this event listener. |
262
|
|
|
*/ |
263
|
|
|
public function setPass($pass) { |
264
|
|
|
$this->pass = $pass; |
265
|
|
|
return $this; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* Set the pseudo. |
270
|
|
|
* |
271
|
|
|
* @param string $pseudo The pseudo. |
272
|
|
|
* @return SMSModeEventListener Returns this event listener. |
273
|
|
|
*/ |
274
|
|
|
public function setPseudo($pseudo) { |
275
|
|
|
$this->pseudo = $pseudo; |
276
|
|
|
return $this; |
277
|
|
|
} |
278
|
|
|
} |
279
|
|
|
|