public function FieldPluginBase::getRenderTokens

Get the 'render' tokens to use for advanced rendering.

This runs through all of the fields and arguments that are available and gets their values. This will then be used in one giant str_replace().

3 calls to FieldPluginBase::getRenderTokens()
ContextualLinks::render in drupal/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php
Render the contextual fields.
FieldPluginBase::renderText in drupal/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php
Perform an advanced text render for the item.
Links::getLinks in drupal/core/modules/views/lib/Drupal/views/Plugin/views/field/Links.php
Gets the list of links used by this field.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php, line 1461
Definition of Drupal\views\Plugin\views\field\FieldPluginBase.

Class

FieldPluginBase
Base field handler that has no options and renders an unformatted field.

Namespace

Drupal\views\Plugin\views\field

Code

public function getRenderTokens($item) {
  $tokens = array();
  if (!empty($this->view->build_info['substitutions'])) {
    $tokens = $this->view->build_info['substitutions'];
  }
  $count = 0;
  foreach ($this->view->display_handler
    ->getHandlers('argument') as $arg => $handler) {
    $token = '%' . ++$count;
    if (!isset($tokens[$token])) {
      $tokens[$token] = '';
    }

    // Use strip tags as there should never be HTML in the path.
    // However, we need to preserve special characters like " that
    // were removed by check_plain().
    $tokens['!' . $count] = isset($this->view->args[$count - 1]) ? strip_tags(decode_entities($this->view->args[$count - 1])) : '';
  }

  // Get flattened set of tokens for any array depth in $_GET parameters.
  $tokens += $this
    ->getTokenValuesRecursive(drupal_container()
    ->get('request')->query
    ->all());

  // Now add replacements for our fields.
  foreach ($this->view->display_handler
    ->getHandlers('field') as $field => $handler) {
    if (isset($handler->last_render)) {
      $tokens["[{$field}]"] = $handler->last_render;
    }
    else {
      $tokens["[{$field}]"] = '';
    }

    // We only use fields up to (and including) this one.
    if ($field == $this->options['id']) {
      break;
    }
  }

  // Store the tokens for the row so we can reference them later if necessary.
  $this->view->style_plugin->render_tokens[$this->view->row_index] = $tokens;
  $this->last_tokens = $tokens;
  if (!empty($item)) {
    $this
      ->addSelfTokens($tokens, $item);
  }
  return $tokens;
}