tokenizeValue example


  public function tokenizeValue($value) {
    if ($this->options['tokenize']) {
      $value = $this->view->getStyle()->tokenizeValue($value, 0);
    }
    // As we add the globalTokenForm() we also should replace the token here.     return $this->globalTokenReplace($value);
  }

}
/** * {@inheritdoc} */
  public function render($empty = FALSE) {
    if (!$empty || !empty($this->options['empty'])) {
      // @todo Use a method to check for tokens in       // https://www.drupal.org/node/2396607.       if (str_contains($this->options['target'], '{{')) {
        // We cast as we need the integer/string value provided by the         // ::tokenizeValue() call.         $target_id = (string) $this->tokenizeValue($this->options['target']);
        if ($entity = $this->entityTypeManager->getStorage($this->entityType)->load($target_id)) {
          $target_entity = $entity;
        }
      }
      else {
        if ($entity = $this->entityRepository->loadEntityByConfigTarget($this->entityType, $this->options['target'])) {
          $target_entity = $entity;
        }
      }
      if (isset($target_entity) && (!empty($this->options['bypass_access']) || $target_entity->access('view'))) {
        $view_builder = $this->entityTypeManager->getViewBuilder($this->entityType);
        
/** * Get RSS feed description. * * @return string * The string containing the description with the tokens replaced. */
  public function getDescription() {
    $description = $this->options['description'];

    // Allow substitutions from the first row.     $description = $this->tokenizeValue($description, 0);

    return $description;
  }

  public function render() {
    $rows = [];

    // This will be filled in by the row plugin and is used later on in the     // theming output.     $this->namespaces = ['xmlns:dc' => 'http://purl.org/dc/elements/1.1/'];

    

  public function getCustomClass($result_index$type) {
    $class = $this->options[$type . '_class_custom'];
    if ($this->usesFields() && $this->view->field) {
      $class = strip_tags($this->tokenizeValue($class$result_index));
    }

    $classes = explode(' ', $class);
    foreach ($classes as &$class) {
      $class = Html::cleanCssIdentifier($class);
    }
    return implode(' ', $classes);
  }

}

      $elements += \Drupal::config('views.settings')->get('field_rewrite_elements');
    }

    return $elements;
  }

  /** * {@inheritdoc} */
  public function elementClasses($row_index = NULL) {
    $classes = $this->tokenizeValue($this->options['element_class']$row_index);
    $classes = explode(' ', $classes);
    foreach ($classes as &$class) {
      $class = Html::cleanCssIdentifier($class);
    }
    return implode(' ', $classes);
  }

  /** * {@inheritdoc} */
  public function tokenizeValue($value$row_index = NULL) {
    

    }

    return [];
  }

  /** * Render a text area with \Drupal\Component\Utility\Xss::filterAdmin(). */
  public function renderTextarea($value) {
    if ($value) {
      return $this->sanitizeValue($this->tokenizeValue($value), 'xss_admin');
    }
  }

}
// During building, we might find a title override. If so, use it.     if (!empty($this->build_info['title'])) {
      $title = $this->build_info['title'];
    }
    else {
      $title = $this->display_handler->getOption('title');
    }

    // Allow substitutions from the first row.     if ($this->initStyle()) {
      $title = $this->style_plugin->tokenizeValue($title, 0);
    }
    return $title;
  }

  /** * Overrides the view's current title. * * The tokens in the title gets replaced before rendering. * * @return true * Always returns TRUE. */

  }

  /** * {@inheritdoc} */
  public function render($empty = FALSE) {
    $format = $this->options['content']['format'] ?? filter_default_format();
    if (!$empty || !empty($this->options['empty'])) {
      return [
        '#type' => 'processed_text',
        '#text' => $this->tokenizeValue($this->options['content']['value']),
        '#format' => $format,
      ];
    }

    return [];
  }

}
public function defaultFieldLabels() {
    return $this->defaultFieldLabels;
  }

  /** * Return the token replaced row class for the specified row. */
  public function getRowClass($row_index) {
    if ($this->usesRowClass()) {
      $class = $this->options['row_class'];
      if ($this->usesFields() && $this->view->field) {
        $class = strip_tags($this->tokenizeValue($class$row_index));
      }

      $classes = explode(' ', $class);
      foreach ($classes as &$class) {
        $class = Html::cleanCssIdentifier($class);
      }
      return implode(' ', $classes);
    }
  }

  /** * Take a value and apply token replacement logic to it. */
Home | Imprint | This part of the site doesn't use cookies.