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;
  }
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;
  }
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 ; }
Replace placeholders with tokens.

@param array $output
The templated text to be replaced.
@param bool $clear
Determine if unused token should be cleared.
@param \Drupal\message\Entity\Message $message
Message object.

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