Unnecessary checks for contrib token module before using Drupal::tokenReplace()

Created on 12 May 2022, almost 3 years ago
Updated 21 June 2023, over 1 year ago

Problem/Motivation

opigno_learning_path\LearningPathAccess has code like the following:

      $token = \Drupal::moduleHandler()->moduleExists('token') ? TRUE : FALSE;
      LearningPathAccess::notifyUsersByMail($group, $uid, $status, $token);

...


 public static function replaceGroupUserTokens(&$text, $params, $token) {
    if ($token) {
      $text = \Drupal::token()->replace($text);

However, Drupal::token() is always available with Drupal core. Token module in contrib only provides additional tokens and the browser UI.

Steps to reproduce

Proposed resolution

Always call Drupal::token()->replace() and remove the moduleExists() checks

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024