You are here

public function View::getTokenValue in Views Field View 8

Gets field values from tokens.

Parameters

string $token: The token string. E.g. explode(',', $this->options['args']);

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

\Drupal\views\ViewExecutable $view: The full view object to get token values from.

Return value

array An array of raw argument values, returned in the same order as the token were passed in.

1 call to View::getTokenValue()
View::render in src/Plugin/views/field/View.php
Renders the field.

File

src/Plugin/views/field/View.php, line 300

Class

View
Plugin annotation @ViewsField("view");

Namespace

Drupal\views_field_view\Plugin\views\field

Code

public function getTokenValue($token, ResultRow $values, ViewExecutable $view) {
  $token_info = $this
    ->getTokenArgument($token);
  $id = $token_info['id'];
  $token_type = $token_info['type'];

  // Collect all of the values that we intend to use as arguments of our
  // single query.
  switch ($token_type) {
    case 'raw_fields':
      $value = $view->field[$id]
        ->getValue($values);
      break;
    case 'fields':
      $value = $view->field[$id]->last_render;
      break;
    case 'raw_arguments':
      $value = $view->args[array_flip(array_keys($view->argument))[$id]];
      break;
    case 'arguments':
      $value = $view->argument[$id]
        ->getTitle();
      break;
    default:
      $value = Html::escape(trim($token, '\'"'));
  }
  return $value;
}