You are here

protected function LoginValidatorBase::prepareEmailTemplateToken in Lightweight Directory Access Protocol (LDAP) 8.4

Prepare the email template token.

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

File

ldap_authentication/src/Controller/LoginValidatorBase.php, line 716

Class

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

Namespace

Drupal\ldap_authentication\Controller

Code

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