You are here

public function TokenReplacerBase::tokens in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 src/Token/TokenReplacerBase.php \Drupal\forena\Token\TokenReplacerBase::tokens()

List all of the tokens used in a piece of text, ignoring duplicates.

Parameters

string $text:

Return value

array tokens contained in the text according to the regular expression.

Overrides TokenReplacerInterface::tokens

File

src/Token/TokenReplacerBase.php, line 125
FrXSytnaxEngine defines how regular expression procesing/token substitution takes place. It includes support for passing in a formatter oobject that will escape strings properly before substituting them.

Class

TokenReplacerBase
Base class for token replacements. @package Drupal\forena\Token

Namespace

Drupal\forena\Token

Code

public function tokens($text) {
  $match = array();
  $tokens = array();
  if (preg_match_all($this->tpattern, $text, $match)) {
    $i = 0;
    foreach ($match[0] as $match_num => $token) {
      $path = trim($token, $this->trim_chars);
      if (array_search($path, $tokens) === FALSE) {
        $tokens[] = $path;
      }
    }
  }
  return $tokens;
}