You are here

public function ActiveHours::delaySmsMessage in SMS Framework 8

Same name and namespace in other branches
  1. 2.x modules/sms_user/src/ActiveHours.php \Drupal\sms_user\ActiveHours::delaySmsMessage()
  2. 2.1.x modules/sms_user/src/ActiveHours.php \Drupal\sms_user\ActiveHours::delaySmsMessage()

Delay a SMS message if active hours require it to be delayed.

Parameters

\Drupal\sms\Entity\SmsMessageInterface $sms_message: An SMS message entity.

Overrides ActiveHoursInterface::delaySmsMessage

File

modules/sms_user/src/ActiveHours.php, line 91

Class

ActiveHours
Defines the user active hours service.

Namespace

Drupal\sms_user

Code

public function delaySmsMessage(SmsMessageInterface &$sms_message) {
  $recipient = $sms_message
    ->getRecipientEntity();
  if ($sms_message
    ->isAutomated() && $recipient instanceof UserInterface) {
    if (!$this
      ->inHours($recipient) && ($range = $this
      ->findNextTime($recipient))) {
      $sms_message
        ->setSendTime($range
        ->getStartDate()
        ->format('U'));
    }
  }
}