You are here

protected function ActivityFactory::processTokens in Open Social 8.3

Same name and namespace in other branches
  1. 8.9 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  2. 8 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  3. 8.2 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  4. 8.4 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  5. 8.5 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  6. 8.6 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  7. 8.7 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  8. 8.8 modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  9. 10.3.x modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  10. 10.0.x modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  11. 10.1.x modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()
  12. 10.2.x modules/custom/activity_creator/src/ActivityFactory.php \Drupal\activity_creator\ActivityFactory::processTokens()

Replace placeholders with tokens.

Parameters

array $output: The templated text to be replaced.

bool $clear: Determine if unused token should be cleared.

\Drupal\message\Entity\Message $message: Message object.

Return value

array The output with placeholders replaced with the token value, if there are indeed tokens.

1 call to ActivityFactory::processTokens()
ActivityFactory::getMessageText in modules/custom/activity_creator/src/ActivityFactory.php
Get message text.

File

modules/custom/activity_creator/src/ActivityFactory.php, line 477

Class

ActivityFactory
Class ActivityFactory to create Activity items based on ActivityLogs.

Namespace

Drupal\activity_creator

Code

protected function processTokens(array $output, $clear, Message $message) {
  $options = [
    'clear' => $clear,
  ];
  foreach ($output as $key => $value) {
    if (is_string($value)) {
      $output[$key] = \Drupal::token()
        ->replace($value, [
        'message' => $message,
      ], $options);
    }
    else {
      if (isset($value['value'])) {
        $output[$key] = \Drupal::token()
          ->replace($value['value'], [
          'message' => $message,
        ], $options);
      }
    }
  }
  return $output;
}