You are here

public function SmsMessage::getResult in SMS Framework 8

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

Get the result associated with this SMS message.

Return value

\Drupal\sms\Message\SmsMessageResultInterface|null The result associated with this SMS message, or NULL if there is no result.

Overrides SmsMessageInterface::getResult

1 call to SmsMessage::getResult()
SmsMessage::setResult in src/Entity/SmsMessage.php
Sets the result associated with this SMS message.

File

src/Entity/SmsMessage.php, line 151

Class

SmsMessage
Defines the SMS message entity.

Namespace

Drupal\sms\Entity

Code

public function getResult() {

  // Check the temporary store first as that contains the most recent value.
  // Also, if the entity is new then return that value (can be null).
  if ($this->result || $this
    ->isNew()) {
    return $this->result;
  }
  $results = $this
    ->entityTypeManager()
    ->getStorage('sms_result')
    ->loadByProperties([
    'sms_message' => $this
      ->id(),
  ]);
  return $results ? reset($results) : NULL;
}