You are here

public function SmsDeliveryReport::getRevisionAtStatus in SMS Framework 8

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

Gets a revision with the specified delivery report status.

Parameters

string $status: Delivery report status from \Drupal\sms\Message\SmsMessageReportStatus.

Return value

\Drupal\sms\Entity\SmsDeliveryReportInterface|null The delivery report object with that status or null if there is none.

2 calls to SmsDeliveryReport::getRevisionAtStatus()
SmsDeliveryReport::getTimeDelivered in src/Entity/SmsDeliveryReport.php
Gets the time the message was delivered to the recipient.
SmsDeliveryReport::getTimeQueued in src/Entity/SmsDeliveryReport.php
Gets the time the message was queued.

File

src/Entity/SmsDeliveryReport.php, line 235

Class

SmsDeliveryReport
Defines the SMS message delivery report entity.

Namespace

Drupal\sms\Entity

Code

public function getRevisionAtStatus($status) {
  $storage = $this
    ->entityTypeManager()
    ->getStorage($this->entityTypeId);
  $revision_ids = $storage
    ->getQuery()
    ->allRevisions()
    ->condition($this
    ->getEntityType()
    ->getKey('id'), $this
    ->id())
    ->condition('status', $status)
    ->sort($this
    ->getEntityType()
    ->getKey('revision'), 'DESC')
    ->range(0, 1)
    ->execute();
  if ($revision_ids) {
    return $storage
      ->loadRevision(key($revision_ids));
  }
  return NULL;
}