You are here

class SmsMessage in SMS Framework 8

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

Defines the SMS message entity.

The SMS message entity is used to maintain the message while it is queued to send to the gateway. After the message has been sent, the message may persist in the database as an archive record.

Plugin annotation


@ContentEntityType(
  id = "sms",
  label = @Translation("SMS Message"),
  label_collection = @Translation("SMS Messages"),
  label_singular = @Translation("SMS message"),
  label_plural = @Translation("SMS messages"),
  label_count = @PluralTranslation(
    singular = "@count SMS message",
    plural = "@count SMS messages",
  ),
  base_table = "sms",
  entity_keys = {
    "id" = "id",
    "uuid" = "uuid",
  },
  handlers = {
    "views_data" = "Drupal\sms\Views\SmsMessageViewsData",
  },
)

Hierarchy

Expanded class hierarchy of SmsMessage

20 files declare their use of SmsMessage
AccountRegistration.php in modules/sms_user/src/AccountRegistration.php
DefaultSmsProvider.php in src/Provider/DefaultSmsProvider.php
PhoneNumberProvider.php in src/Provider/PhoneNumberProvider.php
SendToPhoneForm.php in modules/sms_sendtophone/src/Form/SendToPhoneForm.php
SmsDevelMessageForm.php in modules/sms_devel/src/Form/SmsDevelMessageForm.php

... See full list

File

src/Entity/SmsMessage.php, line 43

Namespace

Drupal\sms\Entity
View source
class SmsMessage extends ContentEntityBase implements SmsMessageInterface {

  /**
   * Temporarily stores the message result until save().
   *
   * @var \Drupal\sms\Message\SmsMessageResultInterface|null
   */
  protected $result = NULL;

  /**
   * Following are implementors of plain SmsMessage interface.
   *
   * @see \Drupal\sms\Entity\SmsMessageInterface
   */

  /**
   * {@inheritdoc}
   */
  public function getRecipients() {
    $recipients = [];
    foreach ($this
      ->get('recipient_phone_number') as $recipient) {
      $recipients[] = $recipient->value;
    }
    return $recipients;
  }

