You are here

public static function SmsMessageResult::convertFromMessageResult in SMS Framework 8

Same name and namespace in other branches
  1. 2.x src/Entity/SmsMessageResult.php \Drupal\sms\Entity\SmsMessageResult::convertFromMessageResult()
  2. 2.1.x src/Entity/SmsMessageResult.php \Drupal\sms\Entity\SmsMessageResult::convertFromMessageResult()

Converts a plain SMS message result into an SMS message result entity.

Parameters

\Drupal\sms\Message\SmsMessageResultInterface $sms_result: A plain SMS message result.

Return value

\Drupal\sms\Entity\SmsMessageResultInterface An SMS message result entity that can be saved.

1 call to SmsMessageResult::convertFromMessageResult()
SmsMessage::postSave in src/Entity/SmsMessage.php
Acts on a saved entity before the insert or update hook is invoked.

File

src/Entity/SmsMessageResult.php, line 232

Class

SmsMessageResult
Defines the SMS message result entity.

Namespace

Drupal\sms\Entity

Code

public static function convertFromMessageResult(StdMessageResultInterface $sms_result) {
  if ($sms_result instanceof SmsMessageResultInterface) {
    return $sms_result;
  }
  $new = SmsMessageResult::create();
  $new
    ->setCreditsBalance($sms_result
    ->getCreditsBalance())
    ->setCreditsUsed($sms_result
    ->getCreditsUsed())
    ->setError($sms_result
    ->getError())
    ->setErrorMessage($sms_result
    ->getErrorMessage())
    ->setReports($sms_result
    ->getReports());
  return $new;
}