<?php
/**
* @author Antony Tkachenko <at@canaryknight.ru>
*/
namespace App\Event\Form;
use App\Form\Dto\WalletDemo;
use App\Form\FormHandledEvent;
use App\Notification\SmsRuNotifier;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class SendWalletDemoSubscriber implements EventSubscriberInterface
{
private $notifier;
public function __construct(SmsRuNotifier $notifier)
{
$this->notifier = $notifier;
}
public function sendSmsNotification(FormHandledEvent $event)
{
$dto = $event->getDto();
if (!is_a($dto, WalletDemo::class)) {
return;
}
$message = "Демо-карта готова. Перейдите по ссылке http://wallet.getmeback.ru/wallet/demo";
$this->notifier->send($dto->phone, $message);
}
public static function getSubscribedEvents()
{
return [
FormHandledEvent::NAME => 'sendSmsNotification'
];
}
}