You are here

public function ProfileStatSender::__construct in Brainstorm profile 8

Constructs Drupal\profile_stat_sender\ProfileStatSender object.

File

module/custom/profile_stat_sender/src/ProfileStatSender.php, line 22
This file contains ProfileStatSender service implementation.

Class

ProfileStatSender
Provides ProfileStatSender service implementation.

Namespace

Drupal\profile_stat_sender

Code

public function __construct() {
  $config = \Drupal::configFactory()
    ->getEditable('profile_stat_sender.key');
  $key = $config
    ->get('key');
  if (!$key) {

    // Generate site key from hash because all keys must have same length.
    $key = Crypt::hmacBase64((string) \Drupal::service('request_stack')
      ->getCurrentRequest()->server
      ->get('SERVER_ADDR'), \Drupal::service('private_key')
      ->get());
    $config
      ->set('key', $key)
      ->save();
  }
  $this->siteKey = $key;
}