  /**
   * {@inheritdoc}
   */
  public function addRecipient($recipient) {

    // Ensure duplicate recipients cannot be added.
    foreach ($this->recipient_phone_number as $item) {
      if ($item->value == $recipient) {
        return $this;
      }
    }
    $this->recipient_phone_number
      ->appendItem($recipient);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function addRecipients(array $recipients) {
    foreach ($recipients as $recipient) {
      $this
        ->addRecipient($recipient);
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function removeRecipient($recipient) {
    $this->recipient_phone_number
      ->filter(function ($item) use ($recipient) {
      return $item->value != $recipient;
    });
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function removeRecipients(array $recipients) {
    $this->recipient_phone_number
      ->filter(function ($item) use ($recipients) {
      return !in_array($item->value, $recipients);
    });
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getOptions() {
    return ($first = $this
      ->get('options')
      ->first()) ? $first
      ->getValue() : [];
  }

  /**
   * {@inheritdoc}
   */
  public function getOption($name) {
    $options = $this
      ->getOptions();
    return isset($options[$name]) ? $options[$name] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function setOption($name, $value) {
    $options = $this
      ->getOptions();
    $options[$name] = $value;
    $this
      ->set('options', $options);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function removeOption($name) {
    $options = $this
      ->getOptions();
    unset($options[$name]);
    $this
      ->set('options', $options);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

  /**
   * Sets the result associated with this SMS message.
   *
   * Results on a saved SMS message are immutable and cannot be changed. An
   * exception will be thrown if this method is called on an SmsMessage that
   * already has saved results.
   *
   * @param \Drupal\sms\Message\SmsMessageResultInterface|null $result
   *   The result to associate with this SMS message, or NULL if there is no
   *   result.
   *
   * @return $this
   *   The called SMS message object.
   *
   * @throws \Drupal\sms\Exception\SmsStorageException
   *   If the SMS message entity already has saved results.
   */
  public function setResult(StdMessageResultInterface $result = NULL) {

    // Throw an exception if there is already a result for this SMS message.
    $previous_result = $this
      ->getResult();
    if ($previous_result) {
      throw new SmsStorageException('Saved SMS message results cannot be changed or updated.');
    }
    elseif ($result) {

      // Temporarily store the result so it can be retrieved without having to
      // save the message entity.
      $this->result = $result;
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

  /**
   * {@inheritdoc}
   */
  public function getReports() {

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

  /**
   * {@inheritdoc}
   */
  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;
    }
  }

  /**
   * {@inheritdoc}
   *
   * @param string|null $sender
   *   The name of the sender. Or NULL to defer to the label of the sender
   *   entity.
   *
   * @see ::getSender()
   */
  public function setSender($sender) {
    $this
      ->set('sender_name', $sender);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getMessage() {
    return $this
      ->get('message')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setMessage($message) {
    $this
      ->set('message', $message);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getUuid() {
    return $this
      ->get('uuid')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getUid() {
    $sender = $this
      ->getSenderEntity();
    return $sender instanceof UserInterface ? $sender
      ->id() : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function setUid($uid) {
    $this
      ->setSenderEntity(User::load($uid));
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function isAutomated() {
    return $this
      ->get('automated')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setAutomated($automated) {
    $this
      ->set('automated', $automated);
    return $this;
  }

  /**
   * Following are implementors of entity interface.
   *
   * @see \Drupal\sms\Entity\SmsMessageInterface
   */

  /**
   * {@inheritdoc}
   */
  public function getDirection() {
    return $this
      ->get('direction')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setDirection($direction) {
    $this
      ->set('direction', $direction);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getGateway() {
    return $this
      ->get('gateway')->entity;
  }

  /**
   * {@inheritdoc}
   */
  public function setGateway(SmsGatewayInterface $gateway) {
    $this
      ->set('gateway', $gateway);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getSenderNumber() {
    return $this
      ->get('sender_phone_number')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setSenderNumber($number) {
    $this
      ->set('sender_phone_number', $number);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getSenderEntity() {
    return $this
      ->get('sender_entity')->entity;
  }

  /**
   * {@inheritdoc}
   */
  public function setSenderEntity(EntityInterface $entity) {
    $this
      ->set('sender_entity', $entity);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getRecipientEntity() {
    return $this
      ->get('recipient_entity')->entity;
  }

  /**
   * {@inheritdoc}
   */
  public function setRecipientEntity(EntityInterface $entity) {
    $this
      ->set('recipient_entity', $entity);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function isQueued() {
    return (bool) $this
      ->get('queued')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setQueued($is_queued) {
    $this
      ->set('queued', $is_queued);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getCreatedTime() {
    return $this
      ->get('created')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getSendTime() {
    return $this
      ->get('send_on')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setSendTime($send_time) {
    $this
      ->set('send_on', $send_time);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getProcessedTime() {
    return $this
      ->get('processed')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setProcessedTime($processed) {
    $this
      ->set('processed', $processed);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function chunkByRecipients($size) {
    $recipients_all = $this
      ->getRecipients();

    // Save processing by returning early.
    if ($size < 1 || count($recipients_all) <= $size) {
      return [
        $this,
      ];
    }

    // Create a baseline SMS message with recipients cleaned out.
    $base = $this
      ->createDuplicate();
    $base
      ->removeRecipients($recipients_all);
    $messages = [];
    foreach (array_chunk($recipients_all, $size) as $recipients) {
      $messages[] = $base
        ->createDuplicate()
        ->addRecipients($recipients);
    }
    return $messages;
  }

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {

    // Identifiers.
    $fields['id'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('SMS message ID'))
      ->setDescription(t('The SMS message ID.'))
      ->setReadOnly(TRUE)
      ->setSetting('unsigned', TRUE);
    $fields['uuid'] = BaseFieldDefinition::create('uuid')
      ->setLabel(t('UUID'))
      ->setDescription(t('The SMS message UUID.'))
      ->setReadOnly(TRUE);
    $fields['gateway'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Gateway Plugin'))
      ->setDescription(t('The gateway plugin instance.'))
      ->setSetting('target_type', 'sms_gateway')
      ->setReadOnly(TRUE)
      ->setRequired(TRUE);
    $fields['direction'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Transmission direction'))
      ->setDescription(t('Transmission direction, See SmsMessageInterface::DIRECTION_*.'))
      ->setReadOnly(TRUE)
      ->setSetting('unsigned', FALSE)
      ->setSetting('size', 'tiny')
      ->setRequired(TRUE);

    // Sender and receivers.
    $fields['sender_name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Sender name'))
      ->setDescription(t('The name of the sender.'))
      ->setRequired(FALSE);
    $fields['sender_phone_number'] = BaseFieldDefinition::create('telephone')
      ->setLabel(t('Sender phone number'))
      ->setDescription(t('The phone number of the sender.'))
      ->setDefaultValue('')
      ->setRequired(FALSE);
    $fields['sender_entity'] = BaseFieldDefinition::create('dynamic_entity_reference')
      ->setLabel(t('Sender entity'))
      ->setDescription(t('The entity who sent the SMS message.'))
      ->setRequired(FALSE);
    $fields['recipient_phone_number'] = BaseFieldDefinition::create('telephone')
      ->setLabel(t('Recipient phone number'))
      ->setDescription(t('The phone number of the recipient.'))
      ->setRequired(FALSE)
      ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED);
    $fields['recipient_entity'] = BaseFieldDefinition::create('dynamic_entity_reference')
      ->setLabel(t('Recipient entity'))
      ->setDescription(t('The entity who received the SMS message.'))
      ->setRequired(FALSE);

    // Meta information.
    $fields['options'] = BaseFieldDefinition::create('map')
      ->setLabel(t('Options'))
      ->setDescription(t('Options to pass to the gateway.'));
    $fields['automated'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Is automated'))
      ->setDescription(t('Whether this SMS message was generated automatically. 0=generated by user action, 1=generated automatically.'))
      ->setDefaultValue(TRUE)
      ->setRequired(TRUE)
      ->setSetting('on_label', t('Automated'))
      ->setSetting('off_label', t('Not automated'));
    $fields['queued'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Queued'))
      ->setDescription(t('Whether the SMS message is in the queue to be processed.'))
      ->setDefaultValue(FALSE)
      ->setRequired(TRUE)
      ->setSetting('on_label', t('Queued'))
      ->setSetting('off_label', t('Not queued'));

    // Dates.
    $fields['created'] = BaseFieldDefinition::create('created')
      ->setLabel(t('Creation date'))
      ->setDescription(t('The time the SMS message was created.'))
      ->setRequired(TRUE);
    $fields['send_on'] = BaseFieldDefinition::create('created')
      ->setLabel(t('Send date'))
      ->setDescription(t('The time to send the SMS message.'))
      ->setRequired(TRUE);
    $fields['processed'] = BaseFieldDefinition::create('timestamp')
      ->setLabel(t('Processed'))
      ->setDescription(t('The time the SMS message was processed. This value does not indicate whether the message was sent, only that the gateway accepted the request.'))
      ->setRequired(FALSE);

    // Message contents.
    $fields['message'] = BaseFieldDefinition::create('string_long')
      ->setLabel(t('Message'))
      ->setDescription(t('The SMS message.'))
      ->setDefaultValue('')
      ->setRequired(TRUE);
    return $fields;
  }

  /**
   * Converts a standard SMS message object to a SMS message entity.
   *
   * @param \Drupal\sms\Message\SmsMessageInterface $sms_message
   *   A standard SMS message.
   *
   * @return static
   *   An unsaved SMS Message entity.
   */
  public static function convertFromSmsMessage(StdSmsMessageInterface $sms_message) {
    if ($sms_message instanceof static) {
      return $sms_message;
    }
    $new = static::create();
    $new
      ->setDirection($sms_message
      ->getDirection())
      ->setAutomated($sms_message
      ->isAutomated())
      ->setSender($sms_message
      ->getSender())
      ->setSenderNumber($sms_message
      ->getSenderNumber())
      ->addRecipients($sms_message
      ->getRecipients())
      ->setMessage($sms_message
      ->getMessage())
      ->setResult($sms_message
      ->getResult());
    if ($gateway = $sms_message
      ->getGateway()) {
      $new
        ->setGateway($gateway);
    }
    if ($uid = $sms_message
      ->getUid()) {
      $new
        ->setUid($uid);
    }
    foreach ($sms_message
      ->getOptions() as $k => $v) {
      $new
        ->setOption($k, $v);
    }
    return $new;
  }

  /**
   * {@inheritdoc}
   */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage, $entities);
    $results = [];
    $reports = [];

    /** @var \Drupal\sms\Entity\SmsMessageInterface $sms_message */
    foreach ($entities as $sms_message) {

      // Since the $sms_message can have both in-memory and stored objects, only
      // need to delete actual stored entities.
      if (($result = $sms_message
        ->getResult()) && $result instanceof EntityInterface) {
        $results[] = $result;
      }
      foreach ($sms_message
        ->getReports() as $report) {
        if ($report instanceof EntityInterface) {
          $reports[] = $report;
        }
      }
    }
    \Drupal::entityTypeManager()
      ->getStorage('sms_result')
      ->delete($results);
    \Drupal::entityTypeManager()
      ->getStorage('sms_report')
      ->delete($reports);
  }

  /**
   * {@inheritdoc}
   */
  public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    parent::postSave($storage, $update);

    // Save the result and reports in the static cache.
    if ($this->result) {
      $result_entity = SmsMessageResult::convertFromMessageResult($this->result);
      $result_entity
        ->setSmsMessage($this)
        ->save();
      foreach ($this->result
        ->getReports() as $report) {
        $report_entity = SmsDeliveryReport::convertFromDeliveryReport($report);
        $report_entity
          ->setSmsMessage($this)
          ->save();
      }

      // Unset $this->result as we don't need it anymore after save.
      unset($this->result);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ContentEntityBase::$activeLangcode protected property Language code identifying the entity active language.
ContentEntityBase::$defaultLangcode protected property Local cache for the default language code.
ContentEntityBase::$defaultLangcodeKey protected property The default langcode entity key.
ContentEntityBase::$enforceRevisionTranslationAffected protected property Whether the revision translation affected flag has been enforced.
ContentEntityBase::$entityKeys protected property Holds untranslatable entity keys such as the ID, bundle, and revision ID.
ContentEntityBase::$fieldDefinitions protected property Local cache for field definitions.
ContentEntityBase::$fields protected property The array of fields, each being an instance of FieldItemListInterface.
ContentEntityBase::$fieldsToSkipFromTranslationChangesCheck protected static property Local cache for fields to skip from the checking for translation changes.
ContentEntityBase::$isDefaultRevision protected property Indicates whether this is the default revision.
ContentEntityBase::$langcodeKey protected property The language entity key.
ContentEntityBase::$languages protected property Local cache for the available language objects.
ContentEntityBase::$loadedRevisionId protected property The loaded revision ID before the new revision was set.
ContentEntityBase::$newRevision protected property Boolean indicating whether a new revision should be created on save.
ContentEntityBase::$revisionTranslationAffectedKey protected property The revision translation affected entity key.
ContentEntityBase::$translatableEntityKeys protected property Holds translatable entity keys such as the label.
ContentEntityBase::$translationInitialize protected property A flag indicating whether a translation object is being initialized.
ContentEntityBase::$translations protected property An array of entity translation metadata.
ContentEntityBase::$validated protected property Whether entity validation was performed.
ContentEntityBase::$validationRequired protected property Whether entity validation is required before saving the entity.
ContentEntityBase::$values protected property The plain data values of the contained fields.
ContentEntityBase::access public function Checks data value access. Overrides EntityBase::access 1
ContentEntityBase::addTranslation public function Adds a new translation to the translatable object. Overrides TranslatableInterface::addTranslation
ContentEntityBase::bundle public function Gets the bundle of the entity. Overrides EntityBase::bundle
ContentEntityBase::bundleFieldDefinitions public static function Provides field definitions for a specific bundle. Overrides FieldableEntityInterface::bundleFieldDefinitions 4
ContentEntityBase::clearTranslationCache protected function Clear entity translation object cache to remove stale references.
ContentEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::createDuplicate 1
ContentEntityBase::get public function Gets a field item list. Overrides FieldableEntityInterface::get
ContentEntityBase::getEntityKey protected function Gets the value of the given entity key, if defined. 1
ContentEntityBase::getFieldDefinition public function Gets the definition of a contained field. Overrides FieldableEntityInterface::getFieldDefinition
ContentEntityBase::getFieldDefinitions public function Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface::getFieldDefinitions
ContentEntityBase::getFields public function Gets an array of all field item lists. Overrides FieldableEntityInterface::getFields
ContentEntityBase::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip in ::hasTranslationChanges. 1
ContentEntityBase::getIterator public function
ContentEntityBase::getLanguages protected function
ContentEntityBase::getLoadedRevisionId public function Gets the loaded Revision ID of the entity. Overrides RevisionableInterface::getLoadedRevisionId
ContentEntityBase::getRevisionId public function Gets the revision identifier of the entity. Overrides RevisionableInterface::getRevisionId
ContentEntityBase::getTranslatableFields public function Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface::getTranslatableFields
ContentEntityBase::getTranslatedField protected function Gets a translated field.
ContentEntityBase::getTranslation public function Gets a translation of the data. Overrides TranslatableInterface::getTranslation
ContentEntityBase::getTranslationLanguages public function Returns the languages the data is translated to. Overrides TranslatableInterface::getTranslationLanguages
ContentEntityBase::getTranslationStatus public function Returns the translation status. Overrides TranslationStatusInterface::getTranslationStatus
ContentEntityBase::getUntranslated public function Returns the translatable object referring to the original language. Overrides TranslatableInterface::getUntranslated
ContentEntityBase::hasField public function Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface::hasField
ContentEntityBase::hasTranslation public function Checks there is a translation for the given language code. Overrides TranslatableInterface::hasTranslation
ContentEntityBase::hasTranslationChanges public function Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface::hasTranslationChanges
ContentEntityBase::id public function Gets the identifier. Overrides EntityBase::id
ContentEntityBase::initializeTranslation protected function Instantiates a translation object for an existing translation.
ContentEntityBase::isDefaultRevision public function Checks if this entity is the default revision. Overrides RevisionableInterface::isDefaultRevision
ContentEntityBase::isDefaultTranslation public function Checks whether the translation is the default one. Overrides TranslatableInterface::isDefaultTranslation
ContentEntityBase::isDefaultTranslationAffectedOnly public function Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface::isDefaultTranslationAffectedOnly
ContentEntityBase::isLatestRevision public function Checks if this entity is the latest revision. Overrides RevisionableInterface::isLatestRevision
ContentEntityBase::isLatestTranslationAffectedRevision public function Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface::isLatestTranslationAffectedRevision
ContentEntityBase::isNewRevision public function Determines whether a new revision should be created on save. Overrides RevisionableInterface::isNewRevision
ContentEntityBase::isNewTranslation public function Checks whether the translation is new. Overrides TranslatableInterface::isNewTranslation
ContentEntityBase::isRevisionTranslationAffected public function Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffected
ContentEntityBase::isRevisionTranslationAffectedEnforced public function Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffectedEnforced
ContentEntityBase::isTranslatable public function Returns the translation support status. Overrides TranslatableInterface::isTranslatable
ContentEntityBase::isValidationRequired public function Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::isValidationRequired
ContentEntityBase::label public function Gets the label of the entity. Overrides EntityBase::label 2
ContentEntityBase::language public function Gets the language of the entity. Overrides EntityBase::language
ContentEntityBase::onChange public function Reacts to changes to a field. Overrides FieldableEntityInterface::onChange
ContentEntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityBase::postCreate
ContentEntityBase::preSave public function Acts on an entity before the presave hook is invoked. Overrides EntityBase::preSave 5
ContentEntityBase::preSaveRevision public function Acts on a revision before it gets saved. Overrides RevisionableInterface::preSaveRevision 2
ContentEntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityBase::referencedEntities 1
ContentEntityBase::removeTranslation public function Removes the translation identified by the given language code. Overrides TranslatableInterface::removeTranslation
ContentEntityBase::set public function Sets a field value. Overrides FieldableEntityInterface::set
ContentEntityBase::setDefaultLangcode protected function Populates the local cache for the default language code.
ContentEntityBase::setNewRevision public function Enforces an entity to be saved as a new revision. Overrides RevisionableInterface::setNewRevision
ContentEntityBase::setRevisionTranslationAffected public function Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffected
ContentEntityBase::setRevisionTranslationAffectedEnforced public function Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffectedEnforced
ContentEntityBase::setValidationRequired public function Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::setValidationRequired
ContentEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray
ContentEntityBase::updateFieldLangcodes protected function Updates language for already instantiated fields.
ContentEntityBase::updateLoadedRevisionId public function Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface::updateLoadedRevisionId
ContentEntityBase::updateOriginalValues public function Updates the original values with the interim changes.
ContentEntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase::uuid
ContentEntityBase::validate public function Validates the currently set values. Overrides FieldableEntityInterface::validate
ContentEntityBase::wasDefaultRevision public function Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface::wasDefaultRevision
ContentEntityBase::__clone public function Magic method: Implements a deep clone.
ContentEntityBase::__construct public function Constructs an Entity object. Overrides EntityBase::__construct
ContentEntityBase::__get public function Implements the magic method for getting object properties.
ContentEntityBase::__isset public function Implements the magic method for isset().
ContentEntityBase::__set public function Implements the magic method for setting object properties.
ContentEntityBase::__sleep public function Overrides EntityBase::__sleep
ContentEntityBase::__unset public function Implements the magic method for unset().
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function 2
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityManager Deprecated protected function Gets the entity manager.
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface::getCacheTagsToInvalidate 2
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityInterface::getConfigDependencyName 1
EntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityInterface::getConfigTarget 1
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getOriginalId public function Gets the original ID. Overrides EntityInterface::getOriginalId 1
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::invalidateTagsOnDelete protected static function Invalidates an entity's cache tags upon delete. 1
EntityBase::invalidateTagsOnSave protected function Invalidates an entity's cache tags upon save. 1
EntityBase::isNew public function Determines whether the entity is new. Overrides EntityInterface::isNew 2
EntityBase::languageManager protected function Gets the language manager.
EntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface::link 1
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 5
EntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface::preDelete 4
EntityBase::save public function Saves an entity permanently. Overrides EntityInterface::save 3
EntityBase::setOriginalId public function Sets the original ID. Overrides EntityInterface::setOriginalId 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityInterface::toUrl 2
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::url public function Gets the public URL for this entity. Overrides EntityInterface::url 2
EntityBase::urlInfo public function Gets the URL object for the entity. Overrides EntityInterface::urlInfo 1
EntityBase::urlRouteParameters protected function Gets an array of placeholders for this entity. 2
EntityBase::uuidGenerator protected function Gets the UUID generator.
EntityChangesDetectionTrait::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
SmsMessage::$result protected property Temporarily stores the message result until save().
SmsMessage::addRecipient public function Adds a single recipient to the SMS message. Overrides SmsMessageInterface::addRecipient
SmsMessage::addRecipients public function Adds multiple recipients to the SMS message. Overrides SmsMessageInterface::addRecipients
SmsMessage::baseFieldDefinitions public static function Provides base field definitions for an entity type. Overrides ContentEntityBase::baseFieldDefinitions
SmsMessage::chunkByRecipients public function Split this SMS message into new messages by chunks of recipients. Overrides SmsMessageInterface::chunkByRecipients
SmsMessage::convertFromSmsMessage public static function Converts a standard SMS message object to a SMS message entity.
SmsMessage::getCreatedTime public function Get the creation timestamp of the SMS message. Overrides SmsMessageInterface::getCreatedTime
SmsMessage::getDirection public function Get direction of the message. Overrides SmsMessageInterface::getDirection
SmsMessage::getGateway public function Get the gateway for this message. Overrides SmsMessageInterface::getGateway
SmsMessage::getMessage public function Gets the message to be sent. Overrides SmsMessageInterface::getMessage
SmsMessage::getOption public function Gets the option specified by the key $name. Overrides SmsMessageInterface::getOption
SmsMessage::getOptions public function Gets the options for building or sending this SMS message. Overrides SmsMessageInterface::getOptions
SmsMessage::getProcessedTime public function The time the SMS message was processed. Overrides SmsMessageInterface::getProcessedTime
SmsMessage::getRecipientEntity public function Gets the entity who will receive the SMS message. Overrides SmsMessageInterface::getRecipientEntity
SmsMessage::getRecipients public function Gets the list of recipients of this SMS message. Overrides SmsMessageInterface::getRecipients
SmsMessage::getReport public function Gets the delivery report for a particular recipient. Overrides SmsMessageInterface::getReport
SmsMessage::getReports public function Gets the delivery reports for all recipients. Overrides SmsMessageInterface::getReports
SmsMessage::getResult public function Get the result associated with this SMS message. Overrides SmsMessageInterface::getResult
SmsMessage::getSender public function Gets the name of the sender of this SMS message. Overrides SmsMessageInterface::getSender
SmsMessage::getSenderEntity public function Gets the entity who sent the SMS message. Overrides SmsMessageInterface::getSenderEntity
SmsMessage::getSenderNumber public function Get phone number of the sender. Overrides SmsMessageInterface::getSenderNumber
SmsMessage::getSendTime public function Get the time to send the SMS message. Overrides SmsMessageInterface::getSendTime
SmsMessage::getUid public function Gets the user who created the SMS message. Overrides SmsMessageInterface::getUid
SmsMessage::getUuid public function Gets the UUID of the SMS object. Overrides SmsMessageInterface::getUuid
SmsMessage::isAutomated public function Gets whether this SMS message was generated automatically. Overrides SmsMessageInterface::isAutomated
SmsMessage::isQueued public function Get whether the SMS message is in the queue to be processed. Overrides SmsMessageInterface::isQueued
SmsMessage::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityBase::postDelete
SmsMessage::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides ContentEntityBase::postSave
SmsMessage::removeOption public function Removes an option from this SMS message. Overrides SmsMessageInterface::removeOption
SmsMessage::removeRecipient public function Removes a single recipient from the SMS message. Overrides SmsMessageInterface::removeRecipient
SmsMessage::removeRecipients public function Removes multiple recipients from the SMS message. Overrides SmsMessageInterface::removeRecipients
SmsMessage::setAutomated public function Sets whether this SMS message was generated automatically. Overrides SmsMessageInterface::setAutomated
SmsMessage::setDirection public function Set direction of the message. Overrides SmsMessageInterface::setDirection
SmsMessage::setGateway public function Set the gateway for this message. Overrides SmsMessageInterface::setGateway
SmsMessage::setMessage public function Set the message to be sent. Overrides SmsMessageInterface::setMessage
SmsMessage::setOption public function Sets an option for this SMS message. Overrides SmsMessageInterface::setOption
SmsMessage::setProcessedTime public function Set the time the SMS message was processed. Overrides SmsMessageInterface::setProcessedTime
SmsMessage::setQueued public function Get whether the SMS message is in the queue to be processed. Overrides SmsMessageInterface::setQueued
SmsMessage::setRecipientEntity public function Set the entity who will receive the SMS message. Overrides SmsMessageInterface::setRecipientEntity
SmsMessage::setResult public function Sets the result associated with this SMS message. Overrides SmsMessageInterface::setResult
SmsMessage::setSender public function Overrides SmsMessageInterface::setSender
SmsMessage::setSenderEntity public function Set the entity who sent the SMS message. Overrides SmsMessageInterface::setSenderEntity
SmsMessage::setSenderNumber public function Set the phone number of the sender. Overrides SmsMessageInterface::setSenderNumber
SmsMessage::setSendTime public function Set the time to send the SMS message. Overrides SmsMessageInterface::setSendTime
SmsMessage::setUid public function Set the user who created the SMS message. Overrides SmsMessageInterface::setUid
SynchronizableEntityTrait::$isSyncing protected property Whether this entity is being created, updated or deleted through a synchronization process.
SynchronizableEntityTrait::isSyncing public function
SynchronizableEntityTrait::setSyncing public function
TranslationStatusInterface::TRANSLATION_CREATED constant Status code identifying a newly created translation.
TranslationStatusInterface::TRANSLATION_EXISTING constant Status code identifying an existing translation.
TranslationStatusInterface::TRANSLATION_REMOVED constant Status code identifying a removed translation.