Commit 4b96c8b6 authored by Robert Ragas's avatar Robert Ragas Committed by Robert Ragas
Browse files

Merge pull request #2860 from...

Merge pull request #2860 from goalgorilla/issue-3273700-the-social-user-recipient-token-is-not-transforming-correctly

Issue #3273700 by nkoporec: The [social_user:recipient] token is not transforming correctly
parent 2c8b7afa
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@
 */

use Drupal\Core\Render\BubbleableMetadata;
use Drupal\message\Entity\Message;

/**
 * Implements hook_token_info().
@@ -36,16 +35,10 @@ function social_user_token_info() {
function social_user_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $replacements = [];

  if ($type == 'social_user' && !empty($data['message'])) {
    /** @var \Drupal\message\Entity\Message $message */
    $message = $data['message'];

    if ($message instanceof Message) {
  if ($type == 'social_user') {
    foreach ($tokens as $name => $original) {
      switch ($name) {

        case 'recipient':

          if (isset($data['display_name'])) {
            $replacements[$original] = $data['display_name'];
          }
@@ -53,7 +46,6 @@ function social_user_tokens($type, $tokens, array $data, array $options, Bubblea
      }
    }
  }
  }

  return $replacements;
}