<?php
namespace App\EventSubscriber;
use App\Event\SmsContactEvent;
use App\Service\SmsService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class SmsContactSubscriber implements EventSubscriberInterface
{
/**
* @var SmsService
*/
protected $smsService;
public function __construct(SmsService $smsService)
{
$this->smsService = $smsService;
}
/**
* @return array
*/
public static function getSubscribedEvents():array
{
return [
SmsContactEvent::SEND_SMS_EVENT => [
['onSendSms', 1]
]
];
}
/**
* @param SmsContactEvent $event
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
*/
public function onSendSms(SmsContactEvent $event)
{
$sms = $event->getSms();
$this->smsService->sendSms($sms->getPayItemDescr(), $sms->getPhoneNumber(), $sms->getCallbackUrl(),$sms->getUser(), $sms->getServiceid(),1, $sms->getStatus(), $sms->getCustomerId() );
}
}