You are here

class SmsEntityPhoneNumber in SMS Framework 8

Same name and namespace in other branches
  1. 2.x src/Event/SmsEntityPhoneNumber.php \Drupal\sms\Event\SmsEntityPhoneNumber
  2. 2.1.x src/Event/SmsEntityPhoneNumber.php \Drupal\sms\Event\SmsEntityPhoneNumber

Event fired when resolving phone numbers for an entity.

Hierarchy

Expanded class hierarchy of SmsEntityPhoneNumber

See also

\Drupal\sms\Event\SmsEvents

2 files declare their use of SmsEntityPhoneNumber
PhoneNumberProvider.php in src/Provider/PhoneNumberProvider.php
SmsEntityPhoneNumberProcessor.php in src/EventSubscriber/SmsEntityPhoneNumberProcessor.php

File

src/Event/SmsEntityPhoneNumber.php, line 13

Namespace

Drupal\sms\Event
View source
class SmsEntityPhoneNumber extends Event {

  /**
   * The entity to find phone numbers.
   *
   * @var \Drupal\Core\Entity\EntityInterface
   */
  protected $entity;

  /**
   * Whether the returned phone numbers must be verified.
   *
   * Use NULL to get all phone numbers regardless of status.
   *
   * @var bool|null
   */
  protected $verified;

  /**
   * An array of phone numbers.
   *
   * @var string[]
   */
  protected $phoneNumbers = [];

  /**
   * Constructs the object.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity to find phone numbers.
   * @param bool|null $verified
   *   Whether the returned phone numbers must be verified, or NULL to get all
   *   phone numbers regardless of status.
   */
  public function __construct(EntityInterface $entity, $verified = TRUE) {
    $this->entity = $entity;
    $this->verified = $verified;
  }

  /**
   * Get entity to find phone numbers.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The entity to find phone numbers.
   */
  public function getEntity() {
    return $this->entity;
  }

  /**
   * Get phone numbers with this verification state.
   *
   * @return bool|null
   *   Whether the returned phone numbers must be verified, or NULL to get all
   *   phone numbers regardless of status.
   */
  public function getRequiresVerification() {
    return $this->verified;
  }

  /**
   * Get phone number on this event.
   *
   * @return string[]
   *   The phone number on this event.
   */
  public function getPhoneNumbers() {
    return $this->phoneNumbers;
  }

  /**
   * Add phone number to this event.
   *
   * @param string $phone_number
   *   A phone number to add to this event.
   *
   * @return $this
   *   Return this event for chaining.
   */
  public function addPhoneNumber($phone_number) {
    if (!in_array($phone_number, $this->phoneNumbers)) {
      $this->phoneNumbers[] = $phone_number;
    }
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SmsEntityPhoneNumber::$entity protected property The entity to find phone numbers.
SmsEntityPhoneNumber::$phoneNumbers protected property An array of phone numbers.
SmsEntityPhoneNumber::$verified protected property Whether the returned phone numbers must be verified.
SmsEntityPhoneNumber::addPhoneNumber public function Add phone number to this event.
SmsEntityPhoneNumber::getEntity public function Get entity to find phone numbers.
SmsEntityPhoneNumber::getPhoneNumbers public function Get phone number on this event.
SmsEntityPhoneNumber::getRequiresVerification public function Get phone numbers with this verification state.
SmsEntityPhoneNumber::__construct public function Constructs the object.