You are here

public static function SmsGateway::preCreate in SMS Framework 2.1.x

Same name and namespace in other branches
  1. 8 src/Entity/SmsGateway.php \Drupal\sms\Entity\SmsGateway::preCreate()
  2. 2.x src/Entity/SmsGateway.php \Drupal\sms\Entity\SmsGateway::preCreate()

Changes the values of an entity before it is created.

Load defaults for example.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

mixed[] $values: An array of values to set, keyed by property name. If the entity type has bundles the bundle key has to be specified.

Overrides EntityBase::preCreate

File

src/Entity/SmsGateway.php, line 141

Class

SmsGateway
Defines storage for an SMS Gateway instance.

Namespace

Drupal\sms\Entity

Code

public static function preCreate(EntityStorageInterface $storage, array &$values) {
  parent::preCreate($storage, $values);
  if (!isset($values['incoming_push_path'])) {
    $key = Crypt::randomBytesBase64(16);
    $values['incoming_push_path'] = '/sms/incoming/receive/' . $key;
  }
  if (!isset($values['reports_push_path'])) {
    $key = Crypt::randomBytesBase64(16);
    $values['reports_push_path'] = '/sms/delivery-report/receive/' . $key;
  }
}