You are here

class SmsEventSubscriber in SMS Framework 2.x

Same name and namespace in other branches
  1. 8 modules/sms_user/src/EventSubscriber/SmsEventSubscriber.php \Drupal\sms_user\EventSubscriber\SmsEventSubscriber
  2. 2.1.x modules/sms_user/src/EventSubscriber/SmsEventSubscriber.php \Drupal\sms_user\EventSubscriber\SmsEventSubscriber

Event subscriber responding to SMS Framework events.

Hierarchy

  • class \Drupal\sms_user\EventSubscriber\SmsEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of SmsEventSubscriber

1 string reference to 'SmsEventSubscriber'
sms_user.services.yml in modules/sms_user/sms_user.services.yml
modules/sms_user/sms_user.services.yml
1 service uses SmsEventSubscriber
sms_user.sms_events in modules/sms_user/sms_user.services.yml
Drupal\sms_user\EventSubscriber\SmsEventSubscriber

File

modules/sms_user/src/EventSubscriber/SmsEventSubscriber.php, line 15

Namespace

Drupal\sms_user\EventSubscriber
View source
class SmsEventSubscriber implements EventSubscriberInterface {

  /**
   * The account registration service.
   *
   * @var \Drupal\sms_user\AccountRegistrationInterface
   */
  protected $accountRegistration;

  /**
   * Constructs a new SmsEvents instance.
   *
   * @param \Drupal\sms_user\AccountRegistrationInterface $account_registration
   *   The account registration service.
   */
  public function __construct(AccountRegistrationInterface $account_registration) {
    $this->accountRegistration = $account_registration;
  }

  /**
   * Process an incoming SMS to see if a new account should be created.
   *
   * @param \Drupal\sms\Event\SmsMessageEvent $event
   *   The event.
   */
  public function createAccount(SmsMessageEvent $event) {
    foreach ($event
      ->getMessages() as $sms_message) {
      $this->accountRegistration
        ->createAccount($sms_message);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[SmsEvents::MESSAGE_INCOMING_POST_PROCESS][] = [
      'createAccount',
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SmsEventSubscriber::$accountRegistration protected property The account registration service.
SmsEventSubscriber::createAccount public function Process an incoming SMS to see if a new account should be created.
SmsEventSubscriber::getSubscribedEvents public static function
SmsEventSubscriber::__construct public function Constructs a new SmsEvents instance.