You are here

public static function LearningPathAccess::replaceGroupUserTokens in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/LearningPathAccess.php \Drupal\opigno_learning_path\LearningPathAccess::replaceGroupUserTokens()

Replaces tokens.

1 call to LearningPathAccess::replaceGroupUserTokens()
LearningPathAccess::notifyUsersByMail in src/LearningPathAccess.php
Prepares and sends emails to users.

File

src/LearningPathAccess.php, line 456

Class

LearningPathAccess
Class LearningPathAccess.

Namespace

Drupal\opigno_learning_path

Code

public static function replaceGroupUserTokens(&$text, $params, $token) {
  if ($token) {
    $text = \Drupal::token()
      ->replace($text);
  }
  $text = str_replace([
    '[user]',
    '[group]',
    '[link]',
    '[user-role]',
    '[user-status]',
  ], [
    $params['account']
      ->getAccountName(),
    $params['group']
      ->label(),
    $params['link'],
    $params['roles'],
    $params['status'],
  ], $text);
}