globalTokenReplace example

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    $this->globalTokenForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function render($empty = FALSE) {
    if (!$empty || !empty($this->options['empty'])) {
      return [
        '#markup' => $this->globalTokenReplace($this->options['string']),
      ];
    }
    return [];
  }

}
    $this->globalTokenForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function preRender(array $results) {
    parent::preRender($results);

    // If a title is provided, process it.     if (!empty($this->options['title'])) {
      $value = $this->globalTokenReplace($this->options['title']);
      $this->view->setTitle($this->sanitizeValue($value, 'xss_admin'));
    }
  }

  /** * {@inheritdoc} */
  public function render($empty = FALSE) {
    // Do nothing for this handler by returning an empty render array.     return [];
  }

}

  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);
  }

}
Home | Imprint | This part of the site doesn't use cookies.