You are here

function push_notifications_set_random_certificate_string in Push Notifications 8

Generate and set the random file ending for APNS certificates.

2 calls to push_notifications_set_random_certificate_string()
PushNotificationsConfigForm::submitRegenerateCertificateString in src/Form/PushNotificationsConfigForm.php
Regenerates the APNS random certificate string.
push_notifications_install in ./push_notifications.install

File

./push_notifications.module, line 71
Contains push_notifications.module functionality.

Code

function push_notifications_set_random_certificate_string() {

  // Generate a random 10-digit string.
  $random_string = substr(md5(microtime()), 0, 10);

  // Write random string to variables.
  $config = \Drupal::service('config.factory')
    ->getEditable('push_notifications.apns');
  $config
    ->set('certificate_random', $random_string);
  $config
    ->save();
}