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\Controller; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
15
|
|
|
use Symfony\Component\HttpFoundation\Request; |
16
|
|
|
use Symfony\Component\HttpFoundation\Response; |
17
|
|
|
use Throwable; |
18
|
|
|
use WBW\Bundle\SmsModeBundle\Event\DeliveryReportCallbackEvent; |
19
|
|
|
use WBW\Bundle\SmsModeBundle\Event\SmsReplyCallbackEvent; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Default controller. |
23
|
|
|
* |
24
|
|
|
* @author webeweb <https://github.com/webeweb> |
25
|
|
|
* @package WBW\Bundle\SmsModeBundle\Controller |
26
|
|
|
*/ |
27
|
|
|
class DefaultController extends AbstractController { |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Service name. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
const SERVICE_NAME = "wbw.smsmode.controller.default"; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Delivery report callback. |
38
|
|
|
* |
39
|
|
|
* @param Request $request The request. |
40
|
|
|
* @return Response Returns the response. |
41
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
42
|
|
|
*/ |
43
|
|
|
public function deliveryReportCallbackAction(Request $request): Response { |
44
|
|
|
|
45
|
|
|
$deliveryReportCallback = $this->newDeliveryReportCallback($request); |
46
|
|
|
|
47
|
|
|
$event = new DeliveryReportCallbackEvent($deliveryReportCallback); |
48
|
|
|
$this->dispatchEvent($event->getEventName(), $event); |
49
|
|
|
|
50
|
|
|
return new JsonResponse(["code" => 200, "message" => "OK"]); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* SMS reply callback. |
55
|
|
|
* |
56
|
|
|
* @param Request $request The request. |
57
|
|
|
* @return Response Returns the response. |
58
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
59
|
|
|
*/ |
60
|
|
|
public function smsReplyCallbackAction(Request $request): Response { |
61
|
|
|
|
62
|
|
|
$smsReplyCallback = $this->newSmsReplyCallback($request); |
63
|
|
|
|
64
|
|
|
$event = new SmsReplyCallbackEvent($smsReplyCallback); |
65
|
|
|
$this->dispatchEvent($event->getEventName(), $event); |
66
|
|
|
|
67
|
|
|
return new JsonResponse(["code" => 200, "message" => "OK"]); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|