You are here

public function TokenReplacerBase::test in Forena Reports 7.5

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

Test for TRUE/FALSE for conditions that are able to be represented using bind parameters Note that & are used to separate the different conditions and these are to be OR'd together.

Parameters

$condition String:

Overrides TokenReplacerInterface::test

File

src/Token/TokenReplacerBase.php, line 165
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

Namespace

Drupal\forena\Token

Code

public function test($condition) {
  $eval = TRUE;
  $tests = explode('&', $condition);
  if ($tests) {
    foreach ($tests as $test) {
      $t = trim($test);
      $res = $this
        ->replace($t, TRUE);
      if (is_string($res)) {
        $res = trim($res, ' !') ? TRUE : FALSE;
        if (strpos($t, '!') === 0) {
          $res = !$res;
        }
      }
      else {
        $res = $res ? TRUE : FALSE;
      }
      $eval = $eval && $res;
    }
  }
  return $eval;
}