SmsEventSubscriber.php in SMS Framework 2.x
File
modules/sms_user/src/EventSubscriber/SmsEventSubscriber.php
View source
<?php
declare (strict_types=1);
namespace Drupal\sms_user\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\sms\Event\SmsEvents;
use Drupal\sms\Event\SmsMessageEvent;
use Drupal\sms_user\AccountRegistrationInterface;
class SmsEventSubscriber implements EventSubscriberInterface {
protected $accountRegistration;
public function __construct(AccountRegistrationInterface $account_registration) {
$this->accountRegistration = $account_registration;
}
public function createAccount(SmsMessageEvent $event) {
foreach ($event
->getMessages() as $sms_message) {
$this->accountRegistration
->createAccount($sms_message);
}
}
public static function getSubscribedEvents() {
$events[SmsEvents::MESSAGE_INCOMING_POST_PROCESS][] = [
'createAccount',
];
return $events;
}
}