You are here

public function SmsMessage::getSender in SMS Framework 8

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

Gets the name of the sender of this SMS message.

Return value

string|null The name of the sender, or NULL if none is defined.

Overrides SmsMessageInterface::getSender

File

src/Entity/SmsMessage.php, line 233

Class

SmsMessage
Defines the SMS message entity.

Namespace

Drupal\sms\Entity

Code

public function getSender() {
  $sender_name = $this
    ->get('sender_name');
  if (isset($sender_name->value)) {
    return $sender_name->value;
  }
  else {
    return ($sender_entity = $this
      ->getSenderEntity()) ? $sender_entity
      ->label() : NULL;
  }
}