You are here

public function DefaultSmsProvider::incoming in SMS Framework 8

Same name and namespace in other branches
  1. 2.x src/Provider/DefaultSmsProvider.php \Drupal\sms\Provider\DefaultSmsProvider::incoming()
  2. 2.1.x src/Provider/DefaultSmsProvider.php \Drupal\sms\Provider\DefaultSmsProvider::incoming()

Handles a message sent from the gateway to the site.

Parameters

\Drupal\sms\Message\SmsMessageInterface $sms_message: The incoming message to process.

Return value

\Drupal\sms\Message\SmsMessageInterface[] The messages received in an incoming operation.

Overrides SmsProviderInterface::incoming

1 call to DefaultSmsProvider::incoming()
DefaultSmsProvider::queue in src/Provider/DefaultSmsProvider.php
Queue a SMS message for sending or receiving.

File

src/Provider/DefaultSmsProvider.php, line 121

Class

DefaultSmsProvider
The SMS provider that provides default messaging functionality.

Namespace

Drupal\sms\Provider

Code

public function incoming(SmsMessageInterface $sms_message) {
  $sms_message
    ->setDirection(Direction::INCOMING);

  // Do not iterate over messages individually like outgoing, changing gateway
  // in pre-process events do not apply to incoming.
  $plugin = $sms_message
    ->getGateway()
    ->getPlugin();
  $dispatch = !$sms_message
    ->getOption('_skip_preprocess_event');
  $sms_messages = $dispatch ? $this
    ->dispatchEvent(SmsEvents::MESSAGE_PRE_PROCESS, [
    $sms_message,
  ])
    ->getMessages() : [
    $sms_message,
  ];
  $sms_messages = $this
    ->dispatchEvent(SmsEvents::MESSAGE_INCOMING_PRE_PROCESS, $sms_messages)
    ->getMessages();
  if ($plugin instanceof SmsIncomingEventProcessorInterface) {
    $event = new SmsMessageEvent($sms_messages);
    $plugin
      ->incomingEvent($event);
  }
  $this
    ->dispatchEvent(SmsEvents::MESSAGE_INCOMING_POST_PROCESS, $sms_messages);
  $this
    ->dispatchEvent(SmsEvents::MESSAGE_POST_PROCESS, $sms_messages);
  return $sms_messages;
}