function StylePluginBase::tokenizeValue

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/style/StylePluginBase.php \Drupal\views\Plugin\views\style\StylePluginBase::tokenizeValue()
  2. 10 core/modules/views/src/Plugin/views/style/StylePluginBase.php \Drupal\views\Plugin\views\style\StylePluginBase::tokenizeValue()
  3. 8.9.x core/modules/views/src/Plugin/views/style/StylePluginBase.php \Drupal\views\Plugin\views\style\StylePluginBase::tokenizeValue()

Take a value and apply token replacement logic to it.

File

core/modules/views/src/Plugin/views/style/StylePluginBase.php, line 230

Class

StylePluginBase
Base class for views style plugins.

Namespace

Drupal\views\Plugin\views\style

Code

public function tokenizeValue($value, $row_index) {
  if (strpos($value, '{{') !== FALSE) {
    // Row tokens might be empty, for example for node row style.
    $tokens = $this->rowTokens[$row_index] ?? [];
    if (!empty($this->view->build_info['substitutions'])) {
      $tokens += $this->view->build_info['substitutions'];
    }
    $value = $this->viewsTokenReplace($value, $tokens);
  }
  else {
    // ::viewsTokenReplace() will run Xss::filterAdmin on the
    // resulting string. We do the same here for consistency.
    $value = Xss::filterAdmin($value);
  }
  return $value;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.