You are here

public function SmsMessage::getReport in SMS Framework 8

Same name in this branch
  1. 8 src/Message/SmsMessage.php \Drupal\sms\Message\SmsMessage::getReport()
  2. 8 src/Entity/SmsMessage.php \Drupal\sms\Entity\SmsMessage::getReport()
Same name and namespace in other branches
  1. 2.x src/Entity/SmsMessage.php \Drupal\sms\Entity\SmsMessage::getReport()
  2. 2.1.x src/Entity/SmsMessage.php \Drupal\sms\Entity\SmsMessage::getReport()

Gets the delivery report for a particular recipient.

Parameters

string $recipient: The number of the recipient for which the report is to be retrieved.

Return value

\Drupal\sms\Message\SmsDeliveryReportInterface|null A delivery report object, or NULL if there is no report for the recipient.

Overrides SmsMessageInterface::getReport

See also

SmsMessageInterface::getReports()

File

src/Entity/SmsMessage.php, line 197

Class

SmsMessage
Defines the SMS message entity.

Namespace

Drupal\sms\Entity

Code

public function getReport($recipient) {

  // If a result has been set, check that first.
  if ($this->result) {
    return $this->result
      ->getReport($recipient);
  }
  elseif (!$this
    ->isNew()) {
    $reports = $this
      ->entityTypeManager()
      ->getStorage('sms_report')
      ->loadByProperties([
      'sms_message' => $this
        ->id(),
      'recipient' => $recipient,
    ]);
    return $reports ? reset($reports) : NULL;
  }
  return NULL;
}