HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/fabricas.colombiatrade.com.co/public_html/modules/contrib/token/src/TokenFieldRender.php
<?php

namespace Drupal\token;

use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\Core\Render\Element;

class TokenFieldRender implements TrustedCallbackInterface {

  /**
   * {@inheritdoc}
   */
  public static function trustedCallbacks() {
    return ['preRender'];
  }

  /**
   * Pre-render callback for field output used with tokens.
   */
  public static function preRender($elements) {
    // Remove the field theme hook, attachments, and JavaScript states.
    unset($elements['#theme']);
    unset($elements['#states']);
    unset($elements['#attached']);

    // Prevent multi-value fields from appearing smooshed together by appending
    // a join suffix to all but the last value.
    $deltas = Element::getVisibleChildren($elements);
    $count = count($deltas);
    if ($count > 1) {
      $join = isset($elements['#token_options']['join']) ? $elements['#token_options']['join'] : ", ";
      foreach ($deltas as $index => $delta) {
        // Do not add a suffix to the last item.
        if ($index < ($count - 1)) {
          $elements[$delta] += ['#suffix' => $join];
        }
      }
    }
    return $elements;
  }

}