You are here

private function LoginValidator::prepareEmailTemplateToken in Lightweight Directory Access Protocol (LDAP) 8.3

Prepare the email template token.

1 call to LoginValidator::prepareEmailTemplateToken()
LoginValidator::deriveDrupalUserName in ldap_authentication/src/Controller/LoginValidator.php
Derives the Drupal user name from server configuration.

File

ldap_authentication/src/Controller/LoginValidator.php, line 842

Class

LoginValidator
Handles the actual testing of credentials and authentication of users.

Namespace

Drupal\ldap_authentication\Controller

Code

private function prepareEmailTemplateToken() {
  $this->emailTemplateTokens = [
    '@username' => $this->drupalUserName,
  ];
  if (!empty($this->config
    ->get('emailTemplate'))) {
    $handling = $this->config
      ->get('emailTemplateHandling');
    if ($handling == 'if_empty' && empty($this->ldapUser['mail']) || $handling == 'always') {
      $this
        ->replaceUserMailWithTemplate();
      $this->detailLog
        ->log('Using template generated email for %username', [
        '%username' => $this->drupalUserName,
      ], 'ldap_authentication');
      $this->emailTemplateUsed = TRUE;
    }
  }
